Chromium Code Reviews

Side by Side Diff: components/autofill/core/browser/address_field.cc

Issue 676983004: Autofill: Fix recognition of Walmart ZIP code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: retry upload Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/20_checkout_m_walmart.com.out ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/autofill/core/browser/address_field.h" 5 #include "components/autofill/core/browser/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"
(...skipping 178 matching lines...)
189 MATCH_DEFAULT | MATCH_SELECT, 189 MATCH_DEFAULT | MATCH_SELECT,
190 &country_); 190 &country_);
191 } 191 }
192 192
193 bool AddressField::ParseZipCode(AutofillScanner* scanner) { 193 bool AddressField::ParseZipCode(AutofillScanner* scanner) {
194 // Parse a zip code. On some UK pages (e.g. The China Shop2.html) this 194 // Parse a zip code. On some UK pages (e.g. The China Shop2.html) this
195 // is called a "post code". 195 // is called a "post code".
196 if (zip_) 196 if (zip_)
197 return false; 197 return false;
198 198
199 base::string16 pattern = UTF8ToUTF16(autofill::kZipCodeRe); 199 // Some sites use type="tel" for zip fields (to get a numerical input).
200 if (!ParseField(scanner, pattern, &zip_)) 200 // http://crbug.com/426958
Ilya Sherman 2014/10/24 20:28:13 Ouch.
Evan Stade 2014/10/24 20:32:16 It seems to be pretty prevalent on mobile sites. I
201 if (!ParseFieldSpecifics(scanner,
202 UTF8ToUTF16(autofill::kZipCodeRe),
203 MATCH_DEFAULT | MATCH_TELEPHONE,
204 &zip_)) {
201 return false; 205 return false;
206 }
202 207
203 // Look for a zip+4, whose field name will also often contain 208 // Look for a zip+4, whose field name will also often contain
204 // the substring "zip". 209 // the substring "zip".
205 ParseField(scanner, UTF8ToUTF16(autofill::kZip4Re), &zip4_); 210 ParseFieldSpecifics(scanner,
211 UTF8ToUTF16(autofill::kZip4Re),
212 MATCH_DEFAULT | MATCH_TELEPHONE,
213 &zip4_);
206 return true; 214 return true;
207 } 215 }
208 216
209 bool AddressField::ParseCity(AutofillScanner* scanner) { 217 bool AddressField::ParseCity(AutofillScanner* scanner) {
210 // Parse a city name. Some UK pages (e.g. The China Shop2.html) use 218 // Parse a city name. Some UK pages (e.g. The China Shop2.html) use
211 // the term "town". 219 // the term "town".
212 if (city_) 220 if (city_)
213 return false; 221 return false;
214 222
215 // Select fields are allowed here. This occurs on top-100 site rediff.com. 223 // Select fields are allowed here. This occurs on top-100 site rediff.com.
216 return ParseFieldSpecifics(scanner, 224 return ParseFieldSpecifics(scanner,
217 UTF8ToUTF16(autofill::kCityRe), 225 UTF8ToUTF16(autofill::kCityRe),
218 MATCH_DEFAULT | MATCH_SELECT, 226 MATCH_DEFAULT | MATCH_SELECT,
219 &city_); 227 &city_);
220 } 228 }
221 229
222 bool AddressField::ParseState(AutofillScanner* scanner) { 230 bool AddressField::ParseState(AutofillScanner* scanner) {
223 if (state_) 231 if (state_)
224 return false; 232 return false;
225 233
226 return ParseFieldSpecifics(scanner, 234 return ParseFieldSpecifics(scanner,
227 UTF8ToUTF16(autofill::kStateRe), 235 UTF8ToUTF16(autofill::kStateRe),
228 MATCH_DEFAULT | MATCH_SELECT, 236 MATCH_DEFAULT | MATCH_SELECT,
229 &state_); 237 &state_);
230 } 238 }
231 239
232 } // namespace autofill 240 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/20_checkout_m_walmart.com.out ('k') | no next file » | no next file with comments »

Powered by Google App Engine