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

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

Issue 1797793003: Fix AddressField "lookup" fields ignore logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/139_bug_594475.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 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 size_t saved_cursor = scanner->SaveCursor(); 50 size_t saved_cursor = scanner->SaveCursor();
51 51
52 base::string16 attention_ignored = UTF8ToUTF16(kAttentionIgnoredRe); 52 base::string16 attention_ignored = UTF8ToUTF16(kAttentionIgnoredRe);
53 base::string16 region_ignored = UTF8ToUTF16(kRegionIgnoredRe); 53 base::string16 region_ignored = UTF8ToUTF16(kRegionIgnoredRe);
54 54
55 // Allow address fields to appear in any order. 55 // Allow address fields to appear in any order.
56 size_t begin_trailing_non_labeled_fields = 0; 56 size_t begin_trailing_non_labeled_fields = 0;
57 bool has_trailing_non_labeled_fields = false; 57 bool has_trailing_non_labeled_fields = false;
58 while (!scanner->IsEnd()) { 58 while (!scanner->IsEnd()) {
59 const size_t cursor = scanner->SaveCursor(); 59 const size_t cursor = scanner->SaveCursor();
60 if (address_field->ParseAddressLines(scanner) || 60 // Ignore "Address Lookup" field. http://crbug.com/427622
61 if (ParseField(scanner, base::UTF8ToUTF16(kAddressLookupRe), NULL)) {
62 continue;
63 } else if (address_field->ParseAddressLines(scanner) ||
61 address_field->ParseCityStateZipCode(scanner) || 64 address_field->ParseCityStateZipCode(scanner) ||
62 address_field->ParseCountry(scanner) || 65 address_field->ParseCountry(scanner) ||
63 address_field->ParseCompany(scanner)) { 66 address_field->ParseCompany(scanner)) {
64 has_trailing_non_labeled_fields = false; 67 has_trailing_non_labeled_fields = false;
65 continue; 68 continue;
66 } else if (ParseField(scanner, attention_ignored, NULL) || 69 } else if (ParseField(scanner, attention_ignored, NULL) ||
67 ParseField(scanner, region_ignored, NULL)) { 70 ParseField(scanner, region_ignored, NULL)) {
68 // We ignore the following: 71 // We ignore the following:
69 // * Attention. 72 // * Attention.
70 // * Province/Region/Other. 73 // * Province/Region/Other.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // because sometimes every element in a group of address fields will have 170 // because sometimes every element in a group of address fields will have
168 // a name containing the string "address"; for example, on the page 171 // a name containing the string "address"; for example, on the page
169 // Kohl's - Register Billing Address.html the text element labeled "city" 172 // Kohl's - Register Billing Address.html the text element labeled "city"
170 // has the name "BILL_TO_ADDRESS<>city". We do match address labels 173 // has the name "BILL_TO_ADDRESS<>city". We do match address labels
171 // such as "address1", which appear as element names on various pages (eg 174 // such as "address1", which appear as element names on various pages (eg
172 // AmericanGirl-Registration.html, BloomingdalesBilling.html, 175 // AmericanGirl-Registration.html, BloomingdalesBilling.html,
173 // EBay Registration Enter Information.html). 176 // EBay Registration Enter Information.html).
174 if (address1_ || street_address_) 177 if (address1_ || street_address_)
175 return false; 178 return false;
176 179
177 // Ignore "Address Lookup" field. http://crbug.com/427622
178 if (ParseField(scanner, base::UTF8ToUTF16(kAddressLookupRe), NULL))
179 return false;
180
181 base::string16 pattern = UTF8ToUTF16(kAddressLine1Re); 180 base::string16 pattern = UTF8ToUTF16(kAddressLine1Re);
182 base::string16 label_pattern = UTF8ToUTF16(kAddressLine1LabelRe); 181 base::string16 label_pattern = UTF8ToUTF16(kAddressLine1LabelRe);
183 if (!ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT, &address1_) && 182 if (!ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT, &address1_) &&
184 !ParseFieldSpecifics(scanner, label_pattern, MATCH_LABEL | MATCH_TEXT, 183 !ParseFieldSpecifics(scanner, label_pattern, MATCH_LABEL | MATCH_TEXT,
185 &address1_) && 184 &address1_) &&
186 !ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT | MATCH_TEXT_AREA, 185 !ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT | MATCH_TEXT_AREA,
187 &street_address_) && 186 &street_address_) &&
188 !ParseFieldSpecifics(scanner, label_pattern, 187 !ParseFieldSpecifics(scanner, label_pattern,
189 MATCH_LABEL | MATCH_TEXT_AREA, 188 MATCH_LABEL | MATCH_TEXT_AREA,
190 &street_address_)) 189 &street_address_))
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelForState( 412 AddressField::ParseNameLabelResult AddressField::ParseNameAndLabelForState(
414 AutofillScanner* scanner) { 413 AutofillScanner* scanner) {
415 if (state_) 414 if (state_)
416 return RESULT_MATCH_NONE; 415 return RESULT_MATCH_NONE;
417 416
418 return ParseNameAndLabelSeparately( 417 return ParseNameAndLabelSeparately(
419 scanner, UTF8ToUTF16(kStateRe), kStateMatchType, &state_); 418 scanner, UTF8ToUTF16(kStateRe), kStateMatchType, &state_);
420 } 419 }
421 420
422 } // namespace autofill 421 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/139_bug_594475.out ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698