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 <set> | 8 #include <set> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 679 } |
680 } | 680 } |
681 | 681 |
682 void AutoFillManager::FillCreditCardFormField(const CreditCard* credit_card, | 682 void AutoFillManager::FillCreditCardFormField(const CreditCard* credit_card, |
683 AutoFillType type, | 683 AutoFillType type, |
684 webkit_glue::FormField* field) { | 684 webkit_glue::FormField* field) { |
685 DCHECK(credit_card); | 685 DCHECK(credit_card); |
686 DCHECK(type.group() == AutoFillType::CREDIT_CARD); | 686 DCHECK(type.group() == AutoFillType::CREDIT_CARD); |
687 DCHECK(field); | 687 DCHECK(field); |
688 | 688 |
689 if (field->form_control_type() == ASCIIToUTF16("select-one")) | 689 if (field->form_control_type() == ASCIIToUTF16("select-one")) { |
690 autofill::FillSelectControl(credit_card, type, field); | 690 autofill::FillSelectControl(credit_card, type, field); |
691 else | 691 } else if (field->form_control_type() == ASCIIToUTF16("month")) { |
| 692 // HTML5 input="month" consists of year-month. |
| 693 string16 year = credit_card->GetFieldText( |
| 694 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 695 string16 month = credit_card->GetFieldText( |
| 696 AutoFillType(CREDIT_CARD_EXP_MONTH)); |
| 697 if (!year.empty() && !month.empty()) { |
| 698 // Iff |credit_card| has both year and month, fill the value. |
| 699 // Because |credit_card| might not have both info. |
| 700 month = year + ASCIIToUTF16("-") + month; |
| 701 field->set_value(month); |
| 702 } |
| 703 } else { |
692 field->set_value(credit_card->GetFieldText(type)); | 704 field->set_value(credit_card->GetFieldText(type)); |
| 705 } |
693 } | 706 } |
694 | 707 |
695 void AutoFillManager::FillFormField(const AutoFillProfile* profile, | 708 void AutoFillManager::FillFormField(const AutoFillProfile* profile, |
696 AutoFillType type, | 709 AutoFillType type, |
697 webkit_glue::FormField* field) { | 710 webkit_glue::FormField* field) { |
698 DCHECK(profile); | 711 DCHECK(profile); |
699 DCHECK(type.group() != AutoFillType::CREDIT_CARD); | 712 DCHECK(type.group() != AutoFillType::CREDIT_CARD); |
700 DCHECK(field); | 713 DCHECK(field); |
701 | 714 |
702 if (type.subgroup() == AutoFillType::PHONE_NUMBER) { | 715 if (type.subgroup() == AutoFillType::PHONE_NUMBER) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 return std::string(); | 823 return std::string(); |
811 | 824 |
812 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); | 825 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); |
813 if (iter == id_guid_map_.end()) { | 826 if (iter == id_guid_map_.end()) { |
814 NOTREACHED(); | 827 NOTREACHED(); |
815 return std::string(); | 828 return std::string(); |
816 } | 829 } |
817 | 830 |
818 return iter->second; | 831 return iter->second; |
819 } | 832 } |
OLD | NEW |