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

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

Issue 12094069: [autofill] Hook the sign-in button up to required actions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bored Created 7 years, 11 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 59a68e9287fd9a750ea24edfbd6d660d78951d2b..2979422fa413ad12555b07dae5a79d4e4249d701 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -270,6 +270,19 @@ string16 AutofillDialogControllerImpl::CancelSignInText() const {
return string16(ASCIIToUTF16("Don't sign in."));
}
+DialogSignedInState AutofillDialogControllerImpl::SignedIn() const {
+ if (!wallet_items_)
+ return REQUIRES_RESPONSE;
+
+ if (HasRequiredAction(wallet::GAIA_AUTH))
+ return REQUIRES_SIGN_IN;
+
+ if (HasRequiredAction(wallet::PASSIVE_GAIA_AUTH))
+ return REQUIRES_PASSIVE_SIGN_IN;
+
+ return SIGNED_IN;
+}
+
string16 AutofillDialogControllerImpl::SaveLocallyText() const {
return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX);
}
@@ -522,37 +535,10 @@ void AutofillDialogControllerImpl::UpdateProgressBar(double value) {
}
DialogNotification AutofillDialogControllerImpl::CurrentNotification() const {
- if (wallet_items_ && !wallet_items_->required_actions().empty()) {
- switch (wallet_items_->required_actions()[0]) {
- case wallet::UNKNOWN_TYPE:
- NOTREACHED();
- break;
- // TODO(dbeam): da real i18nz.
- case wallet::SETUP_WALLET:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Set up da walletz"));
- case wallet::ACCEPT_TOS:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Accept da ToS"));
- case wallet::GAIA_AUTH:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Sign in to da Googlez"));
- case wallet::UPDATE_EXPIRATION_DATE:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Update da expiration datez"));
- case wallet::UPGRADE_MIN_ADDRESS:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Upgrade da min addrezz"));
- case wallet::INVALID_FORM_FIELD:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Da form field is invalid"));
- case wallet::VERIFY_CVV:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Verify da CVVz"));
- case wallet::PASSIVE_GAIA_AUTH:
- return DialogNotification(DialogNotification::REQUIRED_ACTION,
- ASCIIToUTF16("Passively sign in to Googlez"));
- }
+ if (HasRequiredAction(wallet::VERIFY_CVV)) {
+ return DialogNotification(
+ DialogNotification::REQUIRED_ACTION,
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV));
}
if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) {
@@ -645,8 +631,13 @@ void AutofillDialogControllerImpl::Observe(
DCHECK_EQ(type, content::NOTIFICATION_NAV_ENTRY_COMMITTED);
content::LoadCommittedDetails* load_details =
content::Details<content::LoadCommittedDetails>(details).ptr();
- if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL()))
+ if (wallet::IsSignInContinueUrl(load_details->entry->GetVirtualURL())) {
EndSignInFlow();
+ // TODO(dbeam): the fetcher can't handle being called multiple times.
+ // Address this soon as we will be re-fetching wallet items after every
+ // required action is resolved.
+ wallet_client_.GetWalletItems(this);
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -685,6 +676,7 @@ void AutofillDialogControllerImpl::OnDidGetFullWallet(
void AutofillDialogControllerImpl::OnDidGetWalletItems(
scoped_ptr<wallet::WalletItems> wallet_items) {
wallet_items_ = wallet_items.Pass();
+ view_->UpdateAccountChooser();
view_->UpdateNotificationArea();
}
@@ -752,6 +744,16 @@ bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const {
!net::IsCertStatusMinorError(ssl_status_.cert_status);
}
+bool AutofillDialogControllerImpl::HasRequiredAction(
+ wallet::RequiredAction action) const {
+ if (!wallet_items_)
+ return false;
+
+ const std::vector<wallet::RequiredAction>& actions =
+ wallet_items_->required_actions();
+ return std::find(actions.begin(), actions.end(), action) != actions.end();
+}
+
void AutofillDialogControllerImpl::GenerateSuggestionsModels() {
PersonalDataManager* manager = GetManager();
const std::vector<CreditCard*>& cards = manager->credit_cards();

Powered by Google App Engine
This is Rietveld 408576698