Chromium Code Reviews| 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 daa407d0797070433b26f7cc3908bde55a3aa622..8f28edd339e307c3559555b65b6c8f40ecc189d0 100644 |
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
| @@ -91,6 +91,10 @@ const char kAddNewItemKey[] = "add-new-item"; |
| const char kManageItemsKey[] = "manage-items"; |
| const char kSameAsBillingKey[] = "same-as-billing"; |
| +// URLs for Wallet error messages. |
| +const char kBlaStatusUrl[] = "https://wallet.google.com/manage/settings"; |
| +const char kKycStatusUrl[] = "https://wallet.google.com/kyc"; |
|
Ilya Sherman
2013/08/29 00:26:11
nit: Please eschew acronyms like "bla" and "kyc" i
Evan Stade
2013/08/30 02:52:21
Done.
|
| + |
| // Keys for the kAutofillDialogAutofillDefault pref dictionary (do not change |
| // these values). |
| const char kGuidPrefKey[] = "guid"; |
| @@ -350,61 +354,102 @@ DialogSection SectionFromLocation(wallet::FormFieldError::Location location) { |
| return SECTION_MAX; |
| } |
| -base::string16 WalletErrorMessage(wallet::WalletClient::ErrorType error_type) { |
| +scoped_ptr<DialogNotification> GetWalletError( |
| + wallet::WalletClient::ErrorType error_type) { |
| + base::string16 text; |
| + GURL url; |
| + |
| switch (error_type) { |
| - case wallet::WalletClient::BUYER_ACCOUNT_ERROR: |
| - return l10n_util::GetStringUTF16(IDS_AUTOFILL_WALLET_BUYER_ACCOUNT_ERROR); |
| + case wallet::WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS: |
| + text = l10n_util::GetStringUTF16( |
| + IDS_AUTOFILL_WALLET_UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS); |
| + url = GURL(kKycStatusUrl); |
| + break; |
| case wallet::WalletClient::BUYER_LEGAL_ADDRESS_NOT_SUPPORTED: |
| - return l10n_util::GetStringUTF16( |
| + text = l10n_util::GetStringUTF16( |
| IDS_AUTOFILL_WALLET_BUYER_COUNTRY_NOT_SUPPORTED); |
| + url = GURL(kBlaStatusUrl); |
| + break; |
| + |
| + default: |
| + break; |
|
Ilya Sherman
2013/08/29 00:26:11
nit: This looks a little weird without a comment.
Evan Stade
2013/08/30 02:52:21
Done.
|
| + } |
| + |
| + if (!text.empty()) { |
| + scoped_ptr<DialogNotification> notification(new DialogNotification( |
| + DialogNotification::WALLET_ERROR, |
| + text)); |
| + notification->set_link_url(url); |
| + return notification.Pass(); |
| + } |
| + switch (error_type) { |
| case wallet::WalletClient::UNSUPPORTED_MERCHANT: |
| - return l10n_util::GetStringUTF16( |
| + text = l10n_util::GetStringUTF16( |
| IDS_AUTOFILL_WALLET_UNSUPPORTED_MERCHANT); |
| + break; |
| case wallet::WalletClient::BAD_REQUEST: |
| - return l10n_util::GetStringFUTF16( |
| + text = l10n_util::GetStringFUTF16( |
| IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR, |
| ASCIIToUTF16("71")); |
| + break; |
| case wallet::WalletClient::INVALID_PARAMS: |
| - return l10n_util::GetStringFUTF16( |
| + text = l10n_util::GetStringFUTF16( |
| IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR, |
| ASCIIToUTF16("42")); |
| + break; |
| - case wallet::WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS: |
| - return l10n_util::GetStringUTF16( |
| - IDS_AUTOFILL_WALLET_UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS); |
| + case wallet::WalletClient::BUYER_ACCOUNT_ERROR: |
| + text = l10n_util::GetStringUTF16(IDS_AUTOFILL_WALLET_BUYER_ACCOUNT_ERROR); |
| + break; |
| case wallet::WalletClient::UNSUPPORTED_API_VERSION: |
| - return l10n_util::GetStringFUTF16( |
| + text = l10n_util::GetStringFUTF16( |
| IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR, |
| ASCIIToUTF16("43")); |
| + break; |
| case wallet::WalletClient::SERVICE_UNAVAILABLE: |
| - return l10n_util::GetStringUTF16( |
| + text = l10n_util::GetStringUTF16( |
| IDS_AUTOFILL_WALLET_SERVICE_UNAVAILABLE_ERROR); |
| + break; |
| case wallet::WalletClient::INTERNAL_ERROR: |
| - return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| + text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| ASCIIToUTF16("62")); |
| + break; |
| case wallet::WalletClient::MALFORMED_RESPONSE: |
| - return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| + text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| ASCIIToUTF16("72")); |
| + break; |
| case wallet::WalletClient::NETWORK_ERROR: |
| - return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| + text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| ASCIIToUTF16("73")); |
| + break; |
| case wallet::WalletClient::UNKNOWN_ERROR: |
| - return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| + text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, |
| ASCIIToUTF16("74")); |
| + break; |
| + |
| + default: |
| + break; |
| } |
| - NOTREACHED(); |
| - return base::string16(); |
| + if (text.empty()) |
| + NOTREACHED(); |
|
Ilya Sherman
2013/08/29 00:26:11
nit: DCHECK(!text.empty());
Evan Stade
2013/08/30 02:52:21
Done.
|
| + |
| + // The other error types are strings of the form "XXX. You can pay without |
| + // wallet." |
| + return scoped_ptr<DialogNotification>(new DialogNotification( |
|
Ilya Sherman
2013/08/29 00:26:11
nit: make_scoped_ptr
Evan Stade
2013/08/30 02:52:21
Done.
|
| + DialogNotification::WALLET_ERROR, |
| + l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, |
| + text))); |
| } |
| gfx::Image GetGeneratedCardImage(const string16& card_number) { |
| @@ -1828,14 +1873,9 @@ std::vector<DialogNotification> AutofillDialogControllerImpl:: |
| UTF8ToUTF16(source_url_.host())))); |
| } |
| - if (account_chooser_model_.HadWalletError()) { |
| - // TODO(dbeam): figure out a way to dismiss this error after a while. |
| - notifications.push_back(DialogNotification( |
| - DialogNotification::WALLET_ERROR, |
| - l10n_util::GetStringFUTF16( |
| - IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET, |
| - account_chooser_model_.wallet_error_message()))); |
| - } |
| + // TODO(dbeam): figure out a way to dismiss this error after a while. |
| + if (wallet_error_notification_) |
| + notifications.push_back(*wallet_error_notification_); |
| if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
| notifications.push_back(DialogNotification( |
| @@ -2473,7 +2513,8 @@ void AutofillDialogControllerImpl::DisableWallet( |
| } |
| } |
| SetIsSubmitting(false); |
| - account_chooser_model_.SetHadWalletError(WalletErrorMessage(error_type)); |
| + wallet_error_notification_ = GetWalletError(error_type); |
| + account_chooser_model_.SetHadWalletError(); |
| } |
| void AutofillDialogControllerImpl::SuggestionsUpdated() { |