| 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 |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 // Fail if the author didn't specify autocomplete types. | 654 // Fail if the author didn't specify autocomplete types. |
| 655 if (!has_types) { | 655 if (!has_types) { |
| 656 callback_.Run( | 656 callback_.Run( |
| 657 AutofillManagerDelegate::AutocompleteResultErrorUnsupported, | 657 AutofillManagerDelegate::AutocompleteResultErrorUnsupported, |
| 658 base::ASCIIToUTF16("Form is missing autocomplete attributes."), | 658 base::ASCIIToUTF16("Form is missing autocomplete attributes."), |
| 659 NULL); | 659 NULL); |
| 660 delete this; | 660 delete this; |
| 661 return; | 661 return; |
| 662 } | 662 } |
| 663 | 663 |
| 664 // Fail if the author didn't ask for at least some kind of credit card |
| 665 // information. |
| 666 bool has_credit_card_field = false; |
| 667 for (size_t i = 0; i < form_structure_.field_count(); ++i) { |
| 668 AutofillType type = form_structure_.field(i)->Type(); |
| 669 if (type.html_type() != HTML_TYPE_UNKNOWN && type.group() == CREDIT_CARD) { |
| 670 has_credit_card_field = true; |
| 671 break; |
| 672 } |
| 673 } |
| 674 |
| 675 if (!has_credit_card_field) { |
| 676 callback_.Run( |
| 677 AutofillManagerDelegate::AutocompleteResultErrorUnsupported, |
| 678 base::ASCIIToUTF16("Form is not a payment form (must contain " |
| 679 "some autocomplete=\"cc-*\" fields). "), |
| 680 NULL); |
| 681 delete this; |
| 682 return; |
| 683 } |
| 684 |
| 664 billing_country_combobox_model_.reset(new CountryComboboxModel( | 685 billing_country_combobox_model_.reset(new CountryComboboxModel( |
| 665 *GetManager(), | 686 *GetManager(), |
| 666 base::Bind(CountryFilter, | 687 base::Bind(CountryFilter, |
| 667 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); | 688 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); |
| 668 shipping_country_combobox_model_.reset(new CountryComboboxModel( | 689 shipping_country_combobox_model_.reset(new CountryComboboxModel( |
| 669 *GetManager(), | 690 *GetManager(), |
| 670 base::Bind(CountryFilter, | 691 base::Bind(CountryFilter, |
| 671 form_structure_.PossibleValues(ADDRESS_HOME_COUNTRY)))); | 692 form_structure_.PossibleValues(ADDRESS_HOME_COUNTRY)))); |
| 672 | 693 |
| 673 // Log any relevant UI metrics and security exceptions. | 694 // Log any relevant UI metrics and security exceptions. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 | 744 |
| 724 scoped_ptr< ::i18n::addressinput::Downloader> downloader( | 745 scoped_ptr< ::i18n::addressinput::Downloader> downloader( |
| 725 new autofill::ChromeDownloaderImpl(profile_->GetRequestContext())); | 746 new autofill::ChromeDownloaderImpl(profile_->GetRequestContext())); |
| 726 validator_ = AddressValidator::Build( | 747 validator_ = AddressValidator::Build( |
| 727 downloader.Pass(), | 748 downloader.Pass(), |
| 728 ValidationRulesStorageFactory::CreateStorage(), | 749 ValidationRulesStorageFactory::CreateStorage(), |
| 729 this); | 750 this); |
| 730 GetValidator()->LoadRules( | 751 GetValidator()->LoadRules( |
| 731 GetManager()->GetDefaultCountryCodeForNewAddress()); | 752 GetManager()->GetDefaultCountryCodeForNewAddress()); |
| 732 | 753 |
| 733 // TODO(estade): don't show the dialog if the site didn't specify the right | |
| 734 // fields. First we must figure out what the "right" fields are. | |
| 735 SuggestionsUpdated(); | 754 SuggestionsUpdated(); |
| 736 SubmitButtonDelayBegin(); | 755 SubmitButtonDelayBegin(); |
| 737 view_.reset(CreateView()); | 756 view_.reset(CreateView()); |
| 738 view_->Show(); | 757 view_->Show(); |
| 739 GetManager()->AddObserver(this); | 758 GetManager()->AddObserver(this); |
| 740 | 759 |
| 741 if (!account_chooser_model_->WalletIsSelected()) | 760 if (!account_chooser_model_->WalletIsSelected()) |
| 742 LogDialogLatencyToShow(); | 761 LogDialogLatencyToShow(); |
| 743 } | 762 } |
| 744 | 763 |
| (...skipping 3229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3974 view_->UpdateButtonStrip(); | 3993 view_->UpdateButtonStrip(); |
| 3975 } | 3994 } |
| 3976 | 3995 |
| 3977 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3996 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3978 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3997 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3979 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3998 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3980 signin_helper_->StartWalletCookieValueFetch(); | 3999 signin_helper_->StartWalletCookieValueFetch(); |
| 3981 } | 4000 } |
| 3982 | 4001 |
| 3983 } // namespace autofill | 4002 } // namespace autofill |
| OLD | NEW |