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

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

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/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 21 matching lines...) Expand all
32 32
33 // For use in STL containers. 33 // For use in STL containers.
34 AutofillProfile(); 34 AutofillProfile();
35 AutofillProfile(const AutofillProfile& profile); 35 AutofillProfile(const AutofillProfile& profile);
36 virtual ~AutofillProfile(); 36 virtual ~AutofillProfile();
37 37
38 AutofillProfile& operator=(const AutofillProfile& profile); 38 AutofillProfile& operator=(const AutofillProfile& profile);
39 39
40 // FormGroup: 40 // FormGroup:
41 virtual std::string GetGUID() const OVERRIDE; 41 virtual std::string GetGUID() const OVERRIDE;
42 virtual void GetMatchingTypes(const string16& text, 42 virtual void GetMatchingTypes(const base::string16& text,
43 const std::string& app_locale, 43 const std::string& app_locale,
44 FieldTypeSet* matching_types) const OVERRIDE; 44 FieldTypeSet* matching_types) const OVERRIDE;
45 virtual string16 GetRawInfo(AutofillFieldType type) const OVERRIDE; 45 virtual base::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 base::string16& value) OVERRIDE;
48 virtual string16 GetInfo(AutofillFieldType type, 48 virtual base::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 base::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 const std::string& app_locale,
56 FormFieldData* field_data) const OVERRIDE; 56 FormFieldData* field_data) const OVERRIDE;
57 57
58 // Multi-value equivalents to |GetInfo| and |SetInfo|. 58 // Multi-value equivalents to |GetInfo| and |SetInfo|.
59 void SetRawMultiInfo(AutofillFieldType type, 59 void SetRawMultiInfo(AutofillFieldType type,
60 const std::vector<string16>& values); 60 const std::vector<base::string16>& values);
61 void GetRawMultiInfo(AutofillFieldType type, 61 void GetRawMultiInfo(AutofillFieldType type,
62 std::vector<string16>* values) const; 62 std::vector<base::string16>* values) const;
63 void GetMultiInfo(AutofillFieldType type, 63 void GetMultiInfo(AutofillFieldType type,
64 const std::string& app_locale, 64 const std::string& app_locale,
65 std::vector<string16>* values) const; 65 std::vector<base::string16>* values) const;
66 66
67 // 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|.
68 // 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
69 // 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
70 // multi-valued profile. 70 // multi-valued profile.
71 void FillPhoneNumberField(const AutofillField& field, 71 void FillPhoneNumberField(const AutofillField& field,
72 size_t variant, 72 size_t variant,
73 const std::string& app_locale, 73 const std::string& app_locale,
74 FormFieldData* field_data) const; 74 FormFieldData* field_data) const;
75 75
76 // 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
77 // profiles. Shows at least 2 fields that differentiate profile from other 77 // profiles. Shows at least 2 fields that differentiate profile from other
78 // profiles. See AdjustInferredLabels() further down for more description. 78 // profiles. See AdjustInferredLabels() further down for more description.
79 const string16 Label() const; 79 const base::string16 Label() const;
80 80
81 // This guid is the primary identifier for |AutofillProfile| objects. 81 // This guid is the primary identifier for |AutofillProfile| objects.
82 // TODO(estade): remove this and just use GetGUID(). |guid_| can probably 82 // TODO(estade): remove this and just use GetGUID(). |guid_| can probably
83 // be moved to FormGroup. 83 // be moved to FormGroup.
84 const std::string guid() const { return guid_; } 84 const std::string guid() const { return guid_; }
85 void set_guid(const std::string& guid) { guid_ = guid; } 85 void set_guid(const std::string& guid) { guid_ = guid; }
86 86
87 // Returns true if there are no values (field types) set. 87 // Returns true if there are no values (field types) set.
88 bool IsEmpty(const std::string& app_locale) const; 88 bool IsEmpty(const std::string& app_locale) const;
89 89
90 // Comparison for Sync. Returns 0 if the profile is the same as |this|, 90 // Comparison for Sync. Returns 0 if the profile is the same as |this|,
91 // or < 0, or > 0 if it is different. The implied ordering can be used for 91 // or < 0, or > 0 if it is different. The implied ordering can be used for
92 // culling duplicates. The ordering is based on collation order of the 92 // culling duplicates. The ordering is based on collation order of the
93 // textual contents of the fields. 93 // textual contents of the fields.
94 // GUIDs are not compared, only the values of the contents themselves. 94 // GUIDs are not compared, only the values of the contents themselves.
95 // Full profile comparision, comparison includes multi-valued fields. 95 // Full profile comparision, comparison includes multi-valued fields.
96 int Compare(const AutofillProfile& profile) const; 96 int Compare(const AutofillProfile& profile) const;
97 97
98 // Equality operators compare GUIDs and the contents in the comparison. 98 // Equality operators compare GUIDs and the contents in the comparison.
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 full name and address line 1. This acts as the 102 // Returns concatenation of full name and address line 1. This acts as the
103 // basis of comparison for new values that are submitted through forms to 103 // basis of comparison for new values that are submitted through forms to
104 // aid with correct aggregation of new data. 104 // aid with correct aggregation of new data.
105 const string16 PrimaryValue() const; 105 const base::string16 PrimaryValue() const;
106 106
107 // Returns true if the data in this AutofillProfile is a subset of the data in 107 // Returns true if the data in this AutofillProfile is a subset of the data in
108 // |profile|. 108 // |profile|.
109 bool IsSubsetOf(const AutofillProfile& profile, 109 bool IsSubsetOf(const AutofillProfile& profile,
110 const std::string& app_locale) const; 110 const std::string& app_locale) const;
111 111
112 // Overwrites the single-valued field data in |profile| with this 112 // Overwrites the single-valued field data in |profile| with this
113 // Profile. Or, for multi-valued fields append the new values. 113 // Profile. Or, for multi-valued fields append the new values.
114 void OverwriteWithOrAddTo(const AutofillProfile& profile, 114 void OverwriteWithOrAddTo(const AutofillProfile& profile,
115 const std::string& app_locale); 115 const std::string& app_locale);
(...skipping 20 matching lines...) Expand all
136 // resulting label fields are drawn from |suggested_fields|, except excluding 136 // resulting label fields are drawn from |suggested_fields|, except excluding
137 // |excluded_field|. Otherwise, the label fields are drawn from a default set, 137 // |excluded_field|. Otherwise, the label fields are drawn from a default set,
138 // and |excluded_field| is ignored; by convention, it should be of 138 // and |excluded_field| is ignored; by convention, it should be of
139 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at 139 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at
140 // least |minimal_fields_shown| fields, if possible. 140 // least |minimal_fields_shown| fields, if possible.
141 static void CreateInferredLabels( 141 static void CreateInferredLabels(
142 const std::vector<AutofillProfile*>* profiles, 142 const std::vector<AutofillProfile*>* profiles,
143 const std::vector<AutofillFieldType>* suggested_fields, 143 const std::vector<AutofillFieldType>* suggested_fields,
144 AutofillFieldType excluded_field, 144 AutofillFieldType excluded_field,
145 size_t minimal_fields_shown, 145 size_t minimal_fields_shown,
146 std::vector<string16>* created_labels); 146 std::vector<base::string16>* created_labels);
147 147
148 private: 148 private:
149 typedef std::vector<const FormGroup*> FormGroupList; 149 typedef std::vector<const FormGroup*> FormGroupList;
150 150
151 // FormGroup: 151 // FormGroup:
152 virtual bool FillCountrySelectControl(const std::string& app_locale, 152 virtual bool FillCountrySelectControl(const std::string& app_locale,
153 FormFieldData* field) const OVERRIDE; 153 FormFieldData* field) const OVERRIDE;
154 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE; 154 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
155 155
156 // Shared implementation for GetRawMultiInfo() and GetMultiInfo(). Pass an 156 // Shared implementation for GetRawMultiInfo() and GetMultiInfo(). Pass an
157 // empty |app_locale| to get the raw info; otherwise, the returned info is 157 // empty |app_locale| to get the raw info; otherwise, the returned info is
158 // canonicalized according to the given |app_locale|, if appropriate. 158 // canonicalized according to the given |app_locale|, if appropriate.
159 void GetMultiInfoImpl(AutofillFieldType type, 159 void GetMultiInfoImpl(AutofillFieldType type,
160 const std::string& app_locale, 160 const std::string& app_locale,
161 std::vector<string16>* values) const; 161 std::vector<base::string16>* values) const;
162 162
163 // Checks if the |phone| is in the |existing_phones| using fuzzy matching: 163 // Checks if the |phone| is in the |existing_phones| using fuzzy matching:
164 // for example, "1-800-FLOWERS", "18003569377", "(800)356-9377" and "356-9377" 164 // for example, "1-800-FLOWERS", "18003569377", "(800)356-9377" and "356-9377"
165 // are considered the same. 165 // are considered the same.
166 // Adds the |phone| to the |existing_phones| if not already there. 166 // Adds the |phone| to the |existing_phones| if not already there.
167 void AddPhoneIfUnique(const string16& phone, 167 void AddPhoneIfUnique(const base::string16& phone,
168 const std::string& app_locale, 168 const std::string& app_locale,
169 std::vector<string16>* existing_phones); 169 std::vector<base::string16>* existing_phones);
170 170
171 // Builds inferred label from the first |num_fields_to_include| non-empty 171 // Builds inferred label from the first |num_fields_to_include| non-empty
172 // fields in |label_fields|. Uses as many fields as possible if there are not 172 // fields in |label_fields|. Uses as many fields as possible if there are not
173 // enough non-empty fields. 173 // enough non-empty fields.
174 string16 ConstructInferredLabel( 174 base::string16 ConstructInferredLabel(
175 const std::vector<AutofillFieldType>& label_fields, 175 const std::vector<AutofillFieldType>& label_fields,
176 size_t num_fields_to_include) const; 176 size_t num_fields_to_include) const;
177 177
178 // Creates inferred labels for |profiles| at indices corresponding to 178 // Creates inferred labels for |profiles| at indices corresponding to
179 // |indices|, and stores the results to the corresponding elements of 179 // |indices|, and stores the results to the corresponding elements of
180 // |created_labels|. These labels include enough fields to differentiate among 180 // |created_labels|. These labels include enough fields to differentiate among
181 // the profiles, if possible; and also at least |num_fields_to_include| 181 // the profiles, if possible; and also at least |num_fields_to_include|
182 // fields, if possible. The label fields are drawn from |fields|. 182 // fields, if possible. The label fields are drawn from |fields|.
183 static void CreateDifferentiatingLabels( 183 static void CreateDifferentiatingLabels(
184 const std::vector<AutofillProfile*>& profiles, 184 const std::vector<AutofillProfile*>& profiles,
185 const std::list<size_t>& indices, 185 const std::list<size_t>& indices,
186 const std::vector<AutofillFieldType>& fields, 186 const std::vector<AutofillFieldType>& fields,
187 size_t num_fields_to_include, 187 size_t num_fields_to_include,
188 std::vector<string16>* created_labels); 188 std::vector<base::string16>* created_labels);
189 189
190 // Utilities for listing and lookup of the data members that constitute 190 // Utilities for listing and lookup of the data members that constitute
191 // user-visible profile information. 191 // user-visible profile information.
192 FormGroupList FormGroups() const; 192 FormGroupList FormGroups() const;
193 const FormGroup* FormGroupForType(AutofillFieldType type) const; 193 const FormGroup* FormGroupForType(AutofillFieldType type) const;
194 FormGroup* MutableFormGroupForType(AutofillFieldType type); 194 FormGroup* MutableFormGroupForType(AutofillFieldType type);
195 195
196 // The label presented to the user when selecting a profile. 196 // The label presented to the user when selecting a profile.
197 string16 label_; 197 base::string16 label_;
198 198
199 // The guid of this profile. 199 // The guid of this profile.
200 std::string guid_; 200 std::string guid_;
201 201
202 // Personal information for this profile. 202 // Personal information for this profile.
203 std::vector<NameInfo> name_; 203 std::vector<NameInfo> name_;
204 std::vector<EmailInfo> email_; 204 std::vector<EmailInfo> email_;
205 CompanyInfo company_; 205 CompanyInfo company_;
206 std::vector<PhoneNumber> home_number_; 206 std::vector<PhoneNumber> home_number_;
207 Address address_; 207 Address address_;
208 }; 208 };
209 209
210 // So we can compare AutofillProfiles with EXPECT_EQ(). 210 // So we can compare AutofillProfiles with EXPECT_EQ().
211 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); 211 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile);
212 212
213 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_ 213 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698