| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <list> | 10 #include <list> |
| 11 #include <ostream> | 11 #include <ostream> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "chrome/browser/autofill/address.h" | 16 #include "chrome/browser/autofill/address.h" |
| 17 #include "chrome/browser/autofill/autofill_type.h" | 17 #include "chrome/browser/autofill/autofill_type.h" |
| 18 #include "chrome/browser/autofill/contact_info.h" | 18 #include "chrome/browser/autofill/contact_info.h" |
| 19 #include "chrome/browser/autofill/fax_number.h" | |
| 20 #include "chrome/browser/autofill/field_types.h" | 19 #include "chrome/browser/autofill/field_types.h" |
| 21 #include "chrome/browser/autofill/form_group.h" | 20 #include "chrome/browser/autofill/form_group.h" |
| 22 #include "chrome/browser/autofill/home_phone_number.h" | 21 #include "chrome/browser/autofill/home_phone_number.h" |
| 23 | 22 |
| 24 // A collection of FormGroups stored in a profile. AutofillProfile also | 23 // A collection of FormGroups stored in a profile. AutofillProfile also |
| 25 // implements the FormGroup interface so that owners of this object can request | 24 // implements the FormGroup interface so that owners of this object can request |
| 26 // form information from the profile, and the profile will delegate the request | 25 // form information from the profile, and the profile will delegate the request |
| 27 // to the requested form group type. | 26 // to the requested form group type. |
| 28 class AutofillProfile : public FormGroup { | 27 class AutofillProfile : public FormGroup { |
| 29 public: | 28 public: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // Accessors for the stored address's country code. | 67 // Accessors for the stored address's country code. |
| 69 const std::string CountryCode() const; | 68 const std::string CountryCode() const; |
| 70 void SetCountryCode(const std::string& country_code); | 69 void SetCountryCode(const std::string& country_code); |
| 71 | 70 |
| 72 // Adjusts the labels according to profile data. | 71 // Adjusts the labels according to profile data. |
| 73 // Labels contain minimal different combination of: | 72 // Labels contain minimal different combination of: |
| 74 // 1. Full name. | 73 // 1. Full name. |
| 75 // 2. Address. | 74 // 2. Address. |
| 76 // 3. E-mail. | 75 // 3. E-mail. |
| 77 // 4. Phone. | 76 // 4. Phone. |
| 78 // 5. Fax. | 77 // 5. Company name. |
| 79 // 6. Company name. | |
| 80 // Profile labels are changed accordingly to these rules. | 78 // Profile labels are changed accordingly to these rules. |
| 81 // Returns true if any of the profiles were updated. | 79 // Returns true if any of the profiles were updated. |
| 82 // This function is useful if you want to adjust unique labels for all | 80 // This function is useful if you want to adjust unique labels for all |
| 83 // profiles. For non permanent situations (selection of profile, when user | 81 // profiles. For non permanent situations (selection of profile, when user |
| 84 // started typing in the field, for example) use CreateInferredLabels(). | 82 // started typing in the field, for example) use CreateInferredLabels(). |
| 85 static bool AdjustInferredLabels(std::vector<AutofillProfile*>* profiles); | 83 static bool AdjustInferredLabels(std::vector<AutofillProfile*>* profiles); |
| 86 | 84 |
| 87 // Creates inferred labels for |profiles|, according to the rules above and | 85 // Creates inferred labels for |profiles|, according to the rules above and |
| 88 // stores them in |created_labels|. If |suggested_fields| is not NULL, the | 86 // stores them in |created_labels|. If |suggested_fields| is not NULL, the |
| 89 // resulting label fields are drawn from |suggested_fields|, except excluding | 87 // resulting label fields are drawn from |suggested_fields|, except excluding |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // aid with correct aggregation of new data. | 121 // aid with correct aggregation of new data. |
| 124 const string16 PrimaryValue() const; | 122 const string16 PrimaryValue() const; |
| 125 | 123 |
| 126 // Overwrites the single-valued field data in |profile| with this | 124 // Overwrites the single-valued field data in |profile| with this |
| 127 // Profile. Or, for multi-valued fields append the new values. | 125 // Profile. Or, for multi-valued fields append the new values. |
| 128 void OverwriteWithOrAddTo(const AutofillProfile& profile); | 126 void OverwriteWithOrAddTo(const AutofillProfile& profile); |
| 129 | 127 |
| 130 private: | 128 private: |
| 131 typedef std::vector<const FormGroup*> FormGroupList; | 129 typedef std::vector<const FormGroup*> FormGroupList; |
| 132 | 130 |
| 133 // FormGroup: | 131 // FormGroup implementation. |
| 134 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE; | 132 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE; |
| 135 | 133 |
| 136 // Shared implementation for GetMultiInfo() and GetCanonicalizedMultiInfo(). | 134 // Shared implementation for GetMultiInfo() and GetCanonicalizedMultiInfo(). |
| 137 void GetMultiInfoImpl(AutofillFieldType type, | 135 void GetMultiInfoImpl(AutofillFieldType type, |
| 138 bool canonicalize, | 136 bool canonicalize, |
| 139 std::vector<string16>* values) const; | 137 std::vector<string16>* values) const; |
| 140 | 138 |
| 141 // Checks if the |phone| is in the |existing_phones| using fuzzy matching: | 139 // Checks if the |phone| is in the |existing_phones| using fuzzy matching: |
| 142 // for example, "1-800-FLOWERS", "18003569377", "(800)356-9377" and "356-9377" | 140 // for example, "1-800-FLOWERS", "18003569377", "(800)356-9377" and "356-9377" |
| 143 // are considered the same. | 141 // are considered the same. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 174 string16 label_; | 172 string16 label_; |
| 175 | 173 |
| 176 // The guid of this profile. | 174 // The guid of this profile. |
| 177 std::string guid_; | 175 std::string guid_; |
| 178 | 176 |
| 179 // Personal information for this profile. | 177 // Personal information for this profile. |
| 180 std::vector<NameInfo> name_; | 178 std::vector<NameInfo> name_; |
| 181 std::vector<EmailInfo> email_; | 179 std::vector<EmailInfo> email_; |
| 182 CompanyInfo company_; | 180 CompanyInfo company_; |
| 183 std::vector<PhoneNumber> home_number_; | 181 std::vector<PhoneNumber> home_number_; |
| 184 std::vector<PhoneNumber> fax_number_; | |
| 185 Address address_; | 182 Address address_; |
| 186 }; | 183 }; |
| 187 | 184 |
| 188 // So we can compare AutofillProfiles with EXPECT_EQ(). | 185 // So we can compare AutofillProfiles with EXPECT_EQ(). |
| 189 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 186 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
| 190 | 187 |
| 191 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ | 188 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ |
| OLD | NEW |