| OLD | NEW |
| 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/bind_helpers.h" |
| 16 #include "base/i18n/case_conversion.h" | 17 #include "base/i18n/case_conversion.h" |
| 17 #include "base/i18n/rtl.h" | 18 #include "base/i18n/rtl.h" |
| 18 #include "base/logging.h" | 19 #include "base/logging.h" |
| 19 #include "base/prefs/pref_registry_simple.h" | 20 #include "base/prefs/pref_registry_simple.h" |
| 20 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
| 21 #include "base/prefs/scoped_user_pref_update.h" | 22 #include "base/prefs/scoped_user_pref_update.h" |
| 22 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
| 23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_split.h" | 25 #include "base/strings/string_split.h" |
| 25 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 28 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 29 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 30 #include "chrome/browser/autofill/validation_rules_storage_factory.h" |
| 29 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" | 33 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" |
| 32 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" | 34 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
| 33 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" | 35 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" |
| 34 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 36 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 35 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" | 37 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" |
| 36 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" | 38 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" |
| 37 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
| 38 #include "chrome/browser/ui/browser_finder.h" | 40 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "content/public/browser/web_contents.h" | 74 #include "content/public/browser/web_contents.h" |
| 73 #include "content/public/browser/web_contents_view.h" | 75 #include "content/public/browser/web_contents_view.h" |
| 74 #include "content/public/common/url_constants.h" | 76 #include "content/public/common/url_constants.h" |
| 75 #include "grit/chromium_strings.h" | 77 #include "grit/chromium_strings.h" |
| 76 #include "grit/component_strings.h" | 78 #include "grit/component_strings.h" |
| 77 #include "grit/generated_resources.h" | 79 #include "grit/generated_resources.h" |
| 78 #include "grit/platform_locale_settings.h" | 80 #include "grit/platform_locale_settings.h" |
| 79 #include "grit/theme_resources.h" | 81 #include "grit/theme_resources.h" |
| 80 #include "grit/webkit_resources.h" | 82 #include "grit/webkit_resources.h" |
| 81 #include "net/cert/cert_status_flags.h" | 83 #include "net/cert/cert_status_flags.h" |
| 84 #include "third_party/libaddressinput/chromium/chrome_downloader_impl.h" |
| 85 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" |
| 86 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_data.h" |
| 87 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_problem.h" |
| 82 #include "ui/base/base_window.h" | 88 #include "ui/base/base_window.h" |
| 83 #include "ui/base/l10n/l10n_util.h" | 89 #include "ui/base/l10n/l10n_util.h" |
| 84 #include "ui/base/models/combobox_model.h" | 90 #include "ui/base/models/combobox_model.h" |
| 85 #include "ui/base/resource/resource_bundle.h" | 91 #include "ui/base/resource/resource_bundle.h" |
| 86 #include "ui/events/event.h" | 92 #include "ui/events/event.h" |
| 87 #include "ui/gfx/canvas.h" | 93 #include "ui/gfx/canvas.h" |
| 88 #include "ui/gfx/image/image_skia_operations.h" | 94 #include "ui/gfx/image/image_skia_operations.h" |
| 89 #include "ui/gfx/skia_util.h" | 95 #include "ui/gfx/skia_util.h" |
| 90 | 96 |
| 97 using ::i18n::addressinput::AddressData; |
| 98 using ::i18n::addressinput::AddressField; |
| 99 using ::i18n::addressinput::AddressProblem; |
| 100 using ::i18n::addressinput::AddressProblemFilter; |
| 101 using ::i18n::addressinput::AddressProblems; |
| 102 using ::i18n::addressinput::AddressValidator; |
| 103 |
| 91 namespace autofill { | 104 namespace autofill { |
| 92 | 105 |
| 93 namespace { | 106 namespace { |
| 94 | 107 |
| 95 const char kAddNewItemKey[] = "add-new-item"; | 108 const char kAddNewItemKey[] = "add-new-item"; |
| 96 const char kManageItemsKey[] = "manage-items"; | 109 const char kManageItemsKey[] = "manage-items"; |
| 97 const char kSameAsBillingKey[] = "same-as-billing"; | 110 const char kSameAsBillingKey[] = "same-as-billing"; |
| 98 | 111 |
| 99 // URLs for Wallet error messages. | 112 // URLs for Wallet error messages. |
| 100 const char kBuyerLegalAddressStatusUrl[] = | 113 const char kBuyerLegalAddressStatusUrl[] = |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 624 |
| 612 account_chooser_model_.reset( | 625 account_chooser_model_.reset( |
| 613 new AccountChooserModel(this, | 626 new AccountChooserModel(this, |
| 614 profile_, | 627 profile_, |
| 615 !ShouldShowAccountChooser(), | 628 !ShouldShowAccountChooser(), |
| 616 metric_logger_)); | 629 metric_logger_)); |
| 617 | 630 |
| 618 if (account_chooser_model_->WalletIsSelected()) | 631 if (account_chooser_model_->WalletIsSelected()) |
| 619 FetchWalletCookie(); | 632 FetchWalletCookie(); |
| 620 | 633 |
| 634 if (i18ninput::Enabled()) { |
| 635 scoped_ptr< ::i18n::addressinput::Downloader> downloader( |
| 636 new autofill::ChromeDownloaderImpl(profile_->GetRequestContext())); |
| 637 validator_ = AddressValidator::Build( |
| 638 downloader.Pass(), |
| 639 ValidationRulesStorageFactory::CreateStorage(), |
| 640 this); |
| 641 } |
| 642 |
| 643 AddressValidator* validator = GetValidator(); |
| 644 if (validator) |
| 645 validator->LoadRules(GetManager()->GetDefaultCountryCodeForNewAddress()); |
| 646 |
| 621 // TODO(estade): don't show the dialog if the site didn't specify the right | 647 // TODO(estade): don't show the dialog if the site didn't specify the right |
| 622 // fields. First we must figure out what the "right" fields are. | 648 // fields. First we must figure out what the "right" fields are. |
| 623 SuggestionsUpdated(); | 649 SuggestionsUpdated(); |
| 624 SubmitButtonDelayBegin(); | 650 SubmitButtonDelayBegin(); |
| 625 view_.reset(CreateView()); | 651 view_.reset(CreateView()); |
| 626 view_->Show(); | 652 view_->Show(); |
| 627 GetManager()->AddObserver(this); | 653 GetManager()->AddObserver(this); |
| 628 | 654 |
| 629 if (!account_chooser_model_->WalletIsSelected()) | 655 if (!account_chooser_model_->WalletIsSelected()) |
| 630 LogDialogLatencyToShow(); | 656 LogDialogLatencyToShow(); |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 } | 1181 } |
| 1156 | 1182 |
| 1157 return snapshot; | 1183 return snapshot; |
| 1158 } | 1184 } |
| 1159 | 1185 |
| 1160 void AutofillDialogControllerImpl::RestoreUserInputFromSnapshot( | 1186 void AutofillDialogControllerImpl::RestoreUserInputFromSnapshot( |
| 1161 const FieldValueMap& snapshot) { | 1187 const FieldValueMap& snapshot) { |
| 1162 if (snapshot.empty()) | 1188 if (snapshot.empty()) |
| 1163 return; | 1189 return; |
| 1164 | 1190 |
| 1165 FieldMapWrapper wrapper(snapshot); | |
| 1166 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 1191 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
| 1167 DialogSection section = static_cast<DialogSection>(i); | 1192 DialogSection section = static_cast<DialogSection>(i); |
| 1168 if (!SectionIsActive(section)) | 1193 if (!SectionIsActive(section)) |
| 1169 continue; | 1194 continue; |
| 1170 | 1195 |
| 1171 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 1196 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
| 1172 wrapper.FillInputs(inputs); | |
| 1173 | |
| 1174 for (size_t i = 0; i < inputs->size(); ++i) { | 1197 for (size_t i = 0; i < inputs->size(); ++i) { |
| 1175 if (InputWasEdited((*inputs)[i].type, (*inputs)[i].initial_value)) { | 1198 DetailInput* input = &(*inputs)[i]; |
| 1199 input->initial_value = |
| 1200 GetInfoFromInputs(snapshot, section, AutofillType(input->type)); |
| 1201 if (InputWasEdited(input->type, input->initial_value)) |
| 1176 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey); | 1202 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey); |
| 1177 break; | |
| 1178 } | |
| 1179 } | 1203 } |
| 1180 } | 1204 } |
| 1181 } | 1205 } |
| 1182 | 1206 |
| 1183 void AutofillDialogControllerImpl::UpdateSection(DialogSection section) { | 1207 void AutofillDialogControllerImpl::UpdateSection(DialogSection section) { |
| 1184 if (view_) | 1208 if (view_) |
| 1185 view_->UpdateSection(section); | 1209 view_->UpdateSection(section); |
| 1186 } | 1210 } |
| 1187 | 1211 |
| 1188 void AutofillDialogControllerImpl::UpdateForErrors() { | 1212 void AutofillDialogControllerImpl::UpdateForErrors() { |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 if (it != wallet_errors_.end()) { | 1665 if (it != wallet_errors_.end()) { |
| 1642 TypeErrorInputMap::const_iterator iter = it->second.find(type); | 1666 TypeErrorInputMap::const_iterator iter = it->second.find(type); |
| 1643 if (iter != it->second.end()) { | 1667 if (iter != it->second.end()) { |
| 1644 if (iter->second.second == value) | 1668 if (iter->second.second == value) |
| 1645 return iter->second.first; | 1669 return iter->second.first; |
| 1646 it->second.erase(type); | 1670 it->second.erase(type); |
| 1647 } | 1671 } |
| 1648 } | 1672 } |
| 1649 } | 1673 } |
| 1650 | 1674 |
| 1651 switch (AutofillType(type).GetStorableType()) { | 1675 AutofillType autofill_type(type); |
| 1676 if (i18ninput::Enabled() && |
| 1677 (autofill_type.group() == ADDRESS_HOME || |
| 1678 autofill_type.group() == ADDRESS_BILLING)) { |
| 1679 return base::string16(); |
| 1680 } |
| 1681 |
| 1682 switch (autofill_type.GetStorableType()) { |
| 1652 case EMAIL_ADDRESS: | 1683 case EMAIL_ADDRESS: |
| 1653 if (!value.empty() && !IsValidEmailAddress(value)) { | 1684 if (!value.empty() && !IsValidEmailAddress(value)) { |
| 1654 return l10n_util::GetStringUTF16( | 1685 return l10n_util::GetStringUTF16( |
| 1655 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_EMAIL_ADDRESS); | 1686 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_EMAIL_ADDRESS); |
| 1656 } | 1687 } |
| 1657 break; | 1688 break; |
| 1658 | 1689 |
| 1659 case CREDIT_CARD_NUMBER: { | 1690 case CREDIT_CARD_NUMBER: { |
| 1660 if (!value.empty()) { | 1691 if (!value.empty()) { |
| 1661 base::string16 message = CreditCardNumberValidityMessage(value); | 1692 base::string16 message = CreditCardNumberValidityMessage(value); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1692 case ADDRESS_HOME_LINE2: | 1723 case ADDRESS_HOME_LINE2: |
| 1693 case ADDRESS_HOME_DEPENDENT_LOCALITY: | 1724 case ADDRESS_HOME_DEPENDENT_LOCALITY: |
| 1694 case ADDRESS_HOME_SORTING_CODE: | 1725 case ADDRESS_HOME_SORTING_CODE: |
| 1695 return base::string16(); // Optional until we have better validation. | 1726 return base::string16(); // Optional until we have better validation. |
| 1696 | 1727 |
| 1697 case ADDRESS_HOME_CITY: | 1728 case ADDRESS_HOME_CITY: |
| 1698 case ADDRESS_HOME_COUNTRY: | 1729 case ADDRESS_HOME_COUNTRY: |
| 1699 break; | 1730 break; |
| 1700 | 1731 |
| 1701 case ADDRESS_HOME_STATE: | 1732 case ADDRESS_HOME_STATE: |
| 1702 if (!value.empty() && !autofill::IsValidState(value) && | 1733 if (!value.empty() &&!autofill::IsValidState(value) && |
| 1703 CountryCodeForSection(section) == "US") { | 1734 CountryCodeForSection(section) == "US") { |
| 1735 DCHECK(!i18ninput::Enabled()); |
| 1704 return l10n_util::GetStringUTF16( | 1736 return l10n_util::GetStringUTF16( |
| 1705 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION); | 1737 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION); |
| 1706 } | 1738 } |
| 1707 break; | 1739 break; |
| 1708 | 1740 |
| 1709 case ADDRESS_HOME_ZIP: | 1741 case ADDRESS_HOME_ZIP: |
| 1710 if (!value.empty() && !autofill::IsValidZip(value) && | 1742 if (!value.empty() && !autofill::IsValidZip(value) && |
| 1711 CountryCodeForSection(section) == "US") { | 1743 CountryCodeForSection(section) == "US") { |
| 1744 DCHECK(!i18ninput::Enabled()); |
| 1712 return l10n_util::GetStringUTF16( | 1745 return l10n_util::GetStringUTF16( |
| 1713 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE); | 1746 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE); |
| 1714 } | 1747 } |
| 1715 break; | 1748 break; |
| 1716 | 1749 |
| 1717 case NAME_FULL: | 1750 case NAME_FULL: |
| 1718 // Wallet requires a first and last billing name. | 1751 // Wallet requires a first and last billing name. |
| 1719 if (section == SECTION_CC_BILLING && !value.empty() && | 1752 if (section == SECTION_CC_BILLING && !value.empty() && |
| 1720 !IsCardHolderNameValidForWallet(value)) { | 1753 !IsCardHolderNameValidForWallet(value)) { |
| 1721 DCHECK(IsPayingWithWallet()); | 1754 DCHECK(IsPayingWithWallet()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1738 return value.empty() ? | 1771 return value.empty() ? |
| 1739 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) : | 1772 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) : |
| 1740 base::string16(); | 1773 base::string16(); |
| 1741 } | 1774 } |
| 1742 | 1775 |
| 1743 // TODO(groby): Also add tests. | 1776 // TODO(groby): Also add tests. |
| 1744 ValidityMessages AutofillDialogControllerImpl::InputsAreValid( | 1777 ValidityMessages AutofillDialogControllerImpl::InputsAreValid( |
| 1745 DialogSection section, | 1778 DialogSection section, |
| 1746 const FieldValueMap& inputs) { | 1779 const FieldValueMap& inputs) { |
| 1747 ValidityMessages messages; | 1780 ValidityMessages messages; |
| 1781 if (inputs.empty()) |
| 1782 return messages; |
| 1783 |
| 1748 FieldValueMap field_values; | 1784 FieldValueMap field_values; |
| 1785 |
| 1786 AddressValidator* validator = GetValidator(); |
| 1787 if (validator && section != SECTION_CC) { |
| 1788 AddressProblems problems; |
| 1789 AddressData address_data; |
| 1790 i18ninput::CreateAddressData( |
| 1791 base::Bind(&GetInfoFromInputs, base::ConstRef(inputs), section), |
| 1792 &address_data); |
| 1793 DCHECK_EQ(2U, address_data.country_code.size()); |
| 1794 if (validator->ValidateAddress(address_data, |
| 1795 AddressProblemFilter(), |
| 1796 &problems) == AddressValidator::SUCCESS) { |
| 1797 common::AddressType address_type = section == SECTION_SHIPPING ? |
| 1798 common::ADDRESS_TYPE_SHIPPING : common::ADDRESS_TYPE_BILLING; |
| 1799 for (size_t i = 0; i < problems.size(); ++i) { |
| 1800 const AddressProblem& problem = problems[i]; |
| 1801 bool sure = problem.type != AddressProblem::MISSING_REQUIRED_FIELD; |
| 1802 base::string16 text = l10n_util::GetStringUTF16(problem.description_id); |
| 1803 messages.Set(i18ninput::TypeForField(problem.field, address_type), |
| 1804 ValidityMessage(text, sure)); |
| 1805 } |
| 1806 } |
| 1807 } |
| 1808 |
| 1749 for (FieldValueMap::const_iterator iter = inputs.begin(); | 1809 for (FieldValueMap::const_iterator iter = inputs.begin(); |
| 1750 iter != inputs.end(); ++iter) { | 1810 iter != inputs.end(); ++iter) { |
| 1751 const ServerFieldType type = iter->first; | 1811 const ServerFieldType type = iter->first; |
| 1812 if (!messages.GetMessageOrDefault(type).text.empty()) |
| 1813 continue; |
| 1752 | 1814 |
| 1753 base::string16 text = InputValidityMessage(section, type, iter->second); | 1815 base::string16 text = InputValidityMessage(section, type, iter->second); |
| 1754 | 1816 |
| 1755 // Skip empty/unchanged fields in edit mode. Ignore country as it always has | 1817 // Skip empty/unchanged fields in edit mode. Ignore country as it always has |
| 1756 // a value. If the individual field does not have validation errors, assume | 1818 // a value. If the individual field does not have validation errors, assume |
| 1757 // it to be valid unless later proven otherwise. | 1819 // it to be valid unless later proven otherwise. |
| 1758 bool sure = InputWasEdited(type, iter->second) || | 1820 bool sure = InputWasEdited(type, iter->second) || |
| 1759 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY; | 1821 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY; |
| 1760 | 1822 |
| 1761 // Consider only individually valid fields for inter-field validation. | 1823 // Consider only individually valid fields for inter-field validation. |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 handling_use_wallet_link_click_(false), | 2630 handling_use_wallet_link_click_(false), |
| 2569 passive_failed_(false), | 2631 passive_failed_(false), |
| 2570 billing_country_combobox_model_(*GetManager()), | 2632 billing_country_combobox_model_(*GetManager()), |
| 2571 shipping_country_combobox_model_(*GetManager()), | 2633 shipping_country_combobox_model_(*GetManager()), |
| 2572 suggested_cc_(this), | 2634 suggested_cc_(this), |
| 2573 suggested_billing_(this), | 2635 suggested_billing_(this), |
| 2574 suggested_cc_billing_(this), | 2636 suggested_cc_billing_(this), |
| 2575 suggested_shipping_(this), | 2637 suggested_shipping_(this), |
| 2576 cares_about_shipping_(true), | 2638 cares_about_shipping_(true), |
| 2577 popup_input_type_(UNKNOWN_TYPE), | 2639 popup_input_type_(UNKNOWN_TYPE), |
| 2578 weak_ptr_factory_(this), | |
| 2579 waiting_for_explicit_sign_in_response_(false), | 2640 waiting_for_explicit_sign_in_response_(false), |
| 2580 has_accepted_legal_documents_(false), | 2641 has_accepted_legal_documents_(false), |
| 2581 is_submitting_(false), | 2642 is_submitting_(false), |
| 2582 choose_another_instrument_or_address_(false), | 2643 choose_another_instrument_or_address_(false), |
| 2583 wallet_server_validation_recoverable_(true), | 2644 wallet_server_validation_recoverable_(true), |
| 2584 data_was_passed_back_(false), | 2645 data_was_passed_back_(false), |
| 2585 was_ui_latency_logged_(false), | 2646 was_ui_latency_logged_(false), |
| 2586 card_generated_animation_(2000, 60, this) { | 2647 card_generated_animation_(2000, 60, this), |
| 2648 weak_ptr_factory_(this) { |
| 2587 // TODO(estade): remove duplicates from |form_structure|? | 2649 // TODO(estade): remove duplicates from |form_structure|? |
| 2588 DCHECK(!callback_.is_null()); | 2650 DCHECK(!callback_.is_null()); |
| 2589 } | 2651 } |
| 2590 | 2652 |
| 2591 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { | 2653 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { |
| 2592 return AutofillDialogView::Create(this); | 2654 return AutofillDialogView::Create(this); |
| 2593 } | 2655 } |
| 2594 | 2656 |
| 2657 // static |
| 2658 base::string16 AutofillDialogControllerImpl::GetInfoFromInputs( |
| 2659 const FieldValueMap& inputs, |
| 2660 DialogSection section, |
| 2661 const AutofillType& type) { |
| 2662 ServerFieldType field_type = type.GetStorableType(); |
| 2663 if (section != SECTION_SHIPPING) |
| 2664 field_type = AutofillType::GetEquivalentBillingFieldType(field_type); |
| 2665 |
| 2666 base::string16 info; |
| 2667 FieldValueMap::const_iterator it = inputs.find(field_type); |
| 2668 if (it != inputs.end()) |
| 2669 info = it->second; |
| 2670 |
| 2671 if (!info.empty() && type.html_type() == HTML_TYPE_COUNTRY_CODE) { |
| 2672 info = base::ASCIIToUTF16(AutofillCountry::GetCountryCode( |
| 2673 info, g_browser_process->GetApplicationLocale())); |
| 2674 } |
| 2675 |
| 2676 return info; |
| 2677 } |
| 2678 |
| 2595 PersonalDataManager* AutofillDialogControllerImpl::GetManager() const { | 2679 PersonalDataManager* AutofillDialogControllerImpl::GetManager() const { |
| 2596 return PersonalDataManagerFactory::GetForProfile(profile_); | 2680 return PersonalDataManagerFactory::GetForProfile(profile_); |
| 2597 } | 2681 } |
| 2598 | 2682 |
| 2599 const wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() | 2683 const wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() |
| 2600 const { | 2684 const { |
| 2601 return const_cast<AutofillDialogControllerImpl*>(this)->GetWalletClient(); | 2685 return const_cast<AutofillDialogControllerImpl*>(this)->GetWalletClient(); |
| 2602 } | 2686 } |
| 2603 | 2687 |
| 2604 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() { | 2688 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() { |
| 2605 return &wallet_client_; | 2689 return &wallet_client_; |
| 2606 } | 2690 } |
| 2607 | 2691 |
| 2692 AddressValidator* AutofillDialogControllerImpl::GetValidator() { |
| 2693 return validator_.get(); |
| 2694 } |
| 2695 |
| 2608 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { | 2696 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { |
| 2609 return account_chooser_model_->WalletIsSelected() && | 2697 return account_chooser_model_->WalletIsSelected() && |
| 2610 SignedInState() == SIGNED_IN; | 2698 SignedInState() == SIGNED_IN; |
| 2611 } | 2699 } |
| 2612 | 2700 |
| 2613 void AutofillDialogControllerImpl::LoadRiskFingerprintData() { | 2701 void AutofillDialogControllerImpl::LoadRiskFingerprintData() { |
| 2614 risk_data_.clear(); | 2702 risk_data_.clear(); |
| 2615 | 2703 |
| 2616 uint64 obfuscated_gaia_id = 0; | 2704 uint64 obfuscated_gaia_id = 0; |
| 2617 bool success = base::StringToUint64(wallet_items_->ObfuscatedGaiaId(), | 2705 bool success = base::StringToUint64(wallet_items_->ObfuscatedGaiaId(), |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 if (outputs[CountryTypeForSection(section)] == country_name) | 3186 if (outputs[CountryTypeForSection(section)] == country_name) |
| 3099 return false; | 3187 return false; |
| 3100 } | 3188 } |
| 3101 | 3189 |
| 3102 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | 3190 DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
| 3103 inputs->clear(); | 3191 inputs->clear(); |
| 3104 | 3192 |
| 3105 std::string country_code = AutofillCountry::GetCountryCode( | 3193 std::string country_code = AutofillCountry::GetCountryCode( |
| 3106 country_name, g_browser_process->GetApplicationLocale()); | 3194 country_name, g_browser_process->GetApplicationLocale()); |
| 3107 common::BuildInputsForSection(section, country_code, inputs); | 3195 common::BuildInputsForSection(section, country_code, inputs); |
| 3196 |
| 3197 if (GetValidator()) |
| 3198 GetValidator()->LoadRules(country_code); |
| 3199 |
| 3108 return true; | 3200 return true; |
| 3109 } | 3201 } |
| 3110 | 3202 |
| 3111 void AutofillDialogControllerImpl::HidePopup() { | 3203 void AutofillDialogControllerImpl::HidePopup() { |
| 3112 if (popup_controller_.get()) | 3204 if (popup_controller_.get()) |
| 3113 popup_controller_->Hide(); | 3205 popup_controller_->Hide(); |
| 3114 popup_input_type_ = UNKNOWN_TYPE; | 3206 popup_input_type_ = UNKNOWN_TYPE; |
| 3115 } | 3207 } |
| 3116 | 3208 |
| 3117 void AutofillDialogControllerImpl::SetEditingExistingData( | 3209 void AutofillDialogControllerImpl::SetEditingExistingData( |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3391 DCHECK_EQ(animation, &card_generated_animation_); | 3483 DCHECK_EQ(animation, &card_generated_animation_); |
| 3392 PushOverlayUpdate(); | 3484 PushOverlayUpdate(); |
| 3393 } | 3485 } |
| 3394 | 3486 |
| 3395 void AutofillDialogControllerImpl::AnimationEnded( | 3487 void AutofillDialogControllerImpl::AnimationEnded( |
| 3396 const gfx::Animation* animation) { | 3488 const gfx::Animation* animation) { |
| 3397 DCHECK_EQ(animation, &card_generated_animation_); | 3489 DCHECK_EQ(animation, &card_generated_animation_); |
| 3398 DoFinishSubmit(); | 3490 DoFinishSubmit(); |
| 3399 } | 3491 } |
| 3400 | 3492 |
| 3493 void AutofillDialogControllerImpl::OnAddressValidationRulesLoaded( |
| 3494 const std::string& country_code, |
| 3495 bool success) { |
| 3496 // TODO(dbeam): ask |view_| to re-validate its contents if necessary. |
| 3497 } |
| 3498 |
| 3401 void AutofillDialogControllerImpl::DoFinishSubmit() { | 3499 void AutofillDialogControllerImpl::DoFinishSubmit() { |
| 3402 FillOutputForSection(SECTION_CC); | 3500 FillOutputForSection(SECTION_CC); |
| 3403 FillOutputForSection(SECTION_BILLING); | 3501 FillOutputForSection(SECTION_BILLING); |
| 3404 FillOutputForSection(SECTION_CC_BILLING); | 3502 FillOutputForSection(SECTION_CC_BILLING); |
| 3405 | 3503 |
| 3406 if (ShouldUseBillingForShipping()) { | 3504 if (ShouldUseBillingForShipping()) { |
| 3407 FillOutputForSectionWithComparator( | 3505 FillOutputForSectionWithComparator( |
| 3408 SECTION_BILLING, | 3506 SECTION_BILLING, |
| 3409 base::Bind(ServerTypeMatchesShippingField)); | 3507 base::Bind(ServerTypeMatchesShippingField)); |
| 3410 FillOutputForSectionWithComparator( | 3508 FillOutputForSectionWithComparator( |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3648 view_->UpdateButtonStrip(); | 3746 view_->UpdateButtonStrip(); |
| 3649 } | 3747 } |
| 3650 | 3748 |
| 3651 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3749 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3652 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3750 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3653 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3751 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3654 signin_helper_->StartWalletCookieValueFetch(); | 3752 signin_helper_->StartWalletCookieValueFetch(); |
| 3655 } | 3753 } |
| 3656 | 3754 |
| 3657 } // namespace autofill | 3755 } // namespace autofill |
| OLD | NEW |