| OLD | NEW |
| 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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 792 } |
| 793 } | 793 } |
| 794 | 794 |
| 795 void AutoFillManager::FillCreditCardFormField(const CreditCard* credit_card, | 795 void AutoFillManager::FillCreditCardFormField(const CreditCard* credit_card, |
| 796 AutoFillType type, | 796 AutoFillType type, |
| 797 webkit_glue::FormField* field) { | 797 webkit_glue::FormField* field) { |
| 798 DCHECK(credit_card); | 798 DCHECK(credit_card); |
| 799 DCHECK(type.group() == AutoFillType::CREDIT_CARD); | 799 DCHECK(type.group() == AutoFillType::CREDIT_CARD); |
| 800 DCHECK(field); | 800 DCHECK(field); |
| 801 | 801 |
| 802 if (field->form_control_type() == ASCIIToUTF16("select-one")) | 802 if (field->form_control_type() == ASCIIToUTF16("select-one")) { |
| 803 autofill::FillSelectControl(credit_card, type, field); | 803 autofill::FillSelectControl(credit_card, type, field); |
| 804 else | 804 } else if (field->form_control_type() == ASCIIToUTF16("month")) { |
| 805 // HTML5 input="month" consists of year-month. |
| 806 string16 year = credit_card->GetFieldText( |
| 807 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 808 string16 month = credit_card->GetFieldText( |
| 809 AutoFillType(CREDIT_CARD_EXP_MONTH)); |
| 810 if (!year.empty() && !month.empty()) { |
| 811 // Fill the value only if |credit_card| includes both year and month |
| 812 // information. |
| 813 field->set_value(year + ASCIIToUTF16("-") + month); |
| 814 } |
| 815 } else { |
| 805 field->set_value(credit_card->GetFieldText(type)); | 816 field->set_value(credit_card->GetFieldText(type)); |
| 817 } |
| 806 } | 818 } |
| 807 | 819 |
| 808 void AutoFillManager::FillFormField(const AutoFillProfile* profile, | 820 void AutoFillManager::FillFormField(const AutoFillProfile* profile, |
| 809 AutoFillType type, | 821 AutoFillType type, |
| 810 webkit_glue::FormField* field) { | 822 webkit_glue::FormField* field) { |
| 811 DCHECK(profile); | 823 DCHECK(profile); |
| 812 DCHECK(type.group() != AutoFillType::CREDIT_CARD); | 824 DCHECK(type.group() != AutoFillType::CREDIT_CARD); |
| 813 DCHECK(field); | 825 DCHECK(field); |
| 814 | 826 |
| 815 if (type.subgroup() == AutoFillType::PHONE_NUMBER) { | 827 if (type.subgroup() == AutoFillType::PHONE_NUMBER) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 return std::string(); | 933 return std::string(); |
| 922 | 934 |
| 923 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); | 935 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); |
| 924 if (iter == id_guid_map_.end()) { | 936 if (iter == id_guid_map_.end()) { |
| 925 NOTREACHED(); | 937 NOTREACHED(); |
| 926 return std::string(); | 938 return std::string(); |
| 927 } | 939 } |
| 928 | 940 |
| 929 return iter->second; | 941 return iter->second; |
| 930 } | 942 } |
| OLD | NEW |