| 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 dialog_shown_timestamp_ = base::Time::Now(); | 647 dialog_shown_timestamp_ = base::Time::Now(); |
| 648 | 648 |
| 649 // Determine what field types should be included in the dialog. | 649 // Determine what field types should be included in the dialog. |
| 650 bool has_types = false; | 650 bool has_types = false; |
| 651 bool has_sections = false; | 651 bool has_sections = false; |
| 652 form_structure_.ParseFieldTypesFromAutocompleteAttributes( | 652 form_structure_.ParseFieldTypesFromAutocompleteAttributes( |
| 653 &has_types, &has_sections); | 653 &has_types, &has_sections); |
| 654 | 654 |
| 655 // Fail if the author didn't specify autocomplete types. | 655 // Fail if the author didn't specify autocomplete types. |
| 656 if (!has_types) { | 656 if (!has_types) { |
| 657 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorUnsupported, | 657 callback_.Run( |
| 658 NULL); | 658 AutofillManagerDelegate::AutocompleteResultErrorUnsupported, |
| 659 base::ASCIIToUTF16("Form is missing autocomplete attributes."), |
| 660 NULL); |
| 659 delete this; | 661 delete this; |
| 660 return; | 662 return; |
| 661 } | 663 } |
| 662 | 664 |
| 663 billing_country_combobox_model_.reset(new CountryComboboxModel( | 665 billing_country_combobox_model_.reset(new CountryComboboxModel( |
| 664 *GetManager(), | 666 *GetManager(), |
| 665 base::Bind(CountryFilter, | 667 base::Bind(CountryFilter, |
| 666 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); | 668 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); |
| 667 shipping_country_combobox_model_.reset(new CountryComboboxModel( | 669 shipping_country_combobox_model_.reset(new CountryComboboxModel( |
| 668 *GetManager(), | 670 *GetManager(), |
| (...skipping 1504 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 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3745 account_chooser_model_->HasAccountsToChoose()) { | 3749 account_chooser_model_->HasAccountsToChoose()) { |
| 3746 profile_->GetPrefs()->SetBoolean( | 3750 profile_->GetPrefs()->SetBoolean( |
| 3747 ::prefs::kAutofillDialogPayWithoutWallet, | 3751 ::prefs::kAutofillDialogPayWithoutWallet, |
| 3748 !account_chooser_model_->WalletIsSelected()); | 3752 !account_chooser_model_->WalletIsSelected()); |
| 3749 } | 3753 } |
| 3750 | 3754 |
| 3751 LogOnFinishSubmitMetrics(); | 3755 LogOnFinishSubmitMetrics(); |
| 3752 | 3756 |
| 3753 // Callback should be called as late as possible. | 3757 // Callback should be called as late as possible. |
| 3754 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, | 3758 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, |
| 3759 base::string16(), |
| 3755 &form_structure_); | 3760 &form_structure_); |
| 3756 data_was_passed_back_ = true; | 3761 data_was_passed_back_ = true; |
| 3757 | 3762 |
| 3758 // This might delete us. | 3763 // This might delete us. |
| 3759 Hide(); | 3764 Hide(); |
| 3760 } | 3765 } |
| 3761 | 3766 |
| 3762 void AutofillDialogControllerImpl::PersistAutofillChoice( | 3767 void AutofillDialogControllerImpl::PersistAutofillChoice( |
| 3763 DialogSection section, | 3768 DialogSection section, |
| 3764 const std::string& guid) { | 3769 const std::string& guid) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3950 view_->UpdateButtonStrip(); | 3955 view_->UpdateButtonStrip(); |
| 3951 } | 3956 } |
| 3952 | 3957 |
| 3953 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3958 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3954 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3959 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3955 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3960 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3956 signin_helper_->StartWalletCookieValueFetch(); | 3961 signin_helper_->StartWalletCookieValueFetch(); |
| 3957 } | 3962 } |
| 3958 | 3963 |
| 3959 } // namespace autofill | 3964 } // namespace autofill |
| OLD | NEW |