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

Side by Side Diff: chrome/browser/autofill/address_field.cc

Issue 7043027: Autofill refactor form_field.h/cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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) 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 #include "chrome/browser/autofill/address_field.h" 5 #include "chrome/browser/autofill/address_field.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/autofill/autofill_ecml.h"
14 #include "chrome/browser/autofill/autofill_field.h" 15 #include "chrome/browser/autofill/autofill_field.h"
15 #include "chrome/browser/autofill/autofill_scanner.h" 16 #include "chrome/browser/autofill/autofill_scanner.h"
16 #include "grit/autofill_resources.h" 17 #include "grit/autofill_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 19
19 bool AddressField::GetFieldInfo(FieldTypeMap* field_type_map) const { 20 using autofill::GetEcmlPattern;
20 AutofillFieldType address_company;
21 AutofillFieldType address_line1;
22 AutofillFieldType address_line2;
23 AutofillFieldType address_city;
24 AutofillFieldType address_state;
25 AutofillFieldType address_zip;
26 AutofillFieldType address_country;
27
28 switch (type_) {
29 case kShippingAddress:
30 // Fall through. Autofill does not support shipping addresses.
31 case kGenericAddress:
32 address_company = COMPANY_NAME;
33 address_line1 = ADDRESS_HOME_LINE1;
34 address_line2 = ADDRESS_HOME_LINE2;
35 address_city = ADDRESS_HOME_CITY;
36 address_state = ADDRESS_HOME_STATE;
37 address_zip = ADDRESS_HOME_ZIP;
38 address_country = ADDRESS_HOME_COUNTRY;
39 break;
40
41 case kBillingAddress:
42 address_company = COMPANY_NAME;
43 address_line1 = ADDRESS_BILLING_LINE1;
44 address_line2 = ADDRESS_BILLING_LINE2;
45 address_city = ADDRESS_BILLING_CITY;
46 address_state = ADDRESS_BILLING_STATE;
47 address_zip = ADDRESS_BILLING_ZIP;
48 address_country = ADDRESS_BILLING_COUNTRY;
49 break;
50
51 default:
52 NOTREACHED();
53 return false;
54 }
55
56 bool ok = Add(field_type_map, company_, address_company);
57 ok = ok && Add(field_type_map, address1_, address_line1);
58 ok = ok && Add(field_type_map, address2_, address_line2);
59 ok = ok && Add(field_type_map, city_, address_city);
60 ok = ok && Add(field_type_map, state_, address_state);
61 ok = ok && Add(field_type_map, zip_, address_zip);
62 ok = ok && Add(field_type_map, country_, address_country);
63 return ok;
64 }
65 21
66 AddressField* AddressField::Parse(AutofillScanner* scanner, bool is_ecml) { 22 AddressField* AddressField::Parse(AutofillScanner* scanner, bool is_ecml) {
67 if (scanner->IsEnd()) 23 if (scanner->IsEnd())
68 return NULL; 24 return NULL;
69 25
70 scoped_ptr<AddressField> address_field(new AddressField); 26 scoped_ptr<AddressField> address_field(new AddressField);
71 const AutofillField* initial_field = scanner->Cursor(); 27 const AutofillField* initial_field = scanner->Cursor();
72 scanner->SaveCursor(); 28 scanner->SaveCursor();
73 29
74 string16 attention_ignored = 30 string16 attention_ignored =
75 l10n_util::GetStringUTF16(IDS_AUTOFILL_ATTENTION_IGNORED_RE); 31 l10n_util::GetStringUTF16(IDS_AUTOFILL_ATTENTION_IGNORED_RE);
76 string16 region_ignored = 32 string16 region_ignored =
77 l10n_util::GetStringUTF16(IDS_AUTOFILL_REGION_IGNORED_RE); 33 l10n_util::GetStringUTF16(IDS_AUTOFILL_REGION_IGNORED_RE);
78 34
79 // Allow address fields to appear in any order. 35 // Allow address fields to appear in any order.
80 while (!scanner->IsEnd()) { 36 while (!scanner->IsEnd()) {
81 if (ParseCompany(scanner, is_ecml, address_field.get()) || 37 if (ParseCompany(scanner, is_ecml, address_field.get()) ||
82 ParseAddressLines(scanner, is_ecml, address_field.get()) || 38 ParseAddressLines(scanner, is_ecml, address_field.get()) ||
83 ParseCity(scanner, is_ecml, address_field.get()) || 39 ParseCity(scanner, is_ecml, address_field.get()) ||
84 ParseState(scanner, is_ecml, address_field.get()) || 40 ParseState(scanner, is_ecml, address_field.get()) ||
85 ParseZipCode(scanner, is_ecml, address_field.get()) || 41 ParseZipCode(scanner, is_ecml, address_field.get()) ||
86 ParseCountry(scanner, is_ecml, address_field.get())) { 42 ParseCountry(scanner, is_ecml, address_field.get())) {
87 continue; 43 continue;
88 } else if (ParseText(scanner, attention_ignored) || 44 } else if (ParseField(scanner, attention_ignored, NULL) ||
89 ParseText(scanner, region_ignored)) { 45 ParseField(scanner, region_ignored, NULL)) {
90 // We ignore the following: 46 // We ignore the following:
91 // * Attention. 47 // * Attention.
92 // * Province/Region/Other. 48 // * Province/Region/Other.
93 continue; 49 continue;
94 } else if (scanner->Cursor() != initial_field && ParseEmpty(scanner)) { 50 } else if (scanner->Cursor() != initial_field &&
51 ParseEmptyLabel(scanner, NULL)) {
95 // Ignore non-labeled fields within an address; the page 52 // Ignore non-labeled fields within an address; the page
96 // MapQuest Driving Directions North America.html contains such a field. 53 // MapQuest Driving Directions North America.html contains such a field.
97 // We only ignore such fields after we've parsed at least one other field; 54 // We only ignore such fields after we've parsed at least one other field;
98 // otherwise we'd effectively parse address fields before other field 55 // otherwise we'd effectively parse address fields before other field
99 // types after any non-labeled fields, and we want email address fields to 56 // types after any non-labeled fields, and we want email address fields to
100 // have precedence since some pages contain fields labeled 57 // have precedence since some pages contain fields labeled
101 // "Email address". 58 // "Email address".
102 continue; 59 continue;
103 } else { 60 } else {
104 // No field found. 61 // No field found.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 address1_(NULL), 101 address1_(NULL),
145 address2_(NULL), 102 address2_(NULL),
146 city_(NULL), 103 city_(NULL),
147 state_(NULL), 104 state_(NULL),
148 zip_(NULL), 105 zip_(NULL),
149 zip4_(NULL), 106 zip4_(NULL),
150 country_(NULL), 107 country_(NULL),
151 type_(kGenericAddress) { 108 type_(kGenericAddress) {
152 } 109 }
153 110
111 bool AddressField::ClassifyField(FieldTypeMap* map) const {
112 AutofillFieldType address_company;
113 AutofillFieldType address_line1;
114 AutofillFieldType address_line2;
115 AutofillFieldType address_city;
116 AutofillFieldType address_state;
117 AutofillFieldType address_zip;
118 AutofillFieldType address_country;
119
120 switch (type_) {
121 case kShippingAddress:
122 // Fall through. Autofill does not support shipping addresses.
123 case kGenericAddress:
124 address_company = COMPANY_NAME;
125 address_line1 = ADDRESS_HOME_LINE1;
126 address_line2 = ADDRESS_HOME_LINE2;
127 address_city = ADDRESS_HOME_CITY;
128 address_state = ADDRESS_HOME_STATE;
129 address_zip = ADDRESS_HOME_ZIP;
130 address_country = ADDRESS_HOME_COUNTRY;
131 break;
132
133 case kBillingAddress:
134 address_company = COMPANY_NAME;
135 address_line1 = ADDRESS_BILLING_LINE1;
136 address_line2 = ADDRESS_BILLING_LINE2;
137 address_city = ADDRESS_BILLING_CITY;
138 address_state = ADDRESS_BILLING_STATE;
139 address_zip = ADDRESS_BILLING_ZIP;
140 address_country = ADDRESS_BILLING_COUNTRY;
141 break;
142
143 default:
144 NOTREACHED();
145 return false;
146 }
147
148 bool ok = AddClassification(company_, address_company, map);
149 ok = ok && AddClassification(address1_, address_line1, map);
150 ok = ok && AddClassification(address2_, address_line2, map);
151 ok = ok && AddClassification(city_, address_city, map);
152 ok = ok && AddClassification(state_, address_state, map);
153 ok = ok && AddClassification(zip_, address_zip, map);
154 ok = ok && AddClassification(country_, address_country, map);
155 return ok;
156 }
157
154 // static 158 // static
155 bool AddressField::ParseCompany(AutofillScanner* scanner, 159 bool AddressField::ParseCompany(AutofillScanner* scanner,
156 bool is_ecml, 160 bool is_ecml,
157 AddressField* address_field) { 161 AddressField* address_field) {
158 if (address_field->company_ && !address_field->company_->IsEmpty()) 162 if (address_field->company_ && !address_field->company_->IsEmpty())
159 return false; 163 return false;
160 164
161 string16 pattern; 165 string16 pattern;
162 if (is_ecml) { 166 if (is_ecml) {
163 pattern = GetEcmlPattern(kEcmlShipToCompanyName, 167 pattern = GetEcmlPattern(kEcmlShipToCompanyName,
164 kEcmlBillToCompanyName, '|'); 168 kEcmlBillToCompanyName, '|');
165 } else { 169 } else {
166 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_COMPANY_RE); 170 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_COMPANY_RE);
167 } 171 }
168 172
169 return ParseText(scanner, pattern, &address_field->company_); 173 return ParseField(scanner, pattern, &address_field->company_);
170 } 174 }
171 175
172 // static 176 // static
173 bool AddressField::ParseAddressLines(AutofillScanner* scanner, 177 bool AddressField::ParseAddressLines(AutofillScanner* scanner,
174 bool is_ecml, 178 bool is_ecml,
175 AddressField* address_field) { 179 AddressField* address_field) {
176 // We only match the string "address" in page text, not in element names, 180 // We only match the string "address" in page text, not in element names,
177 // because sometimes every element in a group of address fields will have 181 // because sometimes every element in a group of address fields will have
178 // a name containing the string "address"; for example, on the page 182 // a name containing the string "address"; for example, on the page
179 // Kohl's - Register Billing Address.html the text element labeled "city" 183 // Kohl's - Register Billing Address.html the text element labeled "city"
180 // has the name "BILL_TO_ADDRESS<>city". We do match address labels 184 // has the name "BILL_TO_ADDRESS<>city". We do match address labels
181 // such as "address1", which appear as element names on various pages (eg 185 // such as "address1", which appear as element names on various pages (eg
182 // AmericanGirl-Registration.html, BloomingdalesBilling.html, 186 // AmericanGirl-Registration.html, BloomingdalesBilling.html,
183 // EBay Registration Enter Information.html). 187 // EBay Registration Enter Information.html).
184 if (address_field->address1_) 188 if (address_field->address1_)
185 return false; 189 return false;
186 190
187 string16 pattern; 191 string16 pattern;
188 if (is_ecml) { 192 if (is_ecml) {
189 pattern = GetEcmlPattern(kEcmlShipToAddress1, kEcmlBillToAddress1, '|'); 193 pattern = GetEcmlPattern(kEcmlShipToAddress1, kEcmlBillToAddress1, '|');
190 if (!ParseText(scanner, pattern, &address_field->address1_)) 194 if (!ParseField(scanner, pattern, &address_field->address1_))
191 return false; 195 return false;
192 } else { 196 } else {
193 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_1_RE); 197 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_1_RE);
194 string16 label_pattern = 198 string16 label_pattern =
195 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_1_LABEL_RE); 199 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_1_LABEL_RE);
196 200
197 if (!ParseText(scanner, pattern, &address_field->address1_) && 201 if (!ParseField(scanner, pattern, &address_field->address1_) &&
198 !ParseLabelText(scanner, label_pattern, &address_field->address1_)) 202 !ParseFieldSpecifics(scanner, label_pattern, MATCH_LABEL,
203 &address_field->address1_)) {
199 return false; 204 return false;
205 }
200 } 206 }
201 207
202 // Optionally parse more address lines, which may have empty labels. 208 // Optionally parse more address lines, which may have empty labels.
203 // Some pages have 3 address lines (eg SharperImageModifyAccount.html) 209 // Some pages have 3 address lines (eg SharperImageModifyAccount.html)
204 // Some pages even have 4 address lines (e.g. uk/ShoesDirect2.html)! 210 // Some pages even have 4 address lines (e.g. uk/ShoesDirect2.html)!
205 if (is_ecml) { 211 if (is_ecml) {
206 pattern = GetEcmlPattern(kEcmlShipToAddress2, kEcmlBillToAddress2, '|'); 212 pattern = GetEcmlPattern(kEcmlShipToAddress2, kEcmlBillToAddress2, '|');
207 if (!ParseEmptyText(scanner, &address_field->address2_)) 213 if (!ParseEmptyLabel(scanner, &address_field->address2_))
208 ParseText(scanner, pattern, &address_field->address2_); 214 ParseField(scanner, pattern, &address_field->address2_);
209 } else { 215 } else {
210 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_2_RE); 216 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_2_RE);
211 string16 label_pattern = 217 string16 label_pattern =
212 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_1_LABEL_RE); 218 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_1_LABEL_RE);
213 if (!ParseEmptyText(scanner, &address_field->address2_) && 219 if (!ParseEmptyLabel(scanner, &address_field->address2_) &&
214 !ParseText(scanner, pattern, &address_field->address2_)) 220 !ParseField(scanner, pattern, &address_field->address2_)) {
215 ParseLabelText(scanner, label_pattern, &address_field->address2_); 221 ParseFieldSpecifics(scanner, label_pattern, MATCH_LABEL,
222 &address_field->address2_);
223 }
216 } 224 }
217 225
218 // Try for a third line, which we will promptly discard. 226 // Try for a third line, which we will promptly discard.
219 if (address_field->address2_ != NULL) { 227 if (address_field->address2_ != NULL) {
220 if (is_ecml) { 228 if (is_ecml) {
221 pattern = GetEcmlPattern(kEcmlShipToAddress3, kEcmlBillToAddress3, '|'); 229 pattern = GetEcmlPattern(kEcmlShipToAddress3, kEcmlBillToAddress3, '|');
222 ParseText(scanner, pattern); 230 ParseField(scanner, pattern, NULL);
223 } else { 231 } else {
224 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_3_RE); 232 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_3_RE);
225 if (!ParseEmptyText(scanner, NULL)) 233 if (!ParseEmptyLabel(scanner, NULL))
226 ParseText(scanner, pattern, NULL); 234 ParseField(scanner, pattern, NULL);
227 } 235 }
228 } 236 }
229 237
230 return true; 238 return true;
231 } 239 }
232 240
233 // static 241 // static
234 bool AddressField::ParseCountry(AutofillScanner* scanner, 242 bool AddressField::ParseCountry(AutofillScanner* scanner,
235 bool is_ecml, 243 bool is_ecml,
236 AddressField* address_field) { 244 AddressField* address_field) {
237 // Parse a country. The occasional page (e.g. 245 // Parse a country. The occasional page (e.g.
238 // Travelocity_New Member Information1.html) calls this a "location". 246 // Travelocity_New Member Information1.html) calls this a "location".
239 // Note: ECML standard uses 2 letter country code (ISO 3166) 247 // Note: ECML standard uses 2 letter country code (ISO 3166)
240 if (address_field->country_ && !address_field->country_->IsEmpty()) 248 if (address_field->country_ && !address_field->country_->IsEmpty())
241 return false; 249 return false;
242 250
243 string16 pattern; 251 string16 pattern;
244 if (is_ecml) 252 if (is_ecml)
245 pattern = GetEcmlPattern(kEcmlShipToCountry, kEcmlBillToCountry, '|'); 253 pattern = GetEcmlPattern(kEcmlShipToCountry, kEcmlBillToCountry, '|');
246 else 254 else
247 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_COUNTRY_RE); 255 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_COUNTRY_RE);
248 256
249 return ParseText(scanner, pattern, &address_field->country_); 257 return ParseField(scanner, pattern, &address_field->country_);
250 } 258 }
251 259
252 // static 260 // static
253 bool AddressField::ParseZipCode(AutofillScanner* scanner, 261 bool AddressField::ParseZipCode(AutofillScanner* scanner,
254 bool is_ecml, 262 bool is_ecml,
255 AddressField* address_field) { 263 AddressField* address_field) {
256 // Parse a zip code. On some UK pages (e.g. The China Shop2.html) this 264 // Parse a zip code. On some UK pages (e.g. The China Shop2.html) this
257 // is called a "post code". 265 // is called a "post code".
258 // 266 //
259 // HACK: Just for the MapQuest driving directions page we match the 267 // HACK: Just for the MapQuest driving directions page we match the
260 // exact name "1z", which MapQuest uses to label its zip code field. 268 // exact name "1z", which MapQuest uses to label its zip code field.
261 // Hopefully before long we'll be smart enough to find the zip code 269 // Hopefully before long we'll be smart enough to find the zip code
262 // on that page automatically. 270 // on that page automatically.
263 if (address_field->zip_) 271 if (address_field->zip_)
264 return false; 272 return false;
265 273
266 string16 pattern; 274 string16 pattern;
267 if (is_ecml) { 275 if (is_ecml) {
268 pattern = GetEcmlPattern(kEcmlShipToPostalCode, kEcmlBillToPostalCode, '|'); 276 pattern = GetEcmlPattern(kEcmlShipToPostalCode, kEcmlBillToPostalCode, '|');
269 } else { 277 } else {
270 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ZIP_CODE_RE); 278 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_ZIP_CODE_RE);
271 } 279 }
272 280
273 AddressType tempType; 281 AddressType tempType;
274 string16 name = scanner->Cursor()->name; 282 string16 name = scanner->Cursor()->name;
275 283
276 // Note: comparisons using the ecml compliant name as a prefix must be used in 284 // Note: comparisons using the ECML compliant name as a prefix must be used in
277 // order to accommodate Google Checkout. See FormFieldSet::GetEcmlPattern for 285 // order to accommodate Google Checkout. See |GetEcmlPattern| for more detail.
278 // more detail.
279 string16 bill_to_postal_code_field(ASCIIToUTF16(kEcmlBillToPostalCode)); 286 string16 bill_to_postal_code_field(ASCIIToUTF16(kEcmlBillToPostalCode));
280 if (StartsWith(name, bill_to_postal_code_field, false)) { 287 if (StartsWith(name, bill_to_postal_code_field, false)) {
281 tempType = kBillingAddress; 288 tempType = kBillingAddress;
282 } else if (StartsWith(name, bill_to_postal_code_field, false)) { 289 } else if (StartsWith(name, bill_to_postal_code_field, false)) {
283 tempType = kShippingAddress; 290 tempType = kShippingAddress;
284 } else { 291 } else {
285 tempType = kGenericAddress; 292 tempType = kGenericAddress;
286 } 293 }
287 294
288 if (!ParseText(scanner, pattern, &address_field->zip_)) 295 if (!ParseField(scanner, pattern, &address_field->zip_))
289 return false; 296 return false;
290 297
291 address_field->type_ = tempType; 298 address_field->type_ = tempType;
292 if (!is_ecml) { 299 if (!is_ecml) {
293 // Look for a zip+4, whose field name will also often contain 300 // Look for a zip+4, whose field name will also often contain
294 // the substring "zip". 301 // the substring "zip".
295 ParseText(scanner, 302 ParseField(scanner,
296 l10n_util::GetStringUTF16(IDS_AUTOFILL_ZIP_4_RE), 303 l10n_util::GetStringUTF16(IDS_AUTOFILL_ZIP_4_RE),
297 &address_field->zip4_); 304 &address_field->zip4_);
Ilya Sherman 2011/05/19 05:44:16 nit: indentation (probably other places with Parse
dhollowa 2011/05/19 17:53:08 Done.
298 } 305 }
299 306
300 return true; 307 return true;
301 } 308 }
302 309
303 // static 310 // static
304 bool AddressField::ParseCity(AutofillScanner* scanner, 311 bool AddressField::ParseCity(AutofillScanner* scanner,
305 bool is_ecml, 312 bool is_ecml,
306 AddressField* address_field) { 313 AddressField* address_field) {
307 // Parse a city name. Some UK pages (e.g. The China Shop2.html) use 314 // Parse a city name. Some UK pages (e.g. The China Shop2.html) use
308 // the term "town". 315 // the term "town".
309 if (address_field->city_) 316 if (address_field->city_)
310 return false; 317 return false;
311 318
312 string16 pattern; 319 string16 pattern;
313 if (is_ecml) 320 if (is_ecml)
314 pattern = GetEcmlPattern(kEcmlShipToCity, kEcmlBillToCity, '|'); 321 pattern = GetEcmlPattern(kEcmlShipToCity, kEcmlBillToCity, '|');
315 else 322 else
316 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_CITY_RE); 323 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_CITY_RE);
317 324
318 return ParseText(scanner, pattern, &address_field->city_); 325 return ParseField(scanner, pattern, &address_field->city_);
319 } 326 }
320 327
321 // static 328 // static
322 bool AddressField::ParseState(AutofillScanner* scanner, 329 bool AddressField::ParseState(AutofillScanner* scanner,
323 bool is_ecml, 330 bool is_ecml,
324 AddressField* address_field) { 331 AddressField* address_field) {
325 if (address_field->state_) 332 if (address_field->state_)
326 return false; 333 return false;
327 334
328 string16 pattern; 335 string16 pattern;
329 if (is_ecml) 336 if (is_ecml)
330 pattern = GetEcmlPattern(kEcmlShipToStateProv, kEcmlBillToStateProv, '|'); 337 pattern = GetEcmlPattern(kEcmlShipToStateProv, kEcmlBillToStateProv, '|');
331 else 338 else
332 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_STATE_RE); 339 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_STATE_RE);
333 340
334 return ParseText(scanner, pattern, &address_field->state_); 341 return ParseField(scanner, pattern, &address_field->state_);
335 } 342 }
336 343
337 AddressType AddressField::AddressTypeFromText(const string16 &text) { 344 AddressType AddressField::AddressTypeFromText(const string16 &text) {
338 if (text.find(l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_TYPE_SAME_AS_RE)) 345 if (text.find(l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_TYPE_SAME_AS_RE))
339 != string16::npos || 346 != string16::npos ||
340 text.find(l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_TYPE_USE_MY_RE)) 347 text.find(l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_TYPE_USE_MY_RE))
341 != string16::npos) 348 != string16::npos)
342 // This text could be a checkbox label such as "same as my billing 349 // This text could be a checkbox label such as "same as my billing
343 // address" or "use my shipping address". 350 // address" or "use my shipping address".
344 // ++ It would help if we generally skipped all text that appears 351 // ++ It would help if we generally skipped all text that appears
(...skipping 15 matching lines...) Expand all
360 return kBillingAddress; 367 return kBillingAddress;
361 368
362 if (bill == string16::npos && ship != string16::npos) 369 if (bill == string16::npos && ship != string16::npos)
363 return kShippingAddress; 370 return kShippingAddress;
364 371
365 if (bill > ship) 372 if (bill > ship)
366 return kBillingAddress; 373 return kBillingAddress;
367 374
368 return kShippingAddress; 375 return kShippingAddress;
369 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698