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 a8361dd678905e958c8e54b576d490f127ecd89e..4908e0a120b27c904a7daae0ec71e605f037a5cf 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
@@ -270,6 +270,15 @@ string16 AutofillDialogControllerImpl::CancelSignInText() const { |
return string16(ASCIIToUTF16("Don't sign in.")); |
} |
+bool AutofillDialogControllerImpl::IsSignedIn() const { |
+ return !HasRequiredAction(wallet::GAIA_AUTH) && |
+ !HasRequiredAction(wallet::PASSIVE_GAIA_AUTH); |
+} |
+ |
+bool AutofillDialogControllerImpl::HasReceivedWalletResponse() const { |
+ return wallet_items_.get() != NULL; |
+} |
+ |
string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
} |
@@ -513,37 +522,10 @@ void AutofillDialogControllerImpl::ViewClosed(DialogAction action) { |
} |
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)) { |
+ // TODO(dbeam): da real i18nz. |
+ return DialogNotification(DialogNotification::REQUIRED_ACTION, |
+ ASCIIToUTF16("Verify da CVVz")); |
} |
if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
@@ -636,8 +618,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); |
+ } |
} |
//////////////////////////////////////////////////////////////////////////////// |
@@ -676,6 +663,7 @@ void AutofillDialogControllerImpl::OnDidGetFullWallet( |
void AutofillDialogControllerImpl::OnDidGetWalletItems( |
scoped_ptr<wallet::WalletItems> wallet_items) { |
wallet_items_ = wallet_items.Pass(); |
+ view_->UpdateAccountChooser(); |
view_->UpdateNotificationArea(); |
} |
@@ -743,6 +731,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>& required = |
Ilya Sherman
2013/01/31 04:35:44
Optional nit: IMO "actions" is a slightly better s
Dan Beam
2013/01/31 21:04:26
Yeah, thought that actions + action was a little u
|
+ wallet_items_->required_actions(); |
+ return std::find(required.begin(), required.end(), action) != required.end(); |
+} |
+ |
void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
PersonalDataManager* manager = GetManager(); |
const std::vector<CreditCard*>& cards = manager->credit_cards(); |