Chromium Code Reviews| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 | 589 |
| 590 return true; | 590 return true; |
| 591 } | 591 } |
| 592 | 592 |
| 593 // static | 593 // static |
| 594 base::WeakPtr<AutofillDialogControllerImpl> | 594 base::WeakPtr<AutofillDialogControllerImpl> |
| 595 AutofillDialogControllerImpl::Create( | 595 AutofillDialogControllerImpl::Create( |
| 596 content::WebContents* contents, | 596 content::WebContents* contents, |
| 597 const FormData& form_structure, | 597 const FormData& form_structure, |
| 598 const GURL& source_url, | 598 const GURL& source_url, |
| 599 const base::Callback<void(const FormStructure*)>& callback) { | 599 const AutofillManagerDelegate::ResultCallback& callback) { |
| 600 // AutofillDialogControllerImpl owns itself. | 600 // AutofillDialogControllerImpl owns itself. |
| 601 AutofillDialogControllerImpl* autofill_dialog_controller = | 601 AutofillDialogControllerImpl* autofill_dialog_controller = |
| 602 new AutofillDialogControllerImpl(contents, | 602 new AutofillDialogControllerImpl(contents, |
| 603 form_structure, | 603 form_structure, |
| 604 source_url, | 604 source_url, |
| 605 callback); | 605 callback); |
| 606 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); | 606 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); |
| 607 } | 607 } |
| 608 | 608 |
| 609 // static | 609 // static |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 629 ::prefs::kAutofillDialogWalletShippingSameAsBilling, | 629 ::prefs::kAutofillDialogWalletShippingSameAsBilling, |
| 630 false, | 630 false, |
| 631 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 631 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 632 } | 632 } |
| 633 | 633 |
| 634 // static | 634 // static |
| 635 base::WeakPtr<AutofillDialogController> AutofillDialogController::Create( | 635 base::WeakPtr<AutofillDialogController> AutofillDialogController::Create( |
| 636 content::WebContents* contents, | 636 content::WebContents* contents, |
| 637 const FormData& form_structure, | 637 const FormData& form_structure, |
| 638 const GURL& source_url, | 638 const GURL& source_url, |
| 639 const base::Callback<void(const FormStructure*)>& callback) { | 639 const AutofillManagerDelegate::ResultCallback& callback) { |
| 640 return AutofillDialogControllerImpl::Create(contents, | 640 return AutofillDialogControllerImpl::Create(contents, |
| 641 form_structure, | 641 form_structure, |
| 642 source_url, | 642 source_url, |
| 643 callback); | 643 callback); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void AutofillDialogControllerImpl::Show() { | 646 void AutofillDialogControllerImpl::Show() { |
| 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(NULL); | 657 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorUnsupported, |
|
Evan Stade
2014/04/09 22:11:15
^behavioral change (previously this would have cou
| |
| 658 NULL); | |
| 658 delete this; | 659 delete this; |
| 659 return; | 660 return; |
| 660 } | 661 } |
| 661 | 662 |
| 662 billing_country_combobox_model_.reset(new CountryComboboxModel( | 663 billing_country_combobox_model_.reset(new CountryComboboxModel( |
| 663 *GetManager(), | 664 *GetManager(), |
| 664 base::Bind(CountryFilter, | 665 base::Bind(CountryFilter, |
| 665 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); | 666 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY)))); |
| 666 shipping_country_combobox_model_.reset(new CountryComboboxModel( | 667 shipping_country_combobox_model_.reset(new CountryComboboxModel( |
| 667 *GetManager(), | 668 *GetManager(), |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2172 } | 2173 } |
| 2173 } | 2174 } |
| 2174 | 2175 |
| 2175 NOTREACHED(); | 2176 NOTREACHED(); |
| 2176 } | 2177 } |
| 2177 | 2178 |
| 2178 bool AutofillDialogControllerImpl::OnCancel() { | 2179 bool AutofillDialogControllerImpl::OnCancel() { |
| 2179 HidePopup(); | 2180 HidePopup(); |
| 2180 if (!is_submitting_) | 2181 if (!is_submitting_) |
| 2181 LogOnCancelMetrics(); | 2182 LogOnCancelMetrics(); |
| 2182 callback_.Run(NULL); | 2183 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, NULL); |
| 2183 return true; | 2184 return true; |
| 2184 } | 2185 } |
| 2185 | 2186 |
| 2186 bool AutofillDialogControllerImpl::OnAccept() { | 2187 bool AutofillDialogControllerImpl::OnAccept() { |
| 2187 ScopedViewUpdates updates(view_.get()); | 2188 ScopedViewUpdates updates(view_.get()); |
| 2188 choose_another_instrument_or_address_ = false; | 2189 choose_another_instrument_or_address_ = false; |
| 2189 wallet_server_validation_recoverable_ = true; | 2190 wallet_server_validation_recoverable_ = true; |
| 2190 HidePopup(); | 2191 HidePopup(); |
| 2191 | 2192 |
| 2192 // This must come before SetIsSubmitting(). | 2193 // This must come before SetIsSubmitting(). |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2668 bool AutofillDialogControllerImpl::IsSignInContinueUrl( | 2669 bool AutofillDialogControllerImpl::IsSignInContinueUrl( |
| 2669 const GURL& url, | 2670 const GURL& url, |
| 2670 size_t* user_index) const { | 2671 size_t* user_index) const { |
| 2671 return wallet::IsSignInContinueUrl(url, user_index); | 2672 return wallet::IsSignInContinueUrl(url, user_index); |
| 2672 } | 2673 } |
| 2673 | 2674 |
| 2674 AutofillDialogControllerImpl::AutofillDialogControllerImpl( | 2675 AutofillDialogControllerImpl::AutofillDialogControllerImpl( |
| 2675 content::WebContents* contents, | 2676 content::WebContents* contents, |
| 2676 const FormData& form_structure, | 2677 const FormData& form_structure, |
| 2677 const GURL& source_url, | 2678 const GURL& source_url, |
| 2678 const base::Callback<void(const FormStructure*)>& callback) | 2679 const AutofillManagerDelegate::ResultCallback& callback) |
| 2679 : WebContentsObserver(contents), | 2680 : WebContentsObserver(contents), |
| 2680 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 2681 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
| 2681 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 2682 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
| 2682 form_structure_(form_structure), | 2683 form_structure_(form_structure), |
| 2683 invoked_from_same_origin_(true), | 2684 invoked_from_same_origin_(true), |
| 2684 source_url_(source_url), | 2685 source_url_(source_url), |
| 2685 callback_(callback), | 2686 callback_(callback), |
| 2686 wallet_client_(profile_->GetRequestContext(), this, source_url), | 2687 wallet_client_(profile_->GetRequestContext(), this, source_url), |
| 2687 wallet_items_requested_(false), | 2688 wallet_items_requested_(false), |
| 2688 handling_use_wallet_link_click_(false), | 2689 handling_use_wallet_link_click_(false), |
| (...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3743 if (!wallet_error_notification_ && | 3744 if (!wallet_error_notification_ && |
| 3744 account_chooser_model_->HasAccountsToChoose()) { | 3745 account_chooser_model_->HasAccountsToChoose()) { |
| 3745 profile_->GetPrefs()->SetBoolean( | 3746 profile_->GetPrefs()->SetBoolean( |
| 3746 ::prefs::kAutofillDialogPayWithoutWallet, | 3747 ::prefs::kAutofillDialogPayWithoutWallet, |
| 3747 !account_chooser_model_->WalletIsSelected()); | 3748 !account_chooser_model_->WalletIsSelected()); |
| 3748 } | 3749 } |
| 3749 | 3750 |
| 3750 LogOnFinishSubmitMetrics(); | 3751 LogOnFinishSubmitMetrics(); |
| 3751 | 3752 |
| 3752 // Callback should be called as late as possible. | 3753 // Callback should be called as late as possible. |
| 3753 callback_.Run(&form_structure_); | 3754 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, |
| 3755 &form_structure_); | |
| 3754 data_was_passed_back_ = true; | 3756 data_was_passed_back_ = true; |
| 3755 | 3757 |
| 3756 // This might delete us. | 3758 // This might delete us. |
| 3757 Hide(); | 3759 Hide(); |
| 3758 } | 3760 } |
| 3759 | 3761 |
| 3760 void AutofillDialogControllerImpl::PersistAutofillChoice( | 3762 void AutofillDialogControllerImpl::PersistAutofillChoice( |
| 3761 DialogSection section, | 3763 DialogSection section, |
| 3762 const std::string& guid) { | 3764 const std::string& guid) { |
| 3763 DCHECK(!IsPayingWithWallet() && ShouldOfferToSaveInChrome()); | 3765 DCHECK(!IsPayingWithWallet() && ShouldOfferToSaveInChrome()); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3948 view_->UpdateButtonStrip(); | 3950 view_->UpdateButtonStrip(); |
| 3949 } | 3951 } |
| 3950 | 3952 |
| 3951 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3953 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3952 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3954 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3953 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3955 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3954 signin_helper_->StartWalletCookieValueFetch(); | 3956 signin_helper_->StartWalletCookieValueFetch(); |
| 3955 } | 3957 } |
| 3956 | 3958 |
| 3957 } // namespace autofill | 3959 } // namespace autofill |
| OLD | NEW |