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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 UpdateAccountChooserView(); | 726 UpdateAccountChooserView(); |
| 727 | 727 |
| 728 if (view_) | 728 if (view_) |
| 729 view_->UpdateButtonStrip(); | 729 view_->UpdateButtonStrip(); |
| 730 | 730 |
| 731 // On the first successful response, compute the initial user state metric. | 731 // On the first successful response, compute the initial user state metric. |
| 732 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) | 732 if (initial_user_state_ == AutofillMetrics::DIALOG_USER_STATE_UNKNOWN) |
| 733 initial_user_state_ = GetInitialUserState(); | 733 initial_user_state_ = GetInitialUserState(); |
| 734 } | 734 } |
| 735 | 735 |
| 736 void AutofillDialogControllerImpl::OnWalletSigninError() { | |
| 737 signin_helper_.reset(); | |
| 738 account_chooser_model_.SetHadWalletSigninError(); | |
| 739 GetWalletClient()->CancelRequests(); | |
| 740 LogDialogLatencyToShow(); | |
| 741 } | |
| 742 | |
| 743 void AutofillDialogControllerImpl::EnsureLegalDocumentsText() { | 736 void AutofillDialogControllerImpl::EnsureLegalDocumentsText() { |
| 744 if (!wallet_items_ || wallet_items_->legal_documents().empty()) | 737 if (!wallet_items_ || wallet_items_->legal_documents().empty()) |
| 745 return; | 738 return; |
| 746 | 739 |
| 747 // The text has already been constructed, no need to recompute. | 740 // The text has already been constructed, no need to recompute. |
| 748 if (!legal_documents_text_.empty()) | 741 if (!legal_documents_text_.empty()) |
| 749 return; | 742 return; |
| 750 | 743 |
| 751 const std::vector<wallet::WalletItems::LegalDocument*>& documents = | 744 const std::vector<wallet::WalletItems::LegalDocument*>& documents = |
| 752 wallet_items_->legal_documents(); | 745 wallet_items_->legal_documents(); |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1800 | 1793 |
| 1801 SuggestionsUpdated(); | 1794 SuggestionsUpdated(); |
| 1802 } | 1795 } |
| 1803 | 1796 |
| 1804 //////////////////////////////////////////////////////////////////////////////// | 1797 //////////////////////////////////////////////////////////////////////////////// |
| 1805 // AccountChooserModelDelegate implementation. | 1798 // AccountChooserModelDelegate implementation. |
| 1806 | 1799 |
| 1807 void AutofillDialogControllerImpl::AccountChoiceChanged() { | 1800 void AutofillDialogControllerImpl::AccountChoiceChanged() { |
| 1808 if (is_submitting_) | 1801 if (is_submitting_) |
| 1809 GetWalletClient()->CancelRequests(); | 1802 GetWalletClient()->CancelRequests(); |
| 1810 | 1803 |
|
Dan Beam
2013/05/31 00:21:55
why not just detect the change here?
| |
| 1811 SetIsSubmitting(false); | 1804 SetIsSubmitting(false); |
| 1812 | 1805 |
| 1813 SuggestionsUpdated(); | 1806 SuggestionsUpdated(); |
| 1814 UpdateAccountChooserView(); | 1807 UpdateAccountChooserView(); |
| 1815 } | 1808 } |
| 1816 | 1809 |
| 1817 void AutofillDialogControllerImpl::UpdateAccountChooserView() { | 1810 void AutofillDialogControllerImpl::UpdateAccountChooserView() { |
| 1818 if (view_) { | 1811 if (view_) { |
| 1819 view_->UpdateAccountChooser(); | 1812 view_->UpdateAccountChooser(); |
| 1820 view_->UpdateNotificationArea(); | 1813 view_->UpdateNotificationArea(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1959 chrome::FindBrowserWithWebContents(web_contents()), | 1952 chrome::FindBrowserWithWebContents(web_contents()), |
| 1960 url, | 1953 url, |
| 1961 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 1954 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 1962 params.disposition = NEW_FOREGROUND_TAB; | 1955 params.disposition = NEW_FOREGROUND_TAB; |
| 1963 chrome::Navigate(¶ms); | 1956 chrome::Navigate(¶ms); |
| 1964 #else | 1957 #else |
| 1965 // TODO(estade): use TabModelList? | 1958 // TODO(estade): use TabModelList? |
| 1966 #endif | 1959 #endif |
| 1967 } | 1960 } |
| 1968 | 1961 |
| 1962 void AutofillDialogControllerImpl::OnWalletSigninError() { | |
| 1963 signin_helper_.reset(); | |
| 1964 account_chooser_model_.SetHadWalletSigninError(); | |
| 1965 GetWalletClient()->CancelRequests(); | |
| 1966 LogDialogLatencyToShow(); | |
| 1967 } | |
| 1968 | |
| 1969 void AutofillDialogControllerImpl::DisableWallet() { | 1969 void AutofillDialogControllerImpl::DisableWallet() { |
| 1970 signin_helper_.reset(); | 1970 signin_helper_.reset(); |
| 1971 wallet_items_.reset(); | 1971 wallet_items_.reset(); |
| 1972 GetWalletClient()->CancelRequests(); | 1972 GetWalletClient()->CancelRequests(); |
| 1973 SetIsSubmitting(false); | 1973 SetIsSubmitting(false); |
| 1974 account_chooser_model_.SetHadWalletError(); | 1974 account_chooser_model_.SetHadWalletError(); |
| 1975 } | 1975 } |
| 1976 | 1976 |
| 1977 void AutofillDialogControllerImpl::SuggestionsUpdated() { | 1977 void AutofillDialogControllerImpl::SuggestionsUpdated() { |
| 1978 suggested_email_.Reset(); | 1978 suggested_email_.Reset(); |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2682 } | 2682 } |
| 2683 } | 2683 } |
| 2684 | 2684 |
| 2685 callback_.Run(&form_structure_, !wallet_items_ ? std::string() : | 2685 callback_.Run(&form_structure_, !wallet_items_ ? std::string() : |
| 2686 wallet_items_->google_transaction_id()); | 2686 wallet_items_->google_transaction_id()); |
| 2687 callback_ = base::Callback<void(const FormStructure*, const std::string&)>(); | 2687 callback_ = base::Callback<void(const FormStructure*, const std::string&)>(); |
| 2688 | 2688 |
| 2689 LogOnFinishSubmitMetrics(); | 2689 LogOnFinishSubmitMetrics(); |
| 2690 | 2690 |
| 2691 // On a successful submit, if the user manually selected "pay without wallet", | 2691 // On a successful submit, if the user manually selected "pay without wallet", |
| 2692 // stop trying to pay with Wallet on future runs of the dialog. | 2692 // stop trying to pay with Wallet on future runs of the dialog. On the other |
| 2693 bool manually_selected_pay_without_wallet = | 2693 // hand, if there was an error that prevented the user from having the choice |
| 2694 !account_chooser_model_.WalletIsSelected() && | 2694 // of using Wallet, leave the pref alone. |
| 2695 !account_chooser_model_.had_wallet_error(); | 2695 if (!account_chooser_model_.had_wallet_error() && |
| 2696 profile_->GetPrefs()->SetBoolean(::prefs::kAutofillDialogPayWithoutWallet, | 2696 !account_chooser_model_.active_wallet_account_name().empty()) { |
| 2697 manually_selected_pay_without_wallet); | 2697 profile_->GetPrefs()->SetBoolean( |
|
Dan Beam
2013/05/31 00:21:55
don't we use this to determine if it's first run?
| |
| 2698 ::prefs::kAutofillDialogPayWithoutWallet, | |
| 2699 !account_chooser_model_.WalletIsSelected()); | |
| 2700 } | |
|
Dan Beam
2013/05/31 00:21:55
and ensure this pref is set to its current value h
Evan Stade
2013/05/31 02:47:33
it seems better to stop making this pref pull doub
Evan Stade
2013/05/31 03:12:29
filed https://code.google.com/p/chromium/issues/de
| |
| 2698 | 2701 |
| 2699 switch (GetDialogType()) { | 2702 switch (GetDialogType()) { |
| 2700 case DIALOG_TYPE_AUTOCHECKOUT: | 2703 case DIALOG_TYPE_AUTOCHECKOUT: |
| 2701 // Stop observing PersonalDataManager to avoid the dialog redrawing while | 2704 // Stop observing PersonalDataManager to avoid the dialog redrawing while |
| 2702 // in an Autocheckout flow. | 2705 // in an Autocheckout flow. |
| 2703 GetManager()->RemoveObserver(this); | 2706 GetManager()->RemoveObserver(this); |
| 2704 autocheckout_started_timestamp_ = base::Time::Now(); | 2707 autocheckout_started_timestamp_ = base::Time::Now(); |
| 2705 DCHECK_EQ(AUTOCHECKOUT_NOT_STARTED, autocheckout_state_); | 2708 DCHECK_EQ(AUTOCHECKOUT_NOT_STARTED, autocheckout_state_); |
| 2706 autocheckout_state_ = AUTOCHECKOUT_IN_PROGRESS; | 2709 autocheckout_state_ = AUTOCHECKOUT_IN_PROGRESS; |
| 2707 view_->UpdateButtonStrip(); | 2710 view_->UpdateButtonStrip(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2876 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2879 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
| 2877 } | 2880 } |
| 2878 | 2881 |
| 2879 // Has Wallet items. | 2882 // Has Wallet items. |
| 2880 return has_autofill_profiles ? | 2883 return has_autofill_profiles ? |
| 2881 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2884 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
| 2882 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2885 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
| 2883 } | 2886 } |
| 2884 | 2887 |
| 2885 } // namespace autofill | 2888 } // namespace autofill |
| OLD | NEW |