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..21e4daf0b4f1676d85f4349560f4bc4a9c944c03 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 !RequiredActionApplies(wallet::GAIA_AUTH) && |
+ !RequiredActionApplies(wallet::PASSIVE_GAIA_AUTH); |
+} |
+ |
+bool AutofillDialogControllerImpl::HasReceivedWalletResponse() const { |
+ return wallet_items_; |
Ilya Sherman
2013/01/31 02:33:07
nit: Implicitly converting to a boolean is general
Dan Beam
2013/01/31 02:48:51
Done.
|
+} |
+ |
string16 AutofillDialogControllerImpl::SaveLocallyText() const { |
return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAVE_LOCALLY_CHECKBOX); |
} |
@@ -512,38 +521,17 @@ void AutofillDialogControllerImpl::ViewClosed(DialogAction action) { |
delete this; |
} |
+std::vector<wallet::RequiredAction> |
+ AutofillDialogControllerImpl::RequiredActions() const { |
+ return wallet_items_ ? wallet_items_->required_actions() : |
+ std::vector<wallet::RequiredAction>(); |
+} |
+ |
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 (RequiredActionApplies(wallet::VERIFY_CVV)) { |
+ // TODO(dbeam): da real i18nz. |
+ return DialogNotification(DialogNotification::REQUIRED_ACTION, |
+ ASCIIToUTF16("Verify da CVVz")); |
} |
if (RequestingCreditCardInfo() && !TransmissionWillBeSecure()) { |
@@ -636,8 +624,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 +669,7 @@ void AutofillDialogControllerImpl::OnDidGetFullWallet( |
void AutofillDialogControllerImpl::OnDidGetWalletItems( |
scoped_ptr<wallet::WalletItems> wallet_items) { |
wallet_items_ = wallet_items.Pass(); |
+ view_->UpdateAccountChooser(); |
view_->UpdateNotificationArea(); |
} |
@@ -743,6 +737,12 @@ bool AutofillDialogControllerImpl::TransmissionWillBeSecure() const { |
!net::IsCertStatusMinorError(ssl_status_.cert_status); |
} |
+bool AutofillDialogControllerImpl::RequiredActionApplies( |
+ wallet::RequiredAction action) const { |
+ const std::vector<wallet::RequiredAction>& required = RequiredActions(); |
+ return std::find(required.begin(), required.end(), action) != required.end(); |
+} |
+ |
void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
PersonalDataManager* manager = GetManager(); |
const std::vector<CreditCard*>& cards = manager->credit_cards(); |