Chromium Code Reviews| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 // Same as operator==, but ignores differences in guid and cares about | 92 // Same as operator==, but ignores differences in guid and cares about |
| 93 // differences in usage stats. | 93 // differences in usage stats. |
| 94 bool EqualsForSyncPurposes(const AutofillProfile& profile) const; | 94 bool EqualsForSyncPurposes(const AutofillProfile& profile) const; |
| 95 | 95 |
| 96 // Equality operators compare GUIDs, origins, language code, and the contents | 96 // Equality operators compare GUIDs, origins, language code, and the contents |
| 97 // in the comparison. Usage metadata (use count, use date, modification date) | 97 // in the comparison. Usage metadata (use count, use date, modification date) |
| 98 // are NOT compared. | 98 // are NOT compared. |
| 99 bool operator==(const AutofillProfile& profile) const; | 99 bool operator==(const AutofillProfile& profile) const; |
| 100 virtual bool operator!=(const AutofillProfile& profile) const; | 100 virtual bool operator!=(const AutofillProfile& profile) const; |
| 101 | 101 |
| 102 // Returns concatenation of first name, last name, address line 1 and city, | |
| 103 // with each part separated by a whitespace. This acts as the basis of | |
| 104 // comparison for new values that are submitted through forms to aid with | |
| 105 // correct aggregation of new data. | |
| 106 const base::string16 PrimaryValue(const std::string& app_locale) const; | |
| 107 | |
| 108 // Returns true if the data in this AutofillProfile is a subset of the data in | 102 // Returns true if the data in this AutofillProfile is a subset of the data in |
| 109 // |profile|. | 103 // |profile|. |
| 110 bool IsSubsetOf(const AutofillProfile& profile, | 104 bool IsSubsetOf(const AutofillProfile& profile, |
| 111 const std::string& app_locale) const; | 105 const std::string& app_locale) const; |
| 112 | 106 |
| 113 // Like IsSubsetOf, but only considers the types present in |types|. | 107 // Like IsSubsetOf, but only considers the types present in |types|. |
| 114 bool IsSubsetOfForFieldSet(const AutofillProfile& profile, | 108 bool IsSubsetOfForFieldSet(const AutofillProfile& profile, |
| 115 const std::string& app_locale, | 109 const std::string& app_locale, |
| 116 const ServerFieldTypeSet& types) const; | 110 const ServerFieldTypeSet& types) const; |
| 117 | 111 |
| 118 // Overwrites the field data in this Profile with the non-empty fields in | 112 // Overwrites the field data in this Profile with the non-empty fields in |
| 119 // |profile|. Returns |true| if at least one field was overwritten. | 113 // |profile|. Returns |true| if at least one field was overwritten. |
| 120 // The usage stats, the origin and the language code are always updated and | 114 // The usage stats, the origin and the language code are always updated and |
| 121 // have no effect on the return value. | 115 // have no effect on the return value. |
|
sebsg
2016/06/29 08:57:03
Add a note that the two profiles should be conside
Roger McFarlane (Chromium)
2016/06/29 18:21:37
Done.
| |
| 122 bool OverwriteWith(const AutofillProfile& profile, | 116 bool OverwriteWith(const AutofillProfile& profile, |
| 123 const std::string& app_locale); | 117 const std::string& app_locale); |
| 124 | 118 |
| 125 // Saves info from |profile| into |this|, provided |this| and |profile| do not | 119 // Saves info from |profile| into |this|, provided |this| and |profile| do not |
| 126 // have any direct conflicts (i.e. data is present but different). Will not | 120 // have any direct conflicts (i.e. data is present but different). Will not |
| 127 // make changes if |this| is verified and |profile| is not. Returns true if | 121 // make changes if |this| is verified and |profile| is not. Returns true if |
| 128 // |this| and |profile| are similar. | 122 // |this| and |profile| are similar. |
| 129 bool SaveAdditionalInfo(const AutofillProfile& profile, | 123 bool SaveAdditionalInfo(const AutofillProfile& profile, |
| 130 const std::string& app_locale); | 124 const std::string& app_locale); |
| 131 | 125 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 164 |
| 171 // Creates an identifier and saves it as |server_id_|. Only used for | 165 // Creates an identifier and saves it as |server_id_|. Only used for |
| 172 // server credit cards. The server doesn't attach an identifier so Chrome | 166 // server credit cards. The server doesn't attach an identifier so Chrome |
| 173 // creates its own. The ID is a hash of the data contained in the profile. | 167 // creates its own. The ID is a hash of the data contained in the profile. |
| 174 void GenerateServerProfileIdentifier(); | 168 void GenerateServerProfileIdentifier(); |
| 175 | 169 |
| 176 // Logs the number of days since the profile was last used and records its | 170 // Logs the number of days since the profile was last used and records its |
| 177 // use. | 171 // use. |
| 178 void RecordAndLogUse(); | 172 void RecordAndLogUse(); |
| 179 | 173 |
| 180 // TODO(crbug.com/574081): Move common profile methods to a utils file. | |
| 181 // Returns a standardized representation of the given string for comparison | |
| 182 // purposes. The resulting string will be lower-cased with all punctuation | |
| 183 // substituted by spaces. Whitespace will be converted to ASCII space, and | |
| 184 // multiple whitespace characters will be collapsed. | |
| 185 // | |
| 186 // This string is designed for comparison purposes only and isn't suitable | |
| 187 // for storing or displaying to the user. | |
| 188 static base::string16 CanonicalizeProfileString(const base::string16& str); | |
| 189 | |
| 190 private: | 174 private: |
| 191 typedef std::vector<const FormGroup*> FormGroupList; | 175 typedef std::vector<const FormGroup*> FormGroupList; |
| 192 | 176 |
| 193 // FormGroup: | 177 // FormGroup: |
| 194 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; | 178 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; |
| 195 | 179 |
| 196 // Builds inferred label from the first |num_fields_to_include| non-empty | 180 // Builds inferred label from the first |num_fields_to_include| non-empty |
| 197 // fields in |label_fields|. Uses as many fields as possible if there are not | 181 // fields in |label_fields|. Uses as many fields as possible if there are not |
| 198 // enough non-empty fields. | 182 // enough non-empty fields. |
| 199 base::string16 ConstructInferredLabel( | 183 base::string16 ConstructInferredLabel( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 // a hash of the contents. | 229 // a hash of the contents. |
| 246 std::string server_id_; | 230 std::string server_id_; |
| 247 }; | 231 }; |
| 248 | 232 |
| 249 // So we can compare AutofillProfiles with EXPECT_EQ(). | 233 // So we can compare AutofillProfiles with EXPECT_EQ(). |
| 250 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 234 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
| 251 | 235 |
| 252 } // namespace autofill | 236 } // namespace autofill |
| 253 | 237 |
| 254 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 238 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
| OLD | NEW |