| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <iosfwd> | 10 #include <iosfwd> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Returns true if there are no values (field types) set. | 71 // Returns true if there are no values (field types) set. |
| 72 bool IsEmpty(const std::string& app_locale) const; | 72 bool IsEmpty(const std::string& app_locale) const; |
| 73 | 73 |
| 74 // Returns true if the |type| of data in this profile is present, but invalid. | 74 // Returns true if the |type| of data in this profile is present, but invalid. |
| 75 // Otherwise returns false. | 75 // Otherwise returns false. |
| 76 bool IsPresentButInvalid(ServerFieldType type) const; | 76 bool IsPresentButInvalid(ServerFieldType type) const; |
| 77 | 77 |
| 78 // Comparison for Sync. Returns 0 if the profile is the same as |this|, | 78 // Comparison for Sync. Returns 0 if the profile is the same as |this|, |
| 79 // or < 0, or > 0 if it is different. The implied ordering can be used for | 79 // or < 0, or > 0 if it is different. The implied ordering can be used for |
| 80 // culling duplicates. The ordering is based on collation order of the | 80 // culling duplicates. The ordering is based on collation order of the |
| 81 // textual contents of the fields. | 81 // textual contents of the fields. Full profile comparison, comparison |
| 82 // GUIDs and origins are not compared, only the values of the contents | 82 // includes multi-valued fields. |
| 83 // themselves. Full profile comparision, comparison includes multi-valued | 83 // |
| 84 // fields. | 84 // GUIDs, origins, and language codes are not compared, only the contents |
| 85 // themselves. |
| 85 int Compare(const AutofillProfile& profile) const; | 86 int Compare(const AutofillProfile& profile) const; |
| 86 | 87 |
| 87 // Equality operators compare GUIDs, origins, and the contents in the | 88 // Same as operator==, but ignores differences in origin. |
| 88 // comparison. | 89 bool EqualsSansOrigin(const AutofillProfile& profile) const; |
| 90 |
| 91 // Same as operator==, but ignores differences in GUID. |
| 92 bool EqualsSansGuid(const AutofillProfile& profile) const; |
| 93 |
| 94 // Equality operators compare GUIDs, origins, language code, and the contents |
| 95 // in the comparison. |
| 89 bool operator==(const AutofillProfile& profile) const; | 96 bool operator==(const AutofillProfile& profile) const; |
| 90 virtual bool operator!=(const AutofillProfile& profile) const; | 97 virtual bool operator!=(const AutofillProfile& profile) const; |
| 91 | 98 |
| 92 // Returns concatenation of full name and address line 1. This acts as the | 99 // Returns concatenation of full name and address line 1. This acts as the |
| 93 // basis of comparison for new values that are submitted through forms to | 100 // basis of comparison for new values that are submitted through forms to |
| 94 // aid with correct aggregation of new data. | 101 // aid with correct aggregation of new data. |
| 95 const base::string16 PrimaryValue() const; | 102 const base::string16 PrimaryValue() const; |
| 96 | 103 |
| 97 // Returns true if the data in this AutofillProfile is a subset of the data in | 104 // Returns true if the data in this AutofillProfile is a subset of the data in |
| 98 // |profile|. | 105 // |profile|. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 125 // and |excluded_field| is ignored; by convention, it should be of | 132 // and |excluded_field| is ignored; by convention, it should be of |
| 126 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at | 133 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at |
| 127 // least |minimal_fields_shown| fields, if possible. | 134 // least |minimal_fields_shown| fields, if possible. |
| 128 static void CreateInferredLabels( | 135 static void CreateInferredLabels( |
| 129 const std::vector<AutofillProfile*>& profiles, | 136 const std::vector<AutofillProfile*>& profiles, |
| 130 const std::vector<ServerFieldType>* suggested_fields, | 137 const std::vector<ServerFieldType>* suggested_fields, |
| 131 ServerFieldType excluded_field, | 138 ServerFieldType excluded_field, |
| 132 size_t minimal_fields_shown, | 139 size_t minimal_fields_shown, |
| 133 std::vector<base::string16>* labels); | 140 std::vector<base::string16>* labels); |
| 134 | 141 |
| 142 const std::string& language_code() const { return language_code_; } |
| 143 void set_language_code(const std::string& language_code) { |
| 144 language_code_ = language_code; |
| 145 } |
| 146 |
| 135 private: | 147 private: |
| 136 typedef std::vector<const FormGroup*> FormGroupList; | 148 typedef std::vector<const FormGroup*> FormGroupList; |
| 137 | 149 |
| 138 // FormGroup: | 150 // FormGroup: |
| 139 virtual void GetSupportedTypes( | 151 virtual void GetSupportedTypes( |
| 140 ServerFieldTypeSet* supported_types) const OVERRIDE; | 152 ServerFieldTypeSet* supported_types) const OVERRIDE; |
| 141 | 153 |
| 142 // Shared implementation for GetRawMultiInfo() and GetMultiInfo(). Pass an | 154 // Shared implementation for GetRawMultiInfo() and GetMultiInfo(). Pass an |
| 143 // empty |app_locale| to get the raw info; otherwise, the returned info is | 155 // empty |app_locale| to get the raw info; otherwise, the returned info is |
| 144 // canonicalized according to the given |app_locale|, if appropriate. | 156 // canonicalized according to the given |app_locale|, if appropriate. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 FormGroupList FormGroups() const; | 190 FormGroupList FormGroups() const; |
| 179 const FormGroup* FormGroupForType(const AutofillType& type) const; | 191 const FormGroup* FormGroupForType(const AutofillType& type) const; |
| 180 FormGroup* MutableFormGroupForType(const AutofillType& type); | 192 FormGroup* MutableFormGroupForType(const AutofillType& type); |
| 181 | 193 |
| 182 // Personal information for this profile. | 194 // Personal information for this profile. |
| 183 std::vector<NameInfo> name_; | 195 std::vector<NameInfo> name_; |
| 184 std::vector<EmailInfo> email_; | 196 std::vector<EmailInfo> email_; |
| 185 CompanyInfo company_; | 197 CompanyInfo company_; |
| 186 std::vector<PhoneNumber> phone_number_; | 198 std::vector<PhoneNumber> phone_number_; |
| 187 Address address_; | 199 Address address_; |
| 200 |
| 201 // The BCP 47 language code that can be used to format |address_| for display. |
| 202 std::string language_code_; |
| 188 }; | 203 }; |
| 189 | 204 |
| 190 // So we can compare AutofillProfiles with EXPECT_EQ(). | 205 // So we can compare AutofillProfiles with EXPECT_EQ(). |
| 191 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 206 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
| 192 | 207 |
| 193 } // namespace autofill | 208 } // namespace autofill |
| 194 | 209 |
| 195 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 210 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
| OLD | NEW |