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

Unified Diff: chrome/browser/ui/views/autofill/save_card_bubble_views.cc

Issue 2789843004: [Payments] Upload card UI now has a CVC prompt (Closed)
Patch Set: Created 3 years, 9 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/views/autofill/save_card_bubble_views.cc
diff --git a/chrome/browser/ui/views/autofill/save_card_bubble_views.cc b/chrome/browser/ui/views/autofill/save_card_bubble_views.cc
index 2549a1759d90632881233199c593c8ef9d5f3ae3..38cec74822ddda712a51c393d59298f8677eaab7 100644
--- a/chrome/browser/ui/views/autofill/save_card_bubble_views.cc
+++ b/chrome/browser/ui/views/autofill/save_card_bubble_views.cc
@@ -8,9 +8,9 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
-#include "chrome/browser/ui/autofill/save_card_bubble_controller.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/legal_message_line.h"
+#include "components/autofill/core/browser/ui/save_card_bubble_controller.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -21,8 +21,10 @@
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/styled_label.h"
+#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_constants.h"
+#include "ui/views/window/dialog_client_view.h"
namespace autofill {
@@ -50,6 +52,7 @@ SaveCardBubbleViews::SaveCardBubbleViews(views::View* anchor_view,
SaveCardBubbleController* controller)
: LocationBarBubbleDelegateView(anchor_view, web_contents),
controller_(controller),
+ cvc_input_(nullptr),
learn_more_link_(nullptr) {
DCHECK(controller);
views::BubbleDialogDelegateView::CreateBubble(this);
@@ -91,8 +94,13 @@ views::View* SaveCardBubbleViews::CreateFootnoteView() {
}
bool SaveCardBubbleViews::Accept() {
- if (controller_)
+ if (controller_) {
+ if (controller_->ShouldRequestCvcFromUser()) {
+ const base::string16& cvc = cvc_input_->text();
+ controller_->SetUserProvidedCvc(cvc);
+ }
controller_->OnSaveButton();
+ }
return true;
}
@@ -200,6 +208,27 @@ std::unique_ptr<views::View> SaveCardBubbleViews::CreateMainContentView() {
description_view->AddChildView(
new views::Label(card.AbbreviatedExpirationDateForDisplay()));
+ // Optionally add CVC request field if CVC was missing.
+ if (controller_->ShouldRequestCvcFromUser()) {
+ views::View* request_cvc_view = new views::View();
+ request_cvc_view->SetLayoutManager(new views::BoxLayout(
+ views::BoxLayout::kHorizontal, 0, 0, views::kRelatedButtonHSpacing));
+ DCHECK(!cvc_input_);
+ cvc_input_ = new views::Textfield();
+ cvc_input_->set_placeholder_text(
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC));
+ cvc_input_->set_controller(this);
+ cvc_input_->set_default_width_in_chars(8);
csashi 2017/03/31 21:48:15 s/8/kDefaultWidthForCVC?
Jared Saul 2017/04/01 04:18:02 Sure. Not 100% sure where this goes so I put it i
+ request_cvc_view->AddChildView(cvc_input_);
+ views::ImageView* cvc_image = new views::ImageView();
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid()));
+ request_cvc_view->AddChildView(cvc_image);
+ request_cvc_view->AddChildView(new views::Label(
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_PROMPT_ENTER_CVC)));
csashi 2017/03/31 21:48:15 May be add a helper for creating this new view?
Jared Saul 2017/04/01 04:18:02 Done.
+ view->AddChildView(request_cvc_view);
+ }
+
// Optionally add label that will contain an explanation for upload.
base::string16 explanation = controller_->GetExplanatoryMessage();
if (!explanation.empty()) {
@@ -212,6 +241,21 @@ std::unique_ptr<views::View> SaveCardBubbleViews::CreateMainContentView() {
return view;
}
+bool SaveCardBubbleViews::IsDialogButtonEnabled(ui::DialogButton button) const {
+ if (button == ui::DIALOG_BUTTON_CANCEL)
+ return true;
+
+ DCHECK_EQ(ui::DIALOG_BUTTON_OK, button);
+ return !controller_->ShouldRequestCvcFromUser() ||
+ (cvc_input_->enabled() &&
+ controller_->InputCvcIsValid(cvc_input_->text()));
+}
+
+void SaveCardBubbleViews::ContentsChanged(views::Textfield* sender,
+ const base::string16& new_contents) {
+ GetDialogClientView()->UpdateDialogButtons();
csashi 2017/03/31 21:48:15 For my understanding, can you confirm that UpdateD
Jared Saul 2017/04/01 04:18:02 Not sure what you mean. Whenever the user changes
+}
+
void SaveCardBubbleViews::Init() {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
AddChildView(CreateMainContentView().release());

Powered by Google App Engine
This is Rietveld 408576698