Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 13331007: Multi-account AccountChooser for interactive autocomplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent fix. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 bd8de230258c6684ab15acc0f9c0235a9b524ea4..ce59ea0b8c6300e5ff532f87afe0127d19a3fdec 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -469,12 +469,12 @@ bool AutofillDialogControllerImpl::ShouldShowSpinner() const {
}
string16 AutofillDialogControllerImpl::AccountChooserText() const {
+ // TODO(aruslan): this should be l10n "Not using Google Wallet".
if (!IsPayingWithWallet())
return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PAY_WITHOUT_WALLET);
- // TODO(dbeam): real strings and l10n.
if (SignedInState() == SIGNED_IN)
- return ASCIIToUTF16(current_username_);
+ return ASCIIToUTF16(account_chooser_model_.GetCurrentlySignedInAccount());
// In this case, the account chooser should be showing the signin link.
return string16();
@@ -542,7 +542,7 @@ void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() {
switch (SignedInState()) {
case SIGNED_IN:
// Start fetching the user name if we don't know it yet.
- if (current_username_.empty()) {
+ if (account_chooser_model_.GetCurrentlySignedInAccount().empty()) {
signin_helper_.reset(new wallet::WalletSigninHelper(
this,
profile_->GetRequestContext()));
@@ -551,12 +551,13 @@ void AutofillDialogControllerImpl::OnWalletOrSigninUpdate() {
break;
case REQUIRES_SIGN_IN:
- // TODO(aruslan): automatic sign-in?
+ // Switch to the local account and refresh the dialog.
+ OnWalletSigninError();
break;
case REQUIRES_PASSIVE_SIGN_IN:
// Attempt to passively sign in the user.
- current_username_.clear();
+ account_chooser_model_.ResetCurrentlySignedInAccount();
signin_helper_.reset(new wallet::WalletSigninHelper(
this,
profile_->GetRequestContext()));
@@ -661,9 +662,9 @@ ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection(
}
ui::MenuModel* AutofillDialogControllerImpl::MenuModelForAccountChooser() {
- // When paying with wallet, but not signed in, there is no menu, just a
- // sign in link.
- if (IsPayingWithWallet() && SignedInState() != SIGNED_IN)
+ // If the only choice is "Pay without the wallet", there is no menu, just
+ // a sign in link.
+ if (!account_chooser_model_.HasAccountsToChoose())
return NULL;
return &account_chooser_model_;
@@ -676,8 +677,10 @@ gfx::Image AutofillDialogControllerImpl::AccountChooserImage() {
}
gfx::Image icon;
- account_chooser_model_.GetIconAt(account_chooser_model_.checked_item(),
- &icon);
+ account_chooser_model_.GetIconAt(
+ account_chooser_model_.GetIndexOfCommandId(
+ account_chooser_model_.checked_item()),
+ &icon);
return icon;
}
@@ -1103,6 +1106,7 @@ std::vector<DialogNotification>
}
void AutofillDialogControllerImpl::StartSignInFlow() {
+ DCHECK(!IsPayingWithWallet());
DCHECK(registrar_.IsEmpty());
content::Source<content::NavigationController> source(view_->ShowSignIn());
@@ -1243,8 +1247,10 @@ void AutofillDialogControllerImpl::Observe(
content::Details<content::LoadCommittedDetails>(details).ptr();
if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) {
EndSignInFlow();
- if (IsPayingWithWallet())
- StartFetchingWalletItems();
+ // The sign-in flow means that the user implicitly switched the account
+ // to the Wallet. This will trigger AccountChoiceChanged.
+ DCHECK(!IsPayingWithWallet());
+ account_chooser_model_.ForceSelectWalletAccount();
}
}
@@ -1300,7 +1306,7 @@ void AutofillDialogControllerImpl::OnDidGetFullWallet(
void AutofillDialogControllerImpl::OnPassiveSigninSuccess(
const std::string& username) {
DCHECK(IsPayingWithWallet());
- current_username_ = username;
+ account_chooser_model_.SetCurrentlySignedInAccount(username);
signin_helper_.reset();
wallet_items_.reset();
StartFetchingWalletItems();
@@ -1309,7 +1315,7 @@ void AutofillDialogControllerImpl::OnPassiveSigninSuccess(
void AutofillDialogControllerImpl::OnUserNameFetchSuccess(
const std::string& username) {
DCHECK(IsPayingWithWallet());
- current_username_ = username;
+ account_chooser_model_.SetCurrentlySignedInAccount(username);
signin_helper_.reset();
OnWalletOrSigninUpdate();
}
@@ -1415,14 +1421,19 @@ void AutofillDialogControllerImpl::AccountChoiceChanged() {
if (!view_)
return;
- // Whenever the user changes the current account, the Wallet data should be
- // cleared. If the user has chosen a Wallet account, an attempt to fetch
- // the Wallet data is made to see if the user is still signed in.
- // This will trigger a passive sign-in if required.
- // TODO(aruslan): integrate an automatic sign-in.
+ // The Wallet data should be cleared when the user switches accounts.
wallet_items_.reset();
- if (IsPayingWithWallet())
- StartFetchingWalletItems();
+ if (IsPayingWithWallet()) {
+ if (account_chooser_model_.IsCurrentlySignedInAccountSelected()) {
+ // If the user has chosen a content-area Wallet account, an attempt to
+ // fetch the Wallet data is made to see if the user is still signed in.
+ // This will trigger a passive sign-in if required.
+ StartFetchingWalletItems();
+ } else {
+ // TODO(aruslan): integrate an automatic sign-in.
+ OnWalletSigninError();
+ }
+ }
GenerateSuggestionsModels();
view_->ModelChanged();
@@ -1475,14 +1486,12 @@ bool AutofillDialogControllerImpl::IsPayingWithWallet() const {
void AutofillDialogControllerImpl::DisableWallet() {
signin_helper_.reset();
- current_username_.clear();
account_chooser_model_.SetHadWalletError();
GetWalletClient()->CancelPendingRequests();
}
void AutofillDialogControllerImpl::OnWalletSigninError() {
signin_helper_.reset();
- current_username_.clear();
account_chooser_model_.SetHadWalletSigninError();
GetWalletClient()->CancelPendingRequests();
}

Powered by Google App Engine
This is Rietveld 408576698