Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "components/autofill/browser/address_field.h" | 5 #include "components/autofill/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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 // Some pages have 3 address lines (eg SharperImageModifyAccount.html) | 220 // Some pages have 3 address lines (eg SharperImageModifyAccount.html) |
| 221 // Some pages even have 4 address lines (e.g. uk/ShoesDirect2.html)! | 221 // Some pages even have 4 address lines (e.g. uk/ShoesDirect2.html)! |
| 222 pattern = UTF8ToUTF16(autofill::kAddressLine2Re); | 222 pattern = UTF8ToUTF16(autofill::kAddressLine2Re); |
| 223 label_pattern = UTF8ToUTF16(autofill::kAddressLine2LabelRe); | 223 label_pattern = UTF8ToUTF16(autofill::kAddressLine2LabelRe); |
| 224 if (!ParseEmptyLabel(scanner, &address_field->address2_) && | 224 if (!ParseEmptyLabel(scanner, &address_field->address2_) && |
| 225 !ParseField(scanner, pattern, &address_field->address2_)) { | 225 !ParseField(scanner, pattern, &address_field->address2_)) { |
| 226 ParseFieldSpecifics(scanner, label_pattern, MATCH_LABEL | MATCH_TEXT, | 226 ParseFieldSpecifics(scanner, label_pattern, MATCH_LABEL | MATCH_TEXT, |
| 227 &address_field->address2_); | 227 &address_field->address2_); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Try for a third line, which we will promptly discard. | 230 // Try for surplus lines, which we will promptly discard. |
| 231 if (address_field->address2_ != NULL) { | 231 if (address_field->address2_ != NULL) { |
| 232 pattern = UTF8ToUTF16(autofill::kAddressLine3Re); | 232 do |
| 233 ParseField(scanner, pattern, NULL); | 233 pattern = UTF8ToUTF16(autofill::kAddressLinesExtraRe); |
| 234 while (ParseField(scanner, pattern, NULL)); | |
|
Ilya Sherman
2013/04/17 05:56:33
nit: Please write this as:
pattern = UTF8ToUTF16(
Jim Blackler
2013/04/18 13:49:22
Oh yeah it seems I didn't study that closely what
| |
| 234 } | 235 } |
| 235 | 236 |
| 236 return true; | 237 return true; |
| 237 } | 238 } |
| 238 | 239 |
| 239 // static | 240 // static |
| 240 bool AddressField::ParseCountry(AutofillScanner* scanner, | 241 bool AddressField::ParseCountry(AutofillScanner* scanner, |
| 241 AddressField* address_field) { | 242 AddressField* address_field) { |
| 242 // Parse a country. The occasional page (e.g. | 243 // Parse a country. The occasional page (e.g. |
| 243 // Travelocity_New Member Information1.html) calls this a "location". | 244 // Travelocity_New Member Information1.html) calls this a "location". |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 if (bill == base::string16::npos && ship != base::string16::npos) | 331 if (bill == base::string16::npos && ship != base::string16::npos) |
| 331 return kShippingAddress; | 332 return kShippingAddress; |
| 332 | 333 |
| 333 if (bill > ship) | 334 if (bill > ship) |
| 334 return kBillingAddress; | 335 return kBillingAddress; |
| 335 | 336 |
| 336 return kShippingAddress; | 337 return kShippingAddress; |
| 337 } | 338 } |
| 338 | 339 |
| 339 } // namespace autofill | 340 } // namespace autofill |
| OLD | NEW |