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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 145553009: rAc: use libaddressinput to validate international addresses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "apps/shell_window.h" 11 #include "apps/shell_window.h"
12 #include "apps/shell_window_registry.h" 12 #include "apps/shell_window_registry.h"
13 #include "apps/ui/native_app_window.h" 13 #include "apps/ui/native_app_window.h"
14 #include "base/base64.h" 14 #include "base/base64.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/i18n/case_conversion.h" 16 #include "base/i18n/case_conversion.h"
17 #include "base/i18n/rtl.h" 17 #include "base/i18n/rtl.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/prefs/pref_registry_simple.h" 19 #include "base/prefs/pref_registry_simple.h"
20 #include "base/prefs/pref_service.h" 20 #include "base/prefs/pref_service.h"
21 #include "base/prefs/scoped_user_pref_update.h" 21 #include "base/prefs/scoped_user_pref_update.h"
22 #include "base/rand_util.h" 22 #include "base/rand_util.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "chrome/browser/autofill/address_storage_factory.h"
28 #include "chrome/browser/autofill/personal_data_manager_factory.h" 29 #include "chrome/browser/autofill/personal_data_manager_factory.h"
29 #include "chrome/browser/browser_process.h" 30 #include "chrome/browser/browser_process.h"
30 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" 32 #include "chrome/browser/ui/autofill/autofill_dialog_common.h"
32 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" 33 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
33 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 34 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
34 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 35 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
35 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" 36 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
36 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" 37 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h"
37 #include "chrome/browser/ui/browser.h" 38 #include "chrome/browser/ui/browser.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "content/public/browser/web_contents.h" 73 #include "content/public/browser/web_contents.h"
73 #include "content/public/browser/web_contents_view.h" 74 #include "content/public/browser/web_contents_view.h"
74 #include "content/public/common/url_constants.h" 75 #include "content/public/common/url_constants.h"
75 #include "grit/chromium_strings.h" 76 #include "grit/chromium_strings.h"
76 #include "grit/component_strings.h" 77 #include "grit/component_strings.h"
77 #include "grit/generated_resources.h" 78 #include "grit/generated_resources.h"
78 #include "grit/platform_locale_settings.h" 79 #include "grit/platform_locale_settings.h"
79 #include "grit/theme_resources.h" 80 #include "grit/theme_resources.h"
80 #include "grit/webkit_resources.h" 81 #include "grit/webkit_resources.h"
81 #include "net/cert/cert_status_flags.h" 82 #include "net/cert/cert_status_flags.h"
83 #include "third_party/libaddressinput/chromium/chrome_downloader_impl.h"
84 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h"
85 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_data.h"
86 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_problem.h"
82 #include "ui/base/base_window.h" 87 #include "ui/base/base_window.h"
83 #include "ui/base/l10n/l10n_util.h" 88 #include "ui/base/l10n/l10n_util.h"
84 #include "ui/base/models/combobox_model.h" 89 #include "ui/base/models/combobox_model.h"
85 #include "ui/base/resource/resource_bundle.h" 90 #include "ui/base/resource/resource_bundle.h"
86 #include "ui/events/event.h" 91 #include "ui/events/event.h"
87 #include "ui/gfx/canvas.h" 92 #include "ui/gfx/canvas.h"
88 #include "ui/gfx/image/image_skia_operations.h" 93 #include "ui/gfx/image/image_skia_operations.h"
89 #include "ui/gfx/skia_util.h" 94 #include "ui/gfx/skia_util.h"
90 95
96 using ::i18n::addressinput::AddressData;
97 using ::i18n::addressinput::AddressProblem;
98 using ::i18n::addressinput::AddressProblemFilter;
99 using ::i18n::addressinput::AddressProblems;
100 using ::i18n::addressinput::AddressValidator;
101
91 namespace autofill { 102 namespace autofill {
92 103
93 namespace { 104 namespace {
94 105
95 const char kAddNewItemKey[] = "add-new-item"; 106 const char kAddNewItemKey[] = "add-new-item";
96 const char kManageItemsKey[] = "manage-items"; 107 const char kManageItemsKey[] = "manage-items";
97 const char kSameAsBillingKey[] = "same-as-billing"; 108 const char kSameAsBillingKey[] = "same-as-billing";
98 109
99 // URLs for Wallet error messages. 110 // URLs for Wallet error messages.
100 const char kBuyerLegalAddressStatusUrl[] = 111 const char kBuyerLegalAddressStatusUrl[] =
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 484 }
474 485
475 gfx::Image CvcIconForCreditCardType(const base::string16& credit_card_type) { 486 gfx::Image CvcIconForCreditCardType(const base::string16& credit_card_type) {
476 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 487 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
477 if (credit_card_type == l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX)) 488 if (credit_card_type == l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX))
478 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT_AMEX); 489 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT_AMEX);
479 490
480 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT); 491 return rb.GetImageNamed(IDR_CREDIT_CARD_CVC_HINT);
481 } 492 }
482 493
483 ServerFieldType CountryTypeForSection(DialogSection section) { 494 ServerFieldType TypeForSection(DialogSection section, ServerFieldType type) {
484 return section == SECTION_SHIPPING ? ADDRESS_HOME_COUNTRY : 495 return section == SECTION_SHIPPING ?
485 ADDRESS_BILLING_COUNTRY; 496 AutofillType(type).GetStorableType() :
497 AutofillType::GetEquivalentBillingFieldType(type);
486 } 498 }
487 499
488 } // namespace 500 } // namespace
489 501
490 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {} 502 AutofillDialogViewDelegate::~AutofillDialogViewDelegate() {}
491 503
492 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { 504 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() {
493 if (popup_controller_) 505 if (popup_controller_)
494 popup_controller_->Hide(); 506 popup_controller_->Hide();
495 507
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 // If the chosen item in |model| yields an empty suggestion text, it is 1112 // If the chosen item in |model| yields an empty suggestion text, it is
1101 // invalid. In this case, show the edit UI and highlight invalid fields. 1113 // invalid. In this case, show the edit UI and highlight invalid fields.
1102 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); 1114 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
1103 base::string16 unused, unused2; 1115 base::string16 unused, unused2;
1104 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) && 1116 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) &&
1105 !SuggestionTextForSection(section, &unused, &unused2)) { 1117 !SuggestionTextForSection(section, &unused, &unused2)) {
1106 SetEditingExistingData(section, true); 1118 SetEditingExistingData(section, true);
1107 } 1119 }
1108 1120
1109 if (wrapper && IsEditingExistingData(section)) { 1121 if (wrapper && IsEditingExistingData(section)) {
1110 base::string16 country = 1122 base::string16 country = wrapper->GetInfo(AutofillType(
1111 wrapper->GetInfo(AutofillType(CountryTypeForSection(section))); 1123 TypeForSection(section, ADDRESS_HOME_COUNTRY)));
1112 if (!country.empty()) { 1124 if (!country.empty()) {
1113 // There's no user input to restore here as this is only called after 1125 // There's no user input to restore here as this is only called after
1114 // resetting all section input. 1126 // resetting all section input.
1115 if (RebuildInputsForCountry(section, country, false)) 1127 if (RebuildInputsForCountry(section, country, false))
1116 UpdateSection(section); 1128 UpdateSection(section);
1117 } 1129 }
1118 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); 1130 wrapper->FillInputs(MutableRequestedFieldsForSection(section));
1119 } 1131 }
1120 } 1132 }
1121 1133
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 case ADDRESS_HOME_LINE2: 1705 case ADDRESS_HOME_LINE2:
1694 case ADDRESS_HOME_DEPENDENT_LOCALITY: 1706 case ADDRESS_HOME_DEPENDENT_LOCALITY:
1695 case ADDRESS_HOME_SORTING_CODE: 1707 case ADDRESS_HOME_SORTING_CODE:
1696 return base::string16(); // Optional until we have better validation. 1708 return base::string16(); // Optional until we have better validation.
1697 1709
1698 case ADDRESS_HOME_CITY: 1710 case ADDRESS_HOME_CITY:
1699 case ADDRESS_HOME_COUNTRY: 1711 case ADDRESS_HOME_COUNTRY:
1700 break; 1712 break;
1701 1713
1702 case ADDRESS_HOME_STATE: 1714 case ADDRESS_HOME_STATE:
1703 if (!value.empty() && !autofill::IsValidState(value) && 1715 if (!i18ninput::Enabled() && !value.empty() &&
1716 !autofill::IsValidState(value) &&
1704 CountryCodeForSection(section) == "US") { 1717 CountryCodeForSection(section) == "US") {
1705 return l10n_util::GetStringUTF16( 1718 return l10n_util::GetStringUTF16(
1706 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION); 1719 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION);
1707 } 1720 }
1708 break; 1721 break;
1709 1722
1710 case ADDRESS_HOME_ZIP: 1723 case ADDRESS_HOME_ZIP:
1711 if (!value.empty() && !autofill::IsValidZip(value) && 1724 if (!i18ninput::Enabled() && !value.empty() &&
Evan Stade 2014/01/28 19:23:12 I feel like all the address stuff should be remove
Dan Beam 2014/01/30 04:51:36 why not just remove when we axe the flag?
Evan Stade 2014/01/30 04:58:20 because then the behavior will be wrong until we a
Dan Beam 2014/01/30 06:28:58 Done.
1725 !autofill::IsValidZip(value) &&
1712 CountryCodeForSection(section) == "US") { 1726 CountryCodeForSection(section) == "US") {
1713 return l10n_util::GetStringUTF16( 1727 return l10n_util::GetStringUTF16(
1714 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE); 1728 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE);
1715 } 1729 }
1716 break; 1730 break;
1717 1731
1718 case NAME_FULL: 1732 case NAME_FULL:
1719 // Wallet requires a first and last billing name. 1733 // Wallet requires a first and last billing name.
1720 if (section == SECTION_CC_BILLING && !value.empty() && 1734 if (section == SECTION_CC_BILLING && !value.empty() &&
1721 !IsCardHolderNameValidForWallet(value)) { 1735 !IsCardHolderNameValidForWallet(value)) {
(...skipping 18 matching lines...) Expand all
1740 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) : 1754 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) :
1741 base::string16(); 1755 base::string16();
1742 } 1756 }
1743 1757
1744 // TODO(groby): Also add tests. 1758 // TODO(groby): Also add tests.
1745 ValidityMessages AutofillDialogControllerImpl::InputsAreValid( 1759 ValidityMessages AutofillDialogControllerImpl::InputsAreValid(
1746 DialogSection section, 1760 DialogSection section,
1747 const FieldValueMap& inputs) { 1761 const FieldValueMap& inputs) {
1748 ValidityMessages messages; 1762 ValidityMessages messages;
1749 FieldValueMap field_values; 1763 FieldValueMap field_values;
1764
1765 if (section != SECTION_CC) {
1766 FieldValueMap values = inputs;
Evan Stade 2014/01/28 19:23:12 why do you need to make this copy?
Dan Beam 2014/01/30 04:51:36 was to create empty base::string16() by non-const
1767
1768 AddressData address_data;
1769 address_data.language_code = g_browser_process->GetApplicationLocale();
1770 address_data.country_code = AutofillCountry::GetCountryCode(
1771 values[TypeForSection(section, ADDRESS_HOME_COUNTRY)],
1772 g_browser_process->GetApplicationLocale());
1773 address_data.administrative_area = UTF16ToUTF8(
Evan Stade 2014/01/28 19:23:12 DataModelWrapper already has code that creates an
Dan Beam 2014/01/30 04:51:36 Done.
1774 values[TypeForSection(section, ADDRESS_HOME_STATE)]);
1775 address_data.locality = UTF16ToUTF8(
1776 values[TypeForSection(section, ADDRESS_HOME_CITY)]);
1777 address_data.dependent_locality = UTF16ToUTF8(
1778 values[TypeForSection(section, ADDRESS_HOME_DEPENDENT_LOCALITY)]);
1779 address_data.sorting_code = UTF16ToUTF8(
1780 values[TypeForSection(section, ADDRESS_HOME_SORTING_CODE)]);
1781 address_data.postal_code = UTF16ToUTF8(
1782 values[TypeForSection(section, ADDRESS_HOME_ZIP)]);
1783 address_data.recipient = UTF16ToUTF8(
1784 values[TypeForSection(section, NAME_FULL)]);
1785
1786 base::string16 street_line1 =
1787 values[TypeForSection(section, ADDRESS_HOME_LINE1)];
1788 if (!street_line1.empty())
1789 address_data.address_lines.push_back(UTF16ToUTF8(street_line1));
1790
1791 base::string16 street_line2 =
1792 values[TypeForSection(section, ADDRESS_HOME_LINE2)];
1793 if (!street_line2.empty())
1794 address_data.address_lines.push_back(UTF16ToUTF8(street_line2));
1795
1796 AddressProblems problems;
1797 AddressValidator::Status status = validator_->ValidateAddress(
1798 address_data, AddressProblemFilter(), &problems);
1799 if (status == AddressValidator::SUCCESS) {
1800 common::AddressType address_type = section == SECTION_SHIPPING ?
1801 common::ADDRESS_TYPE_SHIPPING : common::ADDRESS_TYPE_BILLING;
1802 for (size_t i = 0; i < problems.size(); ++i) {
1803 const AddressProblem& problem = problems[i];
1804 bool sure = problem.type != AddressProblem::MISSING_REQUIRED_FIELD;
1805 base::string16 text = l10n_util::GetStringUTF16(problem.description_id);
1806 messages.Set(i18ninput::TypeForField(problem.field, address_type),
1807 ValidityMessage(text, sure));
1808 }
1809 }
1810 }
1811
1750 for (FieldValueMap::const_iterator iter = inputs.begin(); 1812 for (FieldValueMap::const_iterator iter = inputs.begin();
1751 iter != inputs.end(); ++iter) { 1813 iter != inputs.end(); ++iter) {
1752 const ServerFieldType type = iter->first; 1814 const ServerFieldType type = iter->first;
1815 if (messages.HasSureError(type))
1816 continue;
1753 1817
1754 base::string16 text = InputValidityMessage(section, type, iter->second); 1818 base::string16 text = InputValidityMessage(section, type, iter->second);
1755 1819
1756 // Skip empty/unchanged fields in edit mode. Ignore country as it always has 1820 // Skip empty/unchanged fields in edit mode. Ignore country as it always has
1757 // a value. If the individual field does not have validation errors, assume 1821 // a value. If the individual field does not have validation errors, assume
1758 // it to be valid unless later proven otherwise. 1822 // it to be valid unless later proven otherwise.
1759 bool sure = InputWasEdited(type, iter->second) || 1823 bool sure = InputWasEdited(type, iter->second) ||
1760 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY; 1824 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY;
1761 1825
1762 // Consider only individually valid fields for inter-field validation. 1826 // Consider only individually valid fields for inter-field validation.
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 handling_use_wallet_link_click_(false), 2637 handling_use_wallet_link_click_(false),
2574 passive_failed_(false), 2638 passive_failed_(false),
2575 billing_country_combobox_model_(*GetManager()), 2639 billing_country_combobox_model_(*GetManager()),
2576 shipping_country_combobox_model_(*GetManager()), 2640 shipping_country_combobox_model_(*GetManager()),
2577 suggested_cc_(this), 2641 suggested_cc_(this),
2578 suggested_billing_(this), 2642 suggested_billing_(this),
2579 suggested_cc_billing_(this), 2643 suggested_cc_billing_(this),
2580 suggested_shipping_(this), 2644 suggested_shipping_(this),
2581 cares_about_shipping_(true), 2645 cares_about_shipping_(true),
2582 popup_input_type_(UNKNOWN_TYPE), 2646 popup_input_type_(UNKNOWN_TYPE),
2583 weak_ptr_factory_(this),
2584 waiting_for_explicit_sign_in_response_(false), 2647 waiting_for_explicit_sign_in_response_(false),
2585 has_accepted_legal_documents_(false), 2648 has_accepted_legal_documents_(false),
2586 is_submitting_(false), 2649 is_submitting_(false),
2587 choose_another_instrument_or_address_(false), 2650 choose_another_instrument_or_address_(false),
2588 wallet_server_validation_recoverable_(true), 2651 wallet_server_validation_recoverable_(true),
2589 data_was_passed_back_(false), 2652 data_was_passed_back_(false),
2590 was_ui_latency_logged_(false), 2653 was_ui_latency_logged_(false),
2591 card_generated_animation_(2000, 60, this) { 2654 card_generated_animation_(2000, 60, this),
2655 weak_ptr_factory_(this) {
2592 // TODO(estade): remove duplicates from |form_structure|? 2656 // TODO(estade): remove duplicates from |form_structure|?
2593 DCHECK(!callback_.is_null()); 2657 DCHECK(!callback_.is_null());
2658
2659 scoped_ptr< ::i18n::addressinput::Downloader> downloader(
Evan Stade 2014/01/28 19:25:09 move this all to show
Dan Beam 2014/01/30 04:51:36 Done.
2660 new autofill::ChromeDownloaderImpl(profile_->GetRequestContext()));
2661 validator_ = AddressValidator::Build(
2662 downloader.Pass(), AddressStorageFactory::CreateStorage(), this);
2663 validator_->LoadRules(GetManager()->GetDefaultCountryCodeForNewAddress());
2594 } 2664 }
2595 2665
2596 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { 2666 AutofillDialogView* AutofillDialogControllerImpl::CreateView() {
2597 return AutofillDialogView::Create(this); 2667 return AutofillDialogView::Create(this);
2598 } 2668 }
2599 2669
2600 PersonalDataManager* AutofillDialogControllerImpl::GetManager() const { 2670 PersonalDataManager* AutofillDialogControllerImpl::GetManager() const {
2601 return PersonalDataManagerFactory::GetForProfile(profile_); 2671 return PersonalDataManagerFactory::GetForProfile(profile_);
2602 } 2672 }
2603 2673
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( 3138 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
3069 DialogSection section) { 3139 DialogSection section) {
3070 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); 3140 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section));
3071 } 3141 }
3072 3142
3073 std::string AutofillDialogControllerImpl::CountryCodeForSection( 3143 std::string AutofillDialogControllerImpl::CountryCodeForSection(
3074 DialogSection section) { 3144 DialogSection section) {
3075 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); 3145 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
3076 if (wrapper) { 3146 if (wrapper) {
3077 return AutofillCountry::GetCountryCode( 3147 return AutofillCountry::GetCountryCode(
3078 wrapper->GetInfo(AutofillType(CountryTypeForSection(section))), 3148 wrapper->GetInfo(
3149 AutofillType(TypeForSection(section, ADDRESS_HOME_COUNTRY))),
3079 g_browser_process->GetApplicationLocale()); 3150 g_browser_process->GetApplicationLocale());
3080 } 3151 }
3081 3152
3082 CountryComboboxModel* model = CountryComboboxModelForSection(section); 3153 CountryComboboxModel* model = CountryComboboxModelForSection(section);
3083 return model ? model->GetDefaultCountryCode() : std::string(); 3154 return model ? model->GetDefaultCountryCode() : std::string();
3084 } 3155 }
3085 3156
3086 bool AutofillDialogControllerImpl::RebuildInputsForCountry( 3157 bool AutofillDialogControllerImpl::RebuildInputsForCountry(
3087 DialogSection section, 3158 DialogSection section,
3088 const base::string16& country_name, 3159 const base::string16& country_name,
3089 bool should_clobber) { 3160 bool should_clobber) {
3090 DCHECK_NE(SECTION_CC, section); 3161 DCHECK_NE(SECTION_CC, section);
3091 3162
3092 if (view_ && !should_clobber) { 3163 if (view_ && !should_clobber) {
3093 FieldValueMap outputs; 3164 FieldValueMap outputs;
3094 view_->GetUserInput(section, &outputs); 3165 view_->GetUserInput(section, &outputs);
3095 3166
3096 // If |country_name| is the same as the view, no-op and let the caller know. 3167 // If |country_name| is the same as the view, no-op and let the caller know.
3097 if (outputs[CountryTypeForSection(section)] == country_name) 3168 if (outputs[TypeForSection(section, ADDRESS_HOME_COUNTRY)] == country_name)
3098 return false; 3169 return false;
3099 } 3170 }
3100 3171
3101 DetailInputs* inputs = MutableRequestedFieldsForSection(section); 3172 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
3102 inputs->clear(); 3173 inputs->clear();
3103 3174
3104 std::string country_code = AutofillCountry::GetCountryCode( 3175 std::string country_code = AutofillCountry::GetCountryCode(
3105 country_name, g_browser_process->GetApplicationLocale()); 3176 country_name, g_browser_process->GetApplicationLocale());
3106 common::BuildInputsForSection(section, country_code, inputs); 3177 common::BuildInputsForSection(section, country_code, inputs);
3107 return true; 3178 return true;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 DCHECK_EQ(animation, &card_generated_animation_); 3461 DCHECK_EQ(animation, &card_generated_animation_);
3391 PushOverlayUpdate(); 3462 PushOverlayUpdate();
3392 } 3463 }
3393 3464
3394 void AutofillDialogControllerImpl::AnimationEnded( 3465 void AutofillDialogControllerImpl::AnimationEnded(
3395 const gfx::Animation* animation) { 3466 const gfx::Animation* animation) {
3396 DCHECK_EQ(animation, &card_generated_animation_); 3467 DCHECK_EQ(animation, &card_generated_animation_);
3397 DoFinishSubmit(); 3468 DoFinishSubmit();
3398 } 3469 }
3399 3470
3471 void AutofillDialogControllerImpl::OnAddressValidationRulesLoaded(
3472 const std::string& country_code,
3473 bool success) {
3474 // TODO(dbeam): ask |view_| to re-validate its contents if necessary.
3475 }
3476
3400 void AutofillDialogControllerImpl::DoFinishSubmit() { 3477 void AutofillDialogControllerImpl::DoFinishSubmit() {
3401 FillOutputForSection(SECTION_CC); 3478 FillOutputForSection(SECTION_CC);
3402 FillOutputForSection(SECTION_BILLING); 3479 FillOutputForSection(SECTION_BILLING);
3403 FillOutputForSection(SECTION_CC_BILLING); 3480 FillOutputForSection(SECTION_CC_BILLING);
3404 3481
3405 if (ShouldUseBillingForShipping()) { 3482 if (ShouldUseBillingForShipping()) {
3406 FillOutputForSectionWithComparator( 3483 FillOutputForSectionWithComparator(
3407 SECTION_BILLING, 3484 SECTION_BILLING,
3408 base::Bind(ServerTypeMatchesShippingField)); 3485 base::Bind(ServerTypeMatchesShippingField));
3409 FillOutputForSectionWithComparator( 3486 FillOutputForSectionWithComparator(
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 view_->UpdateButtonStrip(); 3724 view_->UpdateButtonStrip();
3648 } 3725 }
3649 3726
3650 void AutofillDialogControllerImpl::FetchWalletCookie() { 3727 void AutofillDialogControllerImpl::FetchWalletCookie() {
3651 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); 3728 net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
3652 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); 3729 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
3653 signin_helper_->StartWalletCookieValueFetch(); 3730 signin_helper_->StartWalletCookieValueFetch();
3654 } 3731 }
3655 3732
3656 } // namespace autofill 3733 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698