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

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

Issue 796993002: Turn on cardholder/recipient name disambiguation by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/browser/about_flags.cc ('k') | components/autofill/core/common/autofill_switches.h » ('j') | 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/autofill_field.h" 5 #include "components/autofill/core/browser/autofill_field.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 24 matching lines...) Expand all
35 "Jan", "Feb", "Mar", "Apr", "May", "Jun", 35 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
36 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 36 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
37 }; 37 };
38 38
39 const char* const kMonthsFull[] = { 39 const char* const kMonthsFull[] = {
40 NULL, // Padding so index 1 = month 1 = January. 40 NULL, // Padding so index 1 = month 1 = January.
41 "January", "February", "March", "April", "May", "June", 41 "January", "February", "March", "April", "May", "June",
42 "July", "August", "September", "October", "November", "December", 42 "July", "August", "September", "October", "November", "December",
43 }; 43 };
44 44
45 bool ShouldDisambiguateServerNameTypes() {
46 std::string group_name =
47 base::FieldTrialList::FindFullName("DisambiguateAutofillServerNameTypes");
48
49 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
50 switches::kDisambiguateAutofillServerNameTypes)) {
51 return true;
52 }
53
54 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
55 switches::kTrustAutofillServerNameTypes)) {
56 return false;
57 }
58
59 return group_name == "Enabled";
60 }
61
62 // Returns true if the value was successfully set, meaning |value| was found in 45 // Returns true if the value was successfully set, meaning |value| was found in
63 // the list of select options in |field|. 46 // the list of select options in |field|.
64 bool SetSelectControlValue(const base::string16& value, 47 bool SetSelectControlValue(const base::string16& value,
65 FormFieldData* field) { 48 FormFieldData* field) {
66 base::string16 value_lowercase = base::StringToLowerASCII(value); 49 base::string16 value_lowercase = base::StringToLowerASCII(value);
67 50
68 DCHECK_EQ(field->option_values.size(), field->option_contents.size()); 51 DCHECK_EQ(field->option_values.size(), field->option_contents.size());
69 base::string16 best_match; 52 base::string16 best_match;
70 for (size_t i = 0; i < field->option_values.size(); ++i) { 53 for (size_t i = 0; i < field->option_values.size(); ++i) {
71 if (value == field->option_values[i] || 54 if (value == field->option_values[i] ||
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 phone_part_ = PHONE_SUFFIX; 450 phone_part_ = PHONE_SUFFIX;
468 else 451 else
469 phone_part_ = IGNORED; 452 phone_part_ = IGNORED;
470 } 453 }
471 454
472 AutofillType AutofillField::Type() const { 455 AutofillType AutofillField::Type() const {
473 if (html_type_ != HTML_TYPE_UNKNOWN) 456 if (html_type_ != HTML_TYPE_UNKNOWN)
474 return AutofillType(html_type_, html_mode_); 457 return AutofillType(html_type_, html_mode_);
475 458
476 if (server_type_ != NO_SERVER_DATA) { 459 if (server_type_ != NO_SERVER_DATA) {
477 bool believe_server = true; 460 // See http://crbug.com/429236 for background on why we might not always
478 if (ShouldDisambiguateServerNameTypes()) { 461 // believe the server.
479 believe_server = 462 // See http://crbug.com/441488 for potential improvements to the server
480 !(server_type_ == NAME_FULL && heuristic_type_ == CREDIT_CARD_NAME) && 463 // which may obviate the need for this logic.
481 !(server_type_ == CREDIT_CARD_NAME && heuristic_type_ == NAME_FULL); 464 bool believe_server =
482 } 465 !(server_type_ == NAME_FULL && heuristic_type_ == CREDIT_CARD_NAME) &&
466 !(server_type_ == CREDIT_CARD_NAME && heuristic_type_ == NAME_FULL);
483 if (believe_server) 467 if (believe_server)
484 return AutofillType(server_type_); 468 return AutofillType(server_type_);
485 } 469 }
486 470
487 return AutofillType(heuristic_type_); 471 return AutofillType(heuristic_type_);
488 } 472 }
489 473
490 bool AutofillField::IsEmpty() const { 474 bool AutofillField::IsEmpty() const {
491 return value.empty(); 475 return value.empty();
492 } 476 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 if (field.phone_part() == AutofillField::PHONE_SUFFIX || 535 if (field.phone_part() == AutofillField::PHONE_SUFFIX ||
552 field_data.max_length == PhoneNumber::kSuffixLength) { 536 field_data.max_length == PhoneNumber::kSuffixLength) {
553 return 537 return
554 number.substr(PhoneNumber::kSuffixOffset, PhoneNumber::kSuffixLength); 538 number.substr(PhoneNumber::kSuffixOffset, PhoneNumber::kSuffixLength);
555 } 539 }
556 540
557 return number; 541 return number;
558 } 542 }
559 543
560 } // namespace autofill 544 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | components/autofill/core/common/autofill_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698