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 24 matching lines...) Expand all Loading... |
35 // A profile synced down from the server. These are read-only locally. | 35 // A profile synced down from the server. These are read-only locally. |
36 SERVER_PROFILE, | 36 SERVER_PROFILE, |
37 | 37 |
38 // An auxiliary profile, such as a Mac address book entry. | 38 // An auxiliary profile, such as a Mac address book entry. |
39 AUXILIARY_PROFILE, | 39 AUXILIARY_PROFILE, |
40 }; | 40 }; |
41 | 41 |
42 AutofillProfile(const std::string& guid, const std::string& origin); | 42 AutofillProfile(const std::string& guid, const std::string& origin); |
43 | 43 |
44 // Server profile constructor. The type must be SERVER_PROFILE (this serves | 44 // Server profile constructor. The type must be SERVER_PROFILE (this serves |
45 // to differentiate this constructor). | 45 // to differentiate this constructor). |server_id| can be empty. If empty, |
| 46 // callers should invoke GenerateServerProfileIdentifier after setting data. |
46 AutofillProfile(RecordType type, const std::string& server_id); | 47 AutofillProfile(RecordType type, const std::string& server_id); |
47 | 48 |
48 // For use in STL containers. | 49 // For use in STL containers. |
49 AutofillProfile(); | 50 AutofillProfile(); |
50 AutofillProfile(const AutofillProfile& profile); | 51 AutofillProfile(const AutofillProfile& profile); |
51 ~AutofillProfile() override; | 52 ~AutofillProfile() override; |
52 | 53 |
53 AutofillProfile& operator=(const AutofillProfile& profile); | 54 AutofillProfile& operator=(const AutofillProfile& profile); |
54 | 55 |
55 // FormGroup: | 56 // FormGroup: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 std::vector<base::string16>* labels); | 175 std::vector<base::string16>* labels); |
175 | 176 |
176 const std::string& language_code() const { return language_code_; } | 177 const std::string& language_code() const { return language_code_; } |
177 void set_language_code(const std::string& language_code) { | 178 void set_language_code(const std::string& language_code) { |
178 language_code_ = language_code; | 179 language_code_ = language_code; |
179 } | 180 } |
180 | 181 |
181 // Nonempty only when type() == SERVER_PROFILE. | 182 // Nonempty only when type() == SERVER_PROFILE. |
182 const std::string& server_id() const { return server_id_; } | 183 const std::string& server_id() const { return server_id_; } |
183 | 184 |
| 185 // Creates an identifier and saves it as |server_id_|. Only used for |
| 186 // server credit cards. The server doesn't attach an identifier so Chrome |
| 187 // creates its own. The ID is a hash of the data contained in the profile. |
| 188 void GenerateServerProfileIdentifier(); |
| 189 |
184 // Returns a standardized representation of the given string for comparison | 190 // Returns a standardized representation of the given string for comparison |
185 // purposes. The resulting string will be lower-cased with all punctuation | 191 // purposes. The resulting string will be lower-cased with all punctuation |
186 // substituted by spaces. Whitespace will be converted to ASCII space, and | 192 // substituted by spaces. Whitespace will be converted to ASCII space, and |
187 // multiple whitespace characters will be collapsed. | 193 // multiple whitespace characters will be collapsed. |
188 // | 194 // |
189 // This string is designed for comparison purposes only and isn't suitable | 195 // This string is designed for comparison purposes only and isn't suitable |
190 // for storing or displaying to the user. | 196 // for storing or displaying to the user. |
191 static base::string16 CanonicalizeProfileString(const base::string16& str); | 197 static base::string16 CanonicalizeProfileString(const base::string16& str); |
192 | 198 |
193 // Returns true if the given two profile strings are similar enough that | 199 // Returns true if the given two profile strings are similar enough that |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // Personal information for this profile. | 256 // Personal information for this profile. |
251 std::vector<NameInfo> name_; | 257 std::vector<NameInfo> name_; |
252 std::vector<EmailInfo> email_; | 258 std::vector<EmailInfo> email_; |
253 CompanyInfo company_; | 259 CompanyInfo company_; |
254 std::vector<PhoneNumber> phone_number_; | 260 std::vector<PhoneNumber> phone_number_; |
255 Address address_; | 261 Address address_; |
256 | 262 |
257 // The BCP 47 language code that can be used to format |address_| for display. | 263 // The BCP 47 language code that can be used to format |address_| for display. |
258 std::string language_code_; | 264 std::string language_code_; |
259 | 265 |
260 // ID assigned by the server. This will be set only for WALLET_PROFILEs. | 266 // ID used for identifying this profile. Only set for SERVER_PROFILEs. This is |
| 267 // a hash of the contents. |
261 std::string server_id_; | 268 std::string server_id_; |
262 }; | 269 }; |
263 | 270 |
264 // So we can compare AutofillProfiles with EXPECT_EQ(). | 271 // So we can compare AutofillProfiles with EXPECT_EQ(). |
265 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 272 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
266 | 273 |
267 } // namespace autofill | 274 } // namespace autofill |
268 | 275 |
269 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 276 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
OLD | NEW |