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

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

Issue 6033010: Support autocompletion for HTMl5 tags:"email", "month" and "tel". (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix format errors and change to use toWebInputElement(). Created 9 years, 11 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 | Annotate | Revision Log
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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 } 763 }
764 } 764 }
765 765
766 void AutoFillManager::FillCreditCardFormField(const CreditCard* credit_card, 766 void AutoFillManager::FillCreditCardFormField(const CreditCard* credit_card,
767 AutoFillType type, 767 AutoFillType type,
768 webkit_glue::FormField* field) { 768 webkit_glue::FormField* field) {
769 DCHECK(credit_card); 769 DCHECK(credit_card);
770 DCHECK(type.group() == AutoFillType::CREDIT_CARD); 770 DCHECK(type.group() == AutoFillType::CREDIT_CARD);
771 DCHECK(field); 771 DCHECK(field);
772 772
773 if (field->form_control_type() == ASCIIToUTF16("select-one")) 773 if (field->form_control_type() == ASCIIToUTF16("select-one")) {
774 autofill::FillSelectControl(credit_card, type, field); 774 autofill::FillSelectControl(credit_card, type, field);
775 else 775 } else if (field->form_control_type() == ASCIIToUTF16("month")) {
776 // HTML5 input="month" consists of year-month.
777 string16 year = credit_card->GetFieldText(
778 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR));
779 string16 month = credit_card->GetFieldText(
780 AutoFillType(CREDIT_CARD_EXP_MONTH));
781 if (!year.empty() && !month.empty()) {
782 // Fill the value only if |credit_card| includes both year and month
783 // information.
784 field->set_value(year + ASCIIToUTF16("-") + month);
785 }
786 } else {
776 field->set_value(credit_card->GetFieldText(type)); 787 field->set_value(credit_card->GetFieldText(type));
788 }
777 } 789 }
778 790
779 void AutoFillManager::FillFormField(const AutoFillProfile* profile, 791 void AutoFillManager::FillFormField(const AutoFillProfile* profile,
780 AutoFillType type, 792 AutoFillType type,
781 webkit_glue::FormField* field) { 793 webkit_glue::FormField* field) {
782 DCHECK(profile); 794 DCHECK(profile);
783 DCHECK(type.group() != AutoFillType::CREDIT_CARD); 795 DCHECK(type.group() != AutoFillType::CREDIT_CARD);
784 DCHECK(field); 796 DCHECK(field);
785 797
786 if (type.subgroup() == AutoFillType::PHONE_NUMBER) { 798 if (type.subgroup() == AutoFillType::PHONE_NUMBER) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 return std::string(); 904 return std::string();
893 905
894 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); 906 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id);
895 if (iter == id_guid_map_.end()) { 907 if (iter == id_guid_map_.end()) {
896 NOTREACHED(); 908 NOTREACHED();
897 return std::string(); 909 return std::string();
898 } 910 }
899 911
900 return iter->second; 912 return iter->second;
901 } 913 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698