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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 void AutofillDialogControllerImpl::HideSignIn() { | 683 void AutofillDialogControllerImpl::HideSignIn() { |
| 684 signin_registrar_.RemoveAll(); | 684 signin_registrar_.RemoveAll(); |
| 685 view_->HideSignIn(); | 685 view_->HideSignIn(); |
| 686 view_->UpdateAccountChooser(); | 686 view_->UpdateAccountChooser(); |
| 687 } | 687 } |
| 688 | 688 |
| 689 void AutofillDialogControllerImpl::SignedInStateUpdated() { | 689 void AutofillDialogControllerImpl::SignedInStateUpdated() { |
| 690 switch (SignedInState()) { | 690 switch (SignedInState()) { |
| 691 case SIGNED_IN: | 691 case SIGNED_IN: |
| 692 // Start fetching the user name if we don't know it yet. | 692 // Start fetching the user name if we don't know it yet. |
| 693 if (account_chooser_model_.active_wallet_account_name().empty()) { | 693 if (account_chooser_model_.active_wallet_account_name().empty()) { |
|
Dan Beam
2013/05/31 22:22:53
nit: and here (!account_chooser_model_.HasAccounts
Evan Stade
2013/05/31 22:41:10
The current code is logical and easy to make sense
| |
| 694 signin_helper_.reset(new wallet::WalletSigninHelper( | 694 signin_helper_.reset(new wallet::WalletSigninHelper( |
| 695 this, profile_->GetRequestContext())); | 695 this, profile_->GetRequestContext())); |
| 696 signin_helper_->StartUserNameFetch(); | 696 signin_helper_->StartUserNameFetch(); |
| 697 } else { | 697 } else { |
| 698 LogDialogLatencyToShow(); | 698 LogDialogLatencyToShow(); |
| 699 } | 699 } |
| 700 break; | 700 break; |
| 701 | 701 |
| 702 case REQUIRES_SIGN_IN: | 702 case REQUIRES_SIGN_IN: |
| 703 case SIGN_IN_DISABLED: | 703 case SIGN_IN_DISABLED: |
| (...skipping 22 matching lines...) Expand all 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 1206 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()) { |
|
Dan Beam
2013/05/31 22:22:53
nit: account_chooser_model_.HasAccountsToChoose()
Evan Stade
2013/05/31 22:41:10
Done.
| |
| 2697 manually_selected_pay_without_wallet); | 2697 profile_->GetPrefs()->SetBoolean( |
| 2698 ::prefs::kAutofillDialogPayWithoutWallet, | |
| 2699 !account_chooser_model_.WalletIsSelected()); | |
| 2700 } | |
| 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 |