Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: components/autofill/browser/autofill_profile.h

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_AUTOFILL_PROFILE_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <iosfwd> 10 #include <iosfwd>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 virtual string16 GetRawInfo(AutofillFieldType type) const OVERRIDE; 45 virtual string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
46 virtual void SetRawInfo(AutofillFieldType type, 46 virtual void SetRawInfo(AutofillFieldType type,
47 const string16& value) OVERRIDE; 47 const string16& value) OVERRIDE;
48 virtual string16 GetInfo(AutofillFieldType type, 48 virtual string16 GetInfo(AutofillFieldType type,
49 const std::string& app_locale) const OVERRIDE; 49 const std::string& app_locale) const OVERRIDE;
50 virtual bool SetInfo(AutofillFieldType type, 50 virtual bool SetInfo(AutofillFieldType type,
51 const string16& value, 51 const string16& value,
52 const std::string& app_locale) OVERRIDE; 52 const std::string& app_locale) OVERRIDE;
53 virtual void FillFormField(const AutofillField& field, 53 virtual void FillFormField(const AutofillField& field,
54 size_t variant, 54 size_t variant,
55 const std::string& app_locale,
55 FormFieldData* field_data) const OVERRIDE; 56 FormFieldData* field_data) const OVERRIDE;
56 57
57 // Multi-value equivalents to |GetInfo| and |SetInfo|. 58 // Multi-value equivalents to |GetInfo| and |SetInfo|.
58 void SetRawMultiInfo(AutofillFieldType type, 59 void SetRawMultiInfo(AutofillFieldType type,
59 const std::vector<string16>& values); 60 const std::vector<string16>& values);
60 void GetRawMultiInfo(AutofillFieldType type, 61 void GetRawMultiInfo(AutofillFieldType type,
61 std::vector<string16>* values) const; 62 std::vector<string16>* values) const;
62 void GetMultiInfo(AutofillFieldType type, 63 void GetMultiInfo(AutofillFieldType type,
63 const std::string& app_locale, 64 const std::string& app_locale,
64 std::vector<string16>* values) const; 65 std::vector<string16>* values) const;
65 66
66 // Set |field_data|'s value for phone number based on contents of |this|. 67 // Set |field_data|'s value for phone number based on contents of |this|.
67 // The |field| specifies the type of the phone and whether this is a 68 // The |field| specifies the type of the phone and whether this is a
68 // phone prefix or suffix. The |variant| parameter specifies which value in a 69 // phone prefix or suffix. The |variant| parameter specifies which value in a
69 // multi-valued profile. 70 // multi-valued profile.
70 void FillPhoneNumberField(const AutofillField& field, 71 void FillPhoneNumberField(const AutofillField& field,
71 size_t variant, 72 size_t variant,
73 const std::string& app_locale,
72 FormFieldData* field_data) const; 74 FormFieldData* field_data) const;
73 75
74 // The user-visible label of the profile, generated in relation to other 76 // The user-visible label of the profile, generated in relation to other
75 // profiles. Shows at least 2 fields that differentiate profile from other 77 // profiles. Shows at least 2 fields that differentiate profile from other
76 // profiles. See AdjustInferredLabels() further down for more description. 78 // profiles. See AdjustInferredLabels() further down for more description.
77 const string16 Label() const; 79 const string16 Label() const;
78 80
79 // This guid is the primary identifier for |AutofillProfile| objects. 81 // This guid is the primary identifier for |AutofillProfile| objects.
80 // TODO(estade): remove this and just use GetGUID(). |guid_| can probably 82 // TODO(estade): remove this and just use GetGUID(). |guid_| can probably
81 // be moved to FormGroup. 83 // be moved to FormGroup.
82 const std::string guid() const { return guid_; } 84 const std::string guid() const { return guid_; }
83 void set_guid(const std::string& guid) { guid_ = guid; } 85 void set_guid(const std::string& guid) { guid_ = guid; }
84 86
85 // Accessors for the stored address's country code. 87 // Accessors for the stored address's country code.
86 const std::string CountryCode() const; 88 const std::string CountryCode() const;
87 void SetCountryCode(const std::string& country_code); 89 void SetCountryCode(const std::string& country_code);
88 90
89 // Returns true if there are no values (field types) set. 91 // Returns true if there are no values (field types) set.
90 bool IsEmpty() const; 92 bool IsEmpty(const std::string& app_locale) const;
91 93
92 // Comparison for Sync. Returns 0 if the profile is the same as |this|, 94 // Comparison for Sync. Returns 0 if the profile is the same as |this|,
93 // or < 0, or > 0 if it is different. The implied ordering can be used for 95 // or < 0, or > 0 if it is different. The implied ordering can be used for
94 // culling duplicates. The ordering is based on collation order of the 96 // culling duplicates. The ordering is based on collation order of the
95 // textual contents of the fields. 97 // textual contents of the fields.
96 // GUIDs are not compared, only the values of the contents themselves. 98 // GUIDs are not compared, only the values of the contents themselves.
97 // Full profile comparision, comparison includes multi-valued fields. 99 // Full profile comparision, comparison includes multi-valued fields.
98 int Compare(const AutofillProfile& profile) const; 100 int Compare(const AutofillProfile& profile) const;
99 101
100 // Equality operators compare GUIDs and the contents in the comparison. 102 // Equality operators compare GUIDs and the contents in the comparison.
101 bool operator==(const AutofillProfile& profile) const; 103 bool operator==(const AutofillProfile& profile) const;
102 virtual bool operator!=(const AutofillProfile& profile) const; 104 virtual bool operator!=(const AutofillProfile& profile) const;
103 105
104 // Returns concatenation of full name and address line 1. This acts as the 106 // Returns concatenation of full name and address line 1. This acts as the
105 // basis of comparison for new values that are submitted through forms to 107 // basis of comparison for new values that are submitted through forms to
106 // aid with correct aggregation of new data. 108 // aid with correct aggregation of new data.
107 const string16 PrimaryValue() const; 109 const string16 PrimaryValue() const;
108 110
109 // Returns true if the data in this AutofillProfile is a subset of the data in 111 // Returns true if the data in this AutofillProfile is a subset of the data in
110 // |profile|. 112 // |profile|.
111 bool IsSubsetOf(const AutofillProfile& profile) const; 113 bool IsSubsetOf(const AutofillProfile& profile,
114 const std::string& app_locale) const;
112 115
113 // Overwrites the single-valued field data in |profile| with this 116 // Overwrites the single-valued field data in |profile| with this
114 // Profile. Or, for multi-valued fields append the new values. 117 // Profile. Or, for multi-valued fields append the new values.
115 void OverwriteWithOrAddTo(const AutofillProfile& profile); 118 void OverwriteWithOrAddTo(const AutofillProfile& profile,
119 const std::string& app_locale);
116 120
117 // Returns |true| if |type| accepts multi-values. 121 // Returns |true| if |type| accepts multi-values.
118 static bool SupportsMultiValue(AutofillFieldType type); 122 static bool SupportsMultiValue(AutofillFieldType type);
119 123
120 // Adjusts the labels according to profile data. 124 // Adjusts the labels according to profile data.
121 // Labels contain minimal different combination of: 125 // Labels contain minimal different combination of:
122 // 1. Full name. 126 // 1. Full name.
123 // 2. Address. 127 // 2. Address.
124 // 3. E-mail. 128 // 3. E-mail.
125 // 4. Phone. 129 // 4. Phone.
(...skipping 16 matching lines...) Expand all
142 const std::vector<AutofillProfile*>* profiles, 146 const std::vector<AutofillProfile*>* profiles,
143 const std::vector<AutofillFieldType>* suggested_fields, 147 const std::vector<AutofillFieldType>* suggested_fields,
144 AutofillFieldType excluded_field, 148 AutofillFieldType excluded_field,
145 size_t minimal_fields_shown, 149 size_t minimal_fields_shown,
146 std::vector<string16>* created_labels); 150 std::vector<string16>* created_labels);
147 151
148 private: 152 private:
149 typedef std::vector<const FormGroup*> FormGroupList; 153 typedef std::vector<const FormGroup*> FormGroupList;
150 154
151 // FormGroup: 155 // FormGroup:
152 virtual bool FillCountrySelectControl(FormFieldData* field) const OVERRIDE; 156 virtual bool FillCountrySelectControl(const std::string& app_locale,
157 FormFieldData* field) const OVERRIDE;
153 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE; 158 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
154 159
155 // Shared implementation for GetRawMultiInfo() and GetMultiInfo(). Pass an 160 // Shared implementation for GetRawMultiInfo() and GetMultiInfo(). Pass an
156 // empty |app_locale| to get the raw info; otherwise, the returned info is 161 // empty |app_locale| to get the raw info; otherwise, the returned info is
157 // canonicalized according to the given |app_locale|, if appropriate. 162 // canonicalized according to the given |app_locale|, if appropriate.
158 void GetMultiInfoImpl(AutofillFieldType type, 163 void GetMultiInfoImpl(AutofillFieldType type,
159 const std::string& app_locale, 164 const std::string& app_locale,
160 std::vector<string16>* values) const; 165 std::vector<string16>* values) const;
161 166
162 // Checks if the |phone| is in the |existing_phones| using fuzzy matching: 167 // Checks if the |phone| is in the |existing_phones| using fuzzy matching:
163 // for example, "1-800-FLOWERS", "18003569377", "(800)356-9377" and "356-9377" 168 // for example, "1-800-FLOWERS", "18003569377", "(800)356-9377" and "356-9377"
164 // are considered the same. 169 // are considered the same.
165 // Adds the |phone| to the |existing_phones| if not already there. 170 // Adds the |phone| to the |existing_phones| if not already there.
166 void AddPhoneIfUnique(const string16& phone, 171 void AddPhoneIfUnique(const string16& phone,
172 const std::string& app_locale,
167 std::vector<string16>* existing_phones); 173 std::vector<string16>* existing_phones);
168 174
169 // Builds inferred label from the first |num_fields_to_include| non-empty 175 // Builds inferred label from the first |num_fields_to_include| non-empty
170 // fields in |label_fields|. Uses as many fields as possible if there are not 176 // fields in |label_fields|. Uses as many fields as possible if there are not
171 // enough non-empty fields. 177 // enough non-empty fields.
172 string16 ConstructInferredLabel( 178 string16 ConstructInferredLabel(
173 const std::vector<AutofillFieldType>& label_fields, 179 const std::vector<AutofillFieldType>& label_fields,
174 size_t num_fields_to_include) const; 180 size_t num_fields_to_include) const;
175 181
176 // Creates inferred labels for |profiles| at indices corresponding to 182 // Creates inferred labels for |profiles| at indices corresponding to
(...skipping 25 matching lines...) Expand all
202 std::vector<EmailInfo> email_; 208 std::vector<EmailInfo> email_;
203 CompanyInfo company_; 209 CompanyInfo company_;
204 std::vector<PhoneNumber> home_number_; 210 std::vector<PhoneNumber> home_number_;
205 Address address_; 211 Address address_;
206 }; 212 };
207 213
208 // So we can compare AutofillProfiles with EXPECT_EQ(). 214 // So we can compare AutofillProfiles with EXPECT_EQ().
209 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); 215 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile);
210 216
211 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_ 217 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698