| Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| index 5c1bfecd0cec099d7e18e8361d11377889798b8f..5fa1a8a4cf932173e855d3fc09b40a7a8eafe7d4 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| @@ -698,12 +698,11 @@ void AutofillDialogControllerImpl::Show() {
|
| // Try to see if the user is already signed-in. If signed-in, fetch the user's
|
| // Wallet data. Otherwise, see if the user could be signed in passively.
|
| // TODO(aruslan): UMA metrics for sign-in.
|
| - signin_helper_.reset(new wallet::WalletSigninHelper(
|
| - this, profile_->GetRequestContext()));
|
| - signin_helper_->StartWalletCookieValueFetch();
|
| + FetchWalletCookieAndUserName();
|
|
|
| - if (!account_chooser_model_.WalletIsSelected())
|
| + if (!account_chooser_model_.WalletIsSelected()) {
|
| LogDialogLatencyToShow();
|
| + }
|
| }
|
|
|
| void AutofillDialogControllerImpl::Hide() {
|
| @@ -978,7 +977,7 @@ AutofillDialogControllerImpl::DialogSignedInState
|
| if (wallet_error_notification_)
|
| return SIGN_IN_DISABLED;
|
|
|
| - if (signin_helper_ || !wallet_items_)
|
| + if (signin_helper_ || username_fetcher_ || !wallet_items_)
|
| return REQUIRES_RESPONSE;
|
|
|
| if (wallet_items_->HasRequiredAction(wallet::GAIA_AUTH))
|
| @@ -995,9 +994,9 @@ void AutofillDialogControllerImpl::SignedInStateUpdated() {
|
| case SIGNED_IN:
|
| // Start fetching the user name if we don't know it yet.
|
| if (account_chooser_model_.active_wallet_account_name().empty()) {
|
| - signin_helper_.reset(new wallet::WalletSigninHelper(
|
| + username_fetcher_.reset(new wallet::WalletSigninHelper(
|
| this, profile_->GetRequestContext()));
|
| - signin_helper_->StartUserNameFetch();
|
| + username_fetcher_->StartUserNameFetch();
|
| } else {
|
| LogDialogLatencyToShow();
|
| }
|
| @@ -1010,9 +1009,12 @@ void AutofillDialogControllerImpl::SignedInStateUpdated() {
|
| break;
|
|
|
| case REQUIRES_PASSIVE_SIGN_IN:
|
| + // Cancel any pending username fetch and clear any stale username data.
|
| + username_fetcher_.reset();
|
| + account_chooser_model_.ClearActiveWalletAccountName();
|
| +
|
| // Attempt to passively sign in the user.
|
| DCHECK(!signin_helper_);
|
| - account_chooser_model_.ClearActiveWalletAccountName();
|
| signin_helper_.reset(new wallet::WalletSigninHelper(
|
| this,
|
| profile_->GetRequestContext()));
|
| @@ -2107,9 +2109,7 @@ void AutofillDialogControllerImpl::Observe(
|
| if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) {
|
| should_show_wallet_promo_ = false;
|
| account_chooser_model_.SelectActiveWalletAccount();
|
| - signin_helper_.reset(new wallet::WalletSigninHelper(
|
| - this, profile_->GetRequestContext()));
|
| - signin_helper_->StartWalletCookieValueFetch();
|
| + FetchWalletCookieAndUserName();
|
| HideSignIn();
|
| }
|
| }
|
| @@ -2233,7 +2233,7 @@ void AutofillDialogControllerImpl::OnUserNameFetchSuccess(
|
| const std::string& username) {
|
| ScopedViewUpdates updates(view_.get());
|
| const string16 username16 = UTF8ToUTF16(username);
|
| - signin_helper_.reset();
|
| + username_fetcher_.reset();
|
| account_chooser_model_.SetActiveWalletAccountName(username16);
|
| OnWalletOrSigninUpdate();
|
| }
|
| @@ -2242,6 +2242,7 @@ void AutofillDialogControllerImpl::OnPassiveSigninFailure(
|
| const GoogleServiceAuthError& error) {
|
| // TODO(aruslan): report an error.
|
| LOG(ERROR) << "failed to passively sign in: " << error.ToString();
|
| + signin_helper_.reset();
|
| OnWalletSigninError();
|
| }
|
|
|
| @@ -2249,7 +2250,13 @@ void AutofillDialogControllerImpl::OnUserNameFetchFailure(
|
| const GoogleServiceAuthError& error) {
|
| // TODO(aruslan): report an error.
|
| LOG(ERROR) << "failed to fetch the user account name: " << error.ToString();
|
| - OnWalletSigninError();
|
| + username_fetcher_.reset();
|
| + // Only treat the failed fetch as an error if the user is known to already be
|
| + // signed in. Attempting to fetch the username prior to loading the
|
| + // |wallet_items_| is purely a performance optimization that shouldn't be
|
| + // treated as an error if it fails.
|
| + if (wallet_items_)
|
| + OnWalletSigninError();
|
| }
|
|
|
| void AutofillDialogControllerImpl::OnDidFetchWalletCookieValue(
|
| @@ -2488,7 +2495,6 @@ bool AutofillDialogControllerImpl::IsManuallyEditingSection(
|
| }
|
|
|
| void AutofillDialogControllerImpl::OnWalletSigninError() {
|
| - signin_helper_.reset();
|
| account_chooser_model_.SetHadWalletSigninError();
|
| GetWalletClient()->CancelRequests();
|
| LogDialogLatencyToShow();
|
| @@ -2497,6 +2503,7 @@ void AutofillDialogControllerImpl::OnWalletSigninError() {
|
| void AutofillDialogControllerImpl::DisableWallet(
|
| wallet::WalletClient::ErrorType error_type) {
|
| signin_helper_.reset();
|
| + username_fetcher_.reset();
|
| wallet_items_.reset();
|
| wallet_errors_.clear();
|
| GetWalletClient()->CancelRequests();
|
| @@ -3423,4 +3430,14 @@ void AutofillDialogControllerImpl::OnSubmitButtonDelayEnd() {
|
| view_->UpdateButtonStrip();
|
| }
|
|
|
| +void AutofillDialogControllerImpl::FetchWalletCookieAndUserName() {
|
| + net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
|
| + signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
|
| + signin_helper_->StartWalletCookieValueFetch();
|
| +
|
| + username_fetcher_.reset(
|
| + new wallet::WalletSigninHelper(this, request_context));
|
| + username_fetcher_->StartUserNameFetch();
|
| +}
|
| +
|
| } // namespace autofill
|
|
|