OLD | NEW |
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...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Some sites use type="tel" for zip fields (to get a numerical input). | 199 base::string16 pattern = UTF8ToUTF16(autofill::kZipCodeRe); |
200 // http://crbug.com/426958 | 200 if (!ParseField(scanner, pattern, &zip_)) |
201 if (!ParseFieldSpecifics(scanner, | |
202 UTF8ToUTF16(autofill::kZipCodeRe), | |
203 MATCH_DEFAULT | MATCH_TELEPHONE, | |
204 &zip_)) { | |
205 return false; | 201 return false; |
206 } | |
207 | 202 |
208 // Look for a zip+4, whose field name will also often contain | 203 // Look for a zip+4, whose field name will also often contain |
209 // the substring "zip". | 204 // the substring "zip". |
210 ParseFieldSpecifics(scanner, | 205 ParseField(scanner, UTF8ToUTF16(autofill::kZip4Re), &zip4_); |
211 UTF8ToUTF16(autofill::kZip4Re), | |
212 MATCH_DEFAULT | MATCH_TELEPHONE, | |
213 &zip4_); | |
214 return true; | 206 return true; |
215 } | 207 } |
216 | 208 |
217 bool AddressField::ParseCity(AutofillScanner* scanner) { | 209 bool AddressField::ParseCity(AutofillScanner* scanner) { |
218 // Parse a city name. Some UK pages (e.g. The China Shop2.html) use | 210 // Parse a city name. Some UK pages (e.g. The China Shop2.html) use |
219 // the term "town". | 211 // the term "town". |
220 if (city_) | 212 if (city_) |
221 return false; | 213 return false; |
222 | 214 |
223 // Select fields are allowed here. This occurs on top-100 site rediff.com. | 215 // Select fields are allowed here. This occurs on top-100 site rediff.com. |
224 return ParseFieldSpecifics(scanner, | 216 return ParseFieldSpecifics(scanner, |
225 UTF8ToUTF16(autofill::kCityRe), | 217 UTF8ToUTF16(autofill::kCityRe), |
226 MATCH_DEFAULT | MATCH_SELECT, | 218 MATCH_DEFAULT | MATCH_SELECT, |
227 &city_); | 219 &city_); |
228 } | 220 } |
229 | 221 |
230 bool AddressField::ParseState(AutofillScanner* scanner) { | 222 bool AddressField::ParseState(AutofillScanner* scanner) { |
231 if (state_) | 223 if (state_) |
232 return false; | 224 return false; |
233 | 225 |
234 return ParseFieldSpecifics(scanner, | 226 return ParseFieldSpecifics(scanner, |
235 UTF8ToUTF16(autofill::kStateRe), | 227 UTF8ToUTF16(autofill::kStateRe), |
236 MATCH_DEFAULT | MATCH_SELECT, | 228 MATCH_DEFAULT | MATCH_SELECT, |
237 &state_); | 229 &state_); |
238 } | 230 } |
239 | 231 |
240 } // namespace autofill | 232 } // namespace autofill |
OLD | NEW |