1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_ 7 8 #include <string> 9 10 #include "components/autofill/core/browser/field_types.h" 11 #include "components/autofill/core/browser/form_group.h" 12 13 namespace autofill { 14 15 class AutofillField; 16 struct FormFieldData; 17 18 // This class is an interface for the primary data models that back Autofill. 19 // The information in objects of this class is managed by the 20 // PersonalDataManager. 21 class AutofillDataModel : public FormGroup { 22 public: 23 AutofillDataModel(const std::string& guid, const std::string& origin); 24 virtual ~AutofillDataModel(); 25 26 // Set |field_data|'s value based on |field| and contents of |this| (using 27 // data variant |variant|). 28 virtual void FillFormField(const AutofillField& field, 29 size_t variant, 30 const std::string& app_locale, 31 FormFieldData* field_data) const = 0; 32 33 // Fills in select control with data matching |type| from |this|. 34 // Public for testing purposes. 35 void FillSelectControl(const AutofillType& type, 36 const std::string& app_locale, 37 FormFieldData* field_data) const; 38 39 // Returns true if the data in this model was entered directly by the user, 40 // rather than automatically aggregated. 41 bool IsVerified() const; 42 43 std::string guid() const { return guid_; } 44 void set_guid(const std::string& guid) { guid_ = guid; } 45 46 std::string origin() const { return origin_; } 47 void set_origin(const std::string& origin) { origin_ = origin; } 48 49 protected: 50 // Fills in a select control for a country from data in |this|. Returns true 51 // for success. 52 virtual bool FillCountrySelectControl(const std::string& app_locale, 53 FormFieldData* field_data) const; 54 55 private: 56 // A globally unique ID for this object. 57 std::string guid_; 58 59 // The origin of this data. This should be 60 // (a) a web URL for the domain of the form from which the data was 61 // automatically aggregated, e.g. https://www.example.com/register, 62 // (b) some other non-empty string, which cannot be interpreted as a web 63 // URL, identifying the origin for non-aggregated data, or 64 // (c) an empty string, indicating that the origin for this data is unknown. 65 std::string origin_; 66 }; 67 68 } // namespace autofill 69 70 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_MODEL_H_ 71