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

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: 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 ac629abe137c2693fc0d754969057de220e6652a..0634108ef9d8cd584808f94b62c0a2d0a511a46b 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -462,12 +462,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();
@@ -529,7 +529,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()));
@@ -538,12 +538,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()));
@@ -607,9 +608,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 there is no accounts to choose from except the autofill data,
+ // there is no menu, just a sign in link.
Evan Stade 2013/03/29 23:08:45 comment is hard to follow. "Autofill data" is not
aruslan 2013/03/30 00:07:47 Done.
+ if (!account_chooser_model_.HasAccountsToChoose())
return NULL;
return &account_chooser_model_;
@@ -622,8 +623,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()),
Evan Stade 2013/03/29 23:08:45 isn't the checked item already an index? aren't in
aruslan 2013/03/30 00:07:47 Not anymore; do you suggest it should be? Command-
+ &icon);
return icon;
}
@@ -1040,6 +1043,7 @@ std::vector<DialogNotification>
}
void AutofillDialogControllerImpl::StartSignInFlow() {
+ DCHECK(!IsPayingWithWallet());
DCHECK(registrar_.IsEmpty());
content::Source<content::NavigationController> source(view_->ShowSignIn());
@@ -1158,8 +1162,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_.ForceWalletAccountSelected();
}
}
@@ -1216,7 +1222,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();
@@ -1225,7 +1231,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();
}
@@ -1333,14 +1339,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();
@@ -1393,14 +1404,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