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> |
| 11 #include <list> | 11 #include <list> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "base/time/time.h" | |
| 17 #include "components/autofill/core/browser/address.h" | 18 #include "components/autofill/core/browser/address.h" |
| 18 #include "components/autofill/core/browser/autofill_data_model.h" | 19 #include "components/autofill/core/browser/autofill_data_model.h" |
| 19 #include "components/autofill/core/browser/autofill_type.h" | 20 #include "components/autofill/core/browser/autofill_type.h" |
| 20 #include "components/autofill/core/browser/contact_info.h" | 21 #include "components/autofill/core/browser/contact_info.h" |
| 21 #include "components/autofill/core/browser/phone_number.h" | 22 #include "components/autofill/core/browser/phone_number.h" |
| 22 | 23 |
| 23 namespace autofill { | 24 namespace autofill { |
| 24 | 25 |
| 25 // A collection of FormGroups stored in a profile. AutofillProfile also | 26 // A collection of FormGroups stored in a profile. AutofillProfile also |
| 26 // implements the FormGroup interface so that owners of this object can request | 27 // implements the FormGroup interface so that owners of this object can request |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 | 168 |
| 168 // Nonempty only when type() == SERVER_PROFILE. base::kSHA1Length bytes long. | 169 // Nonempty only when type() == SERVER_PROFILE. base::kSHA1Length bytes long. |
| 169 // Not necessarily valid UTF-8. | 170 // Not necessarily valid UTF-8. |
| 170 const std::string& server_id() const { return server_id_; } | 171 const std::string& server_id() const { return server_id_; } |
| 171 | 172 |
| 172 // Creates an identifier and saves it as |server_id_|. Only used for | 173 // Creates an identifier and saves it as |server_id_|. Only used for |
| 173 // server credit cards. The server doesn't attach an identifier so Chrome | 174 // server credit cards. The server doesn't attach an identifier so Chrome |
| 174 // creates its own. The ID is a hash of the data contained in the profile. | 175 // creates its own. The ID is a hash of the data contained in the profile. |
| 175 void GenerateServerProfileIdentifier(); | 176 void GenerateServerProfileIdentifier(); |
| 176 | 177 |
| 177 // Logs the number of days since the profile was last used and records its | 178 // Logs the number of days since the profile was last used, records its |
| 178 // use. | 179 // use and updates |previous_use_date_| to time it was previously used. |
|
sebsg
2017/05/08 21:43:29
nit: and updates |previous_use_date_| to the last
csashi
2017/05/08 21:51:41
Done.
| |
| 179 void RecordAndLogUse(); | 180 void RecordAndLogUse(); |
| 180 | 181 |
| 181 // Valid only when type() == SERVER_PROFILE. | 182 const base::Time& previous_use_date() const { return previous_use_date_; } |
| 183 void set_previous_use_date(const base::Time& time) { | |
| 184 previous_use_date_ = time; | |
| 185 } | |
| 186 | |
| 187 // Valid only when |record_type()| == |SERVER_PROFILE|. | |
| 182 bool has_converted() const { return has_converted_; } | 188 bool has_converted() const { return has_converted_; } |
| 183 void set_has_converted(bool has_converted) { has_converted_ = has_converted; } | 189 void set_has_converted(bool has_converted) { has_converted_ = has_converted; } |
| 184 | 190 |
| 185 private: | 191 private: |
| 186 typedef std::vector<const FormGroup*> FormGroupList; | 192 typedef std::vector<const FormGroup*> FormGroupList; |
| 187 | 193 |
| 188 // FormGroup: | 194 // FormGroup: |
| 189 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; | 195 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; |
| 190 | 196 |
| 191 // Creates inferred labels for |profiles| at indices corresponding to | 197 // Creates inferred labels for |profiles| at indices corresponding to |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 203 | 209 |
| 204 // Utilities for listing and lookup of the data members that constitute | 210 // Utilities for listing and lookup of the data members that constitute |
| 205 // user-visible profile information. | 211 // user-visible profile information. |
| 206 FormGroupList FormGroups() const; | 212 FormGroupList FormGroups() const; |
| 207 const FormGroup* FormGroupForType(const AutofillType& type) const; | 213 const FormGroup* FormGroupForType(const AutofillType& type) const; |
| 208 FormGroup* MutableFormGroupForType(const AutofillType& type); | 214 FormGroup* MutableFormGroupForType(const AutofillType& type); |
| 209 | 215 |
| 210 // Same as operator==, but ignores differences in GUID. | 216 // Same as operator==, but ignores differences in GUID. |
| 211 bool EqualsSansGuid(const AutofillProfile& profile) const; | 217 bool EqualsSansGuid(const AutofillProfile& profile) const; |
| 212 | 218 |
| 213 RecordType record_type_; | |
| 214 | |
| 215 // Personal information for this profile. | 219 // Personal information for this profile. |
| 216 NameInfo name_; | 220 NameInfo name_; |
| 217 EmailInfo email_; | 221 EmailInfo email_; |
| 218 CompanyInfo company_; | 222 CompanyInfo company_; |
| 219 PhoneNumber phone_number_; | 223 PhoneNumber phone_number_; |
| 220 Address address_; | 224 Address address_; |
| 221 | 225 |
| 222 // The BCP 47 language code that can be used to format |address_| for display. | 226 // The BCP 47 language code that can be used to format |address_| for display. |
| 223 std::string language_code_; | 227 std::string language_code_; |
| 224 | 228 |
| 225 // ID used for identifying this profile. Only set for SERVER_PROFILEs. This is | 229 // ID used for identifying this profile. Only set for SERVER_PROFILEs. This is |
| 226 // a hash of the contents. | 230 // a hash of the contents. |
| 227 std::string server_id_; | 231 std::string server_id_; |
| 228 | 232 |
| 233 // Penultimate time model was used. | |
| 234 base::Time previous_use_date_; | |
|
sebsg
2017/05/08 21:43:29
Could you add a comment here, saying that this val
csashi
2017/05/08 21:51:41
Done.
| |
| 235 | |
| 236 RecordType record_type_; | |
|
sebsg
2017/05/08 21:43:29
Is there a particular reason why you moved it down
csashi
2017/05/08 21:51:41
https://bugs.chromium.org/p/chromium/issues/detail
sebsg
2017/05/08 21:54:19
Ah sweet, thank for the info.
| |
| 237 | |
| 229 // Only useful for SERVER_PROFILEs. Whether this server profile has been | 238 // Only useful for SERVER_PROFILEs. Whether this server profile has been |
| 230 // converted to a local profile. | 239 // converted to a local profile. |
| 231 bool has_converted_; | 240 bool has_converted_; |
| 232 }; | 241 }; |
| 233 | 242 |
| 234 // So we can compare AutofillProfiles with EXPECT_EQ(). | 243 // So we can compare AutofillProfiles with EXPECT_EQ(). |
| 235 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 244 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
| 236 | 245 |
| 237 } // namespace autofill | 246 } // namespace autofill |
| 238 | 247 |
| 239 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 248 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
| OLD | NEW |