| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |