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

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 5137004: Autofill: Prefer maxLength to size attribute for form filling heuristics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Denitting Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_manager_unittest.cc » ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/autofill/autofill_manager.h" 5 #include "chrome/browser/autofill/autofill_manager.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 598 }
599 599
600 void AutoFillManager::FillPhoneNumberField(const AutoFillProfile* profile, 600 void AutoFillManager::FillPhoneNumberField(const AutoFillProfile* profile,
601 webkit_glue::FormField* field) { 601 webkit_glue::FormField* field) {
602 // If we are filling a phone number, check to see if the size field 602 // If we are filling a phone number, check to see if the size field
603 // matches the "prefix" or "suffix" sizes and fill accordingly. 603 // matches the "prefix" or "suffix" sizes and fill accordingly.
604 string16 number = profile->GetFieldText(AutoFillType(PHONE_HOME_NUMBER)); 604 string16 number = profile->GetFieldText(AutoFillType(PHONE_HOME_NUMBER));
605 bool has_valid_suffix_and_prefix = (number.length() == 605 bool has_valid_suffix_and_prefix = (number.length() ==
606 (kAutoFillPhoneNumberPrefixCount + kAutoFillPhoneNumberSuffixCount)); 606 (kAutoFillPhoneNumberPrefixCount + kAutoFillPhoneNumberSuffixCount));
607 if (has_valid_suffix_and_prefix && 607 if (has_valid_suffix_and_prefix &&
608 field->size() == kAutoFillPhoneNumberPrefixCount) { 608 field->max_length() == kAutoFillPhoneNumberPrefixCount) {
609 number = number.substr(kAutoFillPhoneNumberPrefixOffset, 609 number = number.substr(kAutoFillPhoneNumberPrefixOffset,
610 kAutoFillPhoneNumberPrefixCount); 610 kAutoFillPhoneNumberPrefixCount);
611 field->set_value(number); 611 field->set_value(number);
612 } else if (has_valid_suffix_and_prefix && 612 } else if (has_valid_suffix_and_prefix &&
613 field->size() == kAutoFillPhoneNumberSuffixCount) { 613 field->max_length() == kAutoFillPhoneNumberSuffixCount) {
614 number = number.substr(kAutoFillPhoneNumberSuffixOffset, 614 number = number.substr(kAutoFillPhoneNumberSuffixOffset,
615 kAutoFillPhoneNumberSuffixCount); 615 kAutoFillPhoneNumberSuffixCount);
616 field->set_value(number); 616 field->set_value(number);
617 } else { 617 } else {
618 field->set_value(number); 618 field->set_value(number);
619 } 619 }
620 } 620 }
621 621
622 void AutoFillManager::ParseForms(const std::vector<FormData>& forms) { 622 void AutoFillManager::ParseForms(const std::vector<FormData>& forms) {
623 std::vector<FormStructure *> non_queryable_forms; 623 std::vector<FormStructure *> non_queryable_forms;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 return std::string(); 697 return std::string();
698 698
699 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); 699 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id);
700 if (iter == id_guid_map_.end()) { 700 if (iter == id_guid_map_.end()) {
701 NOTREACHED(); 701 NOTREACHED();
702 return std::string(); 702 return std::string();
703 } 703 }
704 704
705 return iter->second; 705 return iter->second;
706 } 706 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698