| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 dialog_shown_timestamp_ = base::Time::Now(); | 646 dialog_shown_timestamp_ = base::Time::Now(); |
| 647 | 647 |
| 648 // Determine what field types should be included in the dialog. | 648 // Determine what field types should be included in the dialog. |
| 649 bool has_types = false; | 649 bool has_types = false; |
| 650 bool has_sections = false; | 650 bool has_sections = false; |
| 651 form_structure_.ParseFieldTypesFromAutocompleteAttributes( | 651 form_structure_.ParseFieldTypesFromAutocompleteAttributes( |
| 652 &has_types, &has_sections); | 652 &has_types, &has_sections); |
| 653 | 653 |
| 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(AutofillManagerDelegate::AutocompleteResultErrorUnsupported, | 656 callback_.Run( |
| 657 NULL); | 657 AutofillManagerDelegate::AutocompleteResultErrorUnsupported, |
| 658 base::ASCIIToUTF16("Form is missing autocomplete attributes."), |
| 659 NULL); |
| 658 delete this; | 660 delete this; |
| 659 return; | 661 return; |
| 660 } | 662 } |
| 661 | 663 |
| 662 billing_country_combobox_model_.reset(new CountryComboboxModel( | 664 billing_country_combobox_model_.reset(new CountryComboboxModel( |
| 663 *GetManager(), | 665 *GetManager(), |
| 664 base::Bind(CountryFilter, | 666 base::Bind(CountryFilter, |
| 665 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); | 667 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); |
| 666 shipping_country_combobox_model_.reset(new CountryComboboxModel( | 668 shipping_country_combobox_model_.reset(new CountryComboboxModel( |
| 667 *GetManager(), | 669 *GetManager(), |
| (...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2173 } | 2175 } |
| 2174 } | 2176 } |
| 2175 | 2177 |
| 2176 NOTREACHED(); | 2178 NOTREACHED(); |
| 2177 } | 2179 } |
| 2178 | 2180 |
| 2179 bool AutofillDialogControllerImpl::OnCancel() { | 2181 bool AutofillDialogControllerImpl::OnCancel() { |
| 2180 HidePopup(); | 2182 HidePopup(); |
| 2181 if (!is_submitting_) | 2183 if (!is_submitting_) |
| 2182 LogOnCancelMetrics(); | 2184 LogOnCancelMetrics(); |
| 2183 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, NULL); | 2185 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, |
| 2186 base::string16(), |
| 2187 NULL); |
| 2184 return true; | 2188 return true; |
| 2185 } | 2189 } |
| 2186 | 2190 |
| 2187 bool AutofillDialogControllerImpl::OnAccept() { | 2191 bool AutofillDialogControllerImpl::OnAccept() { |
| 2188 ScopedViewUpdates updates(view_.get()); | 2192 ScopedViewUpdates updates(view_.get()); |
| 2189 choose_another_instrument_or_address_ = false; | 2193 choose_another_instrument_or_address_ = false; |
| 2190 wallet_server_validation_recoverable_ = true; | 2194 wallet_server_validation_recoverable_ = true; |
| 2191 HidePopup(); | 2195 HidePopup(); |
| 2192 | 2196 |
| 2193 // This must come before SetIsSubmitting(). | 2197 // This must come before SetIsSubmitting(). |
| (...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3763 account_chooser_model_->HasAccountsToChoose()) { | 3767 account_chooser_model_->HasAccountsToChoose()) { |
| 3764 profile_->GetPrefs()->SetBoolean( | 3768 profile_->GetPrefs()->SetBoolean( |
| 3765 ::prefs::kAutofillDialogPayWithoutWallet, | 3769 ::prefs::kAutofillDialogPayWithoutWallet, |
| 3766 !account_chooser_model_->WalletIsSelected()); | 3770 !account_chooser_model_->WalletIsSelected()); |
| 3767 } | 3771 } |
| 3768 | 3772 |
| 3769 LogOnFinishSubmitMetrics(); | 3773 LogOnFinishSubmitMetrics(); |
| 3770 | 3774 |
| 3771 // Callback should be called as late as possible. | 3775 // Callback should be called as late as possible. |
| 3772 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, | 3776 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, |
| 3777 base::string16(), |
| 3773 &form_structure_); | 3778 &form_structure_); |
| 3774 data_was_passed_back_ = true; | 3779 data_was_passed_back_ = true; |
| 3775 | 3780 |
| 3776 // This might delete us. | 3781 // This might delete us. |
| 3777 Hide(); | 3782 Hide(); |
| 3778 } | 3783 } |
| 3779 | 3784 |
| 3780 void AutofillDialogControllerImpl::PersistAutofillChoice( | 3785 void AutofillDialogControllerImpl::PersistAutofillChoice( |
| 3781 DialogSection section, | 3786 DialogSection section, |
| 3782 const std::string& guid) { | 3787 const std::string& guid) { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3969 view_->UpdateButtonStrip(); | 3974 view_->UpdateButtonStrip(); |
| 3970 } | 3975 } |
| 3971 | 3976 |
| 3972 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3977 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3973 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3978 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3974 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3979 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3975 signin_helper_->StartWalletCookieValueFetch(); | 3980 signin_helper_->StartWalletCookieValueFetch(); |
| 3976 } | 3981 } |
| 3977 | 3982 |
| 3978 } // namespace autofill | 3983 } // namespace autofill |
| OLD | NEW |