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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 23495006: rAc: better Wallet error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #include "ui/gfx/skbitmap_operations.h" 84 #include "ui/gfx/skbitmap_operations.h"
85 85
86 namespace autofill { 86 namespace autofill {
87 87
88 namespace { 88 namespace {
89 89
90 const char kAddNewItemKey[] = "add-new-item"; 90 const char kAddNewItemKey[] = "add-new-item";
91 const char kManageItemsKey[] = "manage-items"; 91 const char kManageItemsKey[] = "manage-items";
92 const char kSameAsBillingKey[] = "same-as-billing"; 92 const char kSameAsBillingKey[] = "same-as-billing";
93 93
94 // URLs for Wallet error messages.
95 const char kBlaStatusUrl[] = "https://wallet.google.com/manage/settings";
96 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.
97
94 // Keys for the kAutofillDialogAutofillDefault pref dictionary (do not change 98 // Keys for the kAutofillDialogAutofillDefault pref dictionary (do not change
95 // these values). 99 // these values).
96 const char kGuidPrefKey[] = "guid"; 100 const char kGuidPrefKey[] = "guid";
97 const char kVariantPrefKey[] = "variant"; 101 const char kVariantPrefKey[] = "variant";
98 102
99 // This string is stored along with saved addresses and credit cards in the 103 // This string is stored along with saved addresses and credit cards in the
100 // WebDB, and hence should not be modified, so that it remains consistent over 104 // WebDB, and hence should not be modified, so that it remains consistent over
101 // time. 105 // time.
102 const char kAutofillDialogOrigin[] = "Chrome Autofill dialog"; 106 const char kAutofillDialogOrigin[] = "Chrome Autofill dialog";
103 107
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 347
344 case wallet::FormFieldError::UNKNOWN_LOCATION: 348 case wallet::FormFieldError::UNKNOWN_LOCATION:
345 NOTREACHED(); 349 NOTREACHED();
346 return SECTION_MAX; 350 return SECTION_MAX;
347 } 351 }
348 352
349 NOTREACHED(); 353 NOTREACHED();
350 return SECTION_MAX; 354 return SECTION_MAX;
351 } 355 }
352 356
353 base::string16 WalletErrorMessage(wallet::WalletClient::ErrorType error_type) { 357 scoped_ptr<DialogNotification> GetWalletError(
358 wallet::WalletClient::ErrorType error_type) {
359 base::string16 text;
360 GURL url;
361
354 switch (error_type) { 362 switch (error_type) {
355 case wallet::WalletClient::BUYER_ACCOUNT_ERROR: 363 case wallet::WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS:
356 return l10n_util::GetStringUTF16(IDS_AUTOFILL_WALLET_BUYER_ACCOUNT_ERROR); 364 text = l10n_util::GetStringUTF16(
365 IDS_AUTOFILL_WALLET_UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS);
366 url = GURL(kKycStatusUrl);
367 break;
357 368
358 case wallet::WalletClient::BUYER_LEGAL_ADDRESS_NOT_SUPPORTED: 369 case wallet::WalletClient::BUYER_LEGAL_ADDRESS_NOT_SUPPORTED:
359 return l10n_util::GetStringUTF16( 370 text = l10n_util::GetStringUTF16(
360 IDS_AUTOFILL_WALLET_BUYER_COUNTRY_NOT_SUPPORTED); 371 IDS_AUTOFILL_WALLET_BUYER_COUNTRY_NOT_SUPPORTED);
372 url = GURL(kBlaStatusUrl);
373 break;
361 374
375 default:
376 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.
377 }
378
379 if (!text.empty()) {
380 scoped_ptr<DialogNotification> notification(new DialogNotification(
381 DialogNotification::WALLET_ERROR,
382 text));
383 notification->set_link_url(url);
384 return notification.Pass();
385 }
386
387 switch (error_type) {
362 case wallet::WalletClient::UNSUPPORTED_MERCHANT: 388 case wallet::WalletClient::UNSUPPORTED_MERCHANT:
363 return l10n_util::GetStringUTF16( 389 text = l10n_util::GetStringUTF16(
364 IDS_AUTOFILL_WALLET_UNSUPPORTED_MERCHANT); 390 IDS_AUTOFILL_WALLET_UNSUPPORTED_MERCHANT);
391 break;
365 392
366 case wallet::WalletClient::BAD_REQUEST: 393 case wallet::WalletClient::BAD_REQUEST:
367 return l10n_util::GetStringFUTF16( 394 text = l10n_util::GetStringFUTF16(
368 IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR, 395 IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR,
369 ASCIIToUTF16("71")); 396 ASCIIToUTF16("71"));
397 break;
370 398
371 case wallet::WalletClient::INVALID_PARAMS: 399 case wallet::WalletClient::INVALID_PARAMS:
372 return l10n_util::GetStringFUTF16( 400 text = l10n_util::GetStringFUTF16(
373 IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR, 401 IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR,
374 ASCIIToUTF16("42")); 402 ASCIIToUTF16("42"));
403 break;
375 404
376 case wallet::WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS: 405 case wallet::WalletClient::BUYER_ACCOUNT_ERROR:
377 return l10n_util::GetStringUTF16( 406 text = l10n_util::GetStringUTF16(IDS_AUTOFILL_WALLET_BUYER_ACCOUNT_ERROR);
378 IDS_AUTOFILL_WALLET_UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS); 407 break;
379 408
380 case wallet::WalletClient::UNSUPPORTED_API_VERSION: 409 case wallet::WalletClient::UNSUPPORTED_API_VERSION:
381 return l10n_util::GetStringFUTF16( 410 text = l10n_util::GetStringFUTF16(
382 IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR, 411 IDS_AUTOFILL_WALLET_UPGRADE_CHROME_ERROR,
383 ASCIIToUTF16("43")); 412 ASCIIToUTF16("43"));
413 break;
384 414
385 case wallet::WalletClient::SERVICE_UNAVAILABLE: 415 case wallet::WalletClient::SERVICE_UNAVAILABLE:
386 return l10n_util::GetStringUTF16( 416 text = l10n_util::GetStringUTF16(
387 IDS_AUTOFILL_WALLET_SERVICE_UNAVAILABLE_ERROR); 417 IDS_AUTOFILL_WALLET_SERVICE_UNAVAILABLE_ERROR);
418 break;
388 419
389 case wallet::WalletClient::INTERNAL_ERROR: 420 case wallet::WalletClient::INTERNAL_ERROR:
390 return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, 421 text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR,
391 ASCIIToUTF16("62")); 422 ASCIIToUTF16("62"));
423 break;
392 424
393 case wallet::WalletClient::MALFORMED_RESPONSE: 425 case wallet::WalletClient::MALFORMED_RESPONSE:
394 return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, 426 text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR,
395 ASCIIToUTF16("72")); 427 ASCIIToUTF16("72"));
428 break;
396 429
397 case wallet::WalletClient::NETWORK_ERROR: 430 case wallet::WalletClient::NETWORK_ERROR:
398 return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, 431 text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR,
399 ASCIIToUTF16("73")); 432 ASCIIToUTF16("73"));
433 break;
400 434
401 case wallet::WalletClient::UNKNOWN_ERROR: 435 case wallet::WalletClient::UNKNOWN_ERROR:
402 return l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR, 436 text = l10n_util::GetStringFUTF16(IDS_AUTOFILL_WALLET_UNKNOWN_ERROR,
403 ASCIIToUTF16("74")); 437 ASCIIToUTF16("74"));
438 break;
439
440 default:
441 break;
404 } 442 }
405 443
406 NOTREACHED(); 444 if (text.empty())
407 return base::string16(); 445 NOTREACHED();
Ilya Sherman 2013/08/29 00:26:11 nit: DCHECK(!text.empty());
Evan Stade 2013/08/30 02:52:21 Done.
446
447 // The other error types are strings of the form "XXX. You can pay without
448 // wallet."
449 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.
450 DialogNotification::WALLET_ERROR,
451 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET,
452 text)));
408 } 453 }
409 454
410 gfx::Image GetGeneratedCardImage(const string16& card_number) { 455 gfx::Image GetGeneratedCardImage(const string16& card_number) {
411 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 456 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
412 const gfx::ImageSkia* card = 457 const gfx::ImageSkia* card =
413 rb.GetImageSkiaNamed(IDR_AUTOFILL_GENERATED_CARD); 458 rb.GetImageSkiaNamed(IDR_AUTOFILL_GENERATED_CARD);
414 gfx::Canvas canvas(card->size(), ui::SCALE_FACTOR_100P, false); 459 gfx::Canvas canvas(card->size(), ui::SCALE_FACTOR_100P, false);
415 canvas.DrawImageInt(*card, 0, 0); 460 canvas.DrawImageInt(*card, 0, 0);
416 461
417 gfx::Rect display_rect(gfx::Point(), card->size()); 462 gfx::Rect display_rect(gfx::Point(), card->size());
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING))); 1866 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SECURITY_WARNING)));
1822 } 1867 }
1823 1868
1824 if (!invoked_from_same_origin_) { 1869 if (!invoked_from_same_origin_) {
1825 notifications.push_back(DialogNotification( 1870 notifications.push_back(DialogNotification(
1826 DialogNotification::SECURITY_WARNING, 1871 DialogNotification::SECURITY_WARNING,
1827 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_SITE_WARNING, 1872 l10n_util::GetStringFUTF16(IDS_AUTOFILL_DIALOG_SITE_WARNING,
1828 UTF8ToUTF16(source_url_.host())))); 1873 UTF8ToUTF16(source_url_.host()))));
1829 } 1874 }
1830 1875
1831 if (account_chooser_model_.HadWalletError()) { 1876 // TODO(dbeam): figure out a way to dismiss this error after a while.
1832 // TODO(dbeam): figure out a way to dismiss this error after a while. 1877 if (wallet_error_notification_)
1833 notifications.push_back(DialogNotification( 1878 notifications.push_back(*wallet_error_notification_);
1834 DialogNotification::WALLET_ERROR,
1835 l10n_util::GetStringFUTF16(
1836 IDS_AUTOFILL_DIALOG_COMPLETE_WITHOUT_WALLET,
1837 account_chooser_model_.wallet_error_message())));
1838 }
1839 1879
1840 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { 1880 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) {
1841 notifications.push_back(DialogNotification( 1881 notifications.push_back(DialogNotification(
1842 DialogNotification::REQUIRED_ACTION, 1882 DialogNotification::REQUIRED_ACTION,
1843 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV))); 1883 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VERIFY_CVV)));
1844 } 1884 }
1845 1885
1846 if (autocheckout_state_ == AUTOCHECKOUT_ERROR) { 1886 if (autocheckout_state_ == AUTOCHECKOUT_ERROR) {
1847 notifications.push_back(DialogNotification( 1887 notifications.push_back(DialogNotification(
1848 DialogNotification::AUTOCHECKOUT_ERROR, 1888 DialogNotification::AUTOCHECKOUT_ERROR,
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 GetWalletClient()->CancelRequests(); 2506 GetWalletClient()->CancelRequests();
2467 SetAutocheckoutState(AUTOCHECKOUT_NOT_STARTED); 2507 SetAutocheckoutState(AUTOCHECKOUT_NOT_STARTED);
2468 for (std::vector<DialogAutocheckoutStep>::iterator it = steps_.begin(); 2508 for (std::vector<DialogAutocheckoutStep>::iterator it = steps_.begin();
2469 it != steps_.end(); ++it) { 2509 it != steps_.end(); ++it) {
2470 if (it->type() == AUTOCHECKOUT_STEP_PROXY_CARD) { 2510 if (it->type() == AUTOCHECKOUT_STEP_PROXY_CARD) {
2471 steps_.erase(it); 2511 steps_.erase(it);
2472 break; 2512 break;
2473 } 2513 }
2474 } 2514 }
2475 SetIsSubmitting(false); 2515 SetIsSubmitting(false);
2476 account_chooser_model_.SetHadWalletError(WalletErrorMessage(error_type)); 2516 wallet_error_notification_ = GetWalletError(error_type);
2517 account_chooser_model_.SetHadWalletError();
2477 } 2518 }
2478 2519
2479 void AutofillDialogControllerImpl::SuggestionsUpdated() { 2520 void AutofillDialogControllerImpl::SuggestionsUpdated() {
2480 ScopedViewUpdates updates(view_.get()); 2521 ScopedViewUpdates updates(view_.get());
2481 2522
2482 const DetailOutputMap snapshot = TakeUserInputSnapshot(); 2523 const DetailOutputMap snapshot = TakeUserInputSnapshot();
2483 2524
2484 suggested_email_.Reset(); 2525 suggested_email_.Reset();
2485 suggested_cc_.Reset(); 2526 suggested_cc_.Reset();
2486 suggested_billing_.Reset(); 2527 suggested_billing_.Reset();
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
3496 } 3537 }
3497 #if !defined(OS_ANDROID) 3538 #if !defined(OS_ANDROID)
3498 GeneratedCreditCardBubbleController::Show( 3539 GeneratedCreditCardBubbleController::Show(
3499 web_contents(), 3540 web_contents(),
3500 backing_last_four, 3541 backing_last_four,
3501 full_wallet_->TypeAndLastFourDigits()); 3542 full_wallet_->TypeAndLastFourDigits());
3502 #endif 3543 #endif
3503 } 3544 }
3504 3545
3505 } // namespace autofill 3546 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698