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

Side by Side Diff: chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc

Issue 889043003: Card unmasking prompt - mark cvc input as invalid as appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" 7 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
8 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" 8 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h"
9 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" 9 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h"
10 #include "chrome/browser/ui/views/autofill/decorated_textfield.h"
10 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
11 #include "components/constrained_window/constrained_window_views.h" 12 #include "components/constrained_window/constrained_window_views.h"
12 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/views/controls/combobox/combobox.h" 16 #include "ui/views/controls/combobox/combobox.h"
16 #include "ui/views/controls/combobox/combobox_listener.h" 17 #include "ui/views/controls/combobox/combobox_listener.h"
17 #include "ui/views/controls/image_view.h" 18 #include "ui/views/controls/image_view.h"
18 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
19 #include "ui/views/controls/textfield/textfield.h"
20 #include "ui/views/controls/textfield/textfield_controller.h" 20 #include "ui/views/controls/textfield/textfield_controller.h"
21 #include "ui/views/layout/box_layout.h" 21 #include "ui/views/layout/box_layout.h"
22 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
23 #include "ui/views/window/dialog_client_view.h" 23 #include "ui/views/window/dialog_client_view.h"
24 #include "ui/views/window/dialog_delegate.h" 24 #include "ui/views/window/dialog_delegate.h"
25 25
26 namespace autofill { 26 namespace autofill {
27 27
28 namespace { 28 namespace {
29 29
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 void GotVerificationResult(bool success) override { 66 void GotVerificationResult(bool success) override {
67 if (success) { 67 if (success) {
68 message_label_->SetText(base::ASCIIToUTF16("Success!")); 68 message_label_->SetText(base::ASCIIToUTF16("Success!"));
69 base::MessageLoop::current()->PostDelayedTask( 69 base::MessageLoop::current()->PostDelayedTask(
70 FROM_HERE, base::Bind(&CardUnmaskPromptViews::ClosePrompt, 70 FROM_HERE, base::Bind(&CardUnmaskPromptViews::ClosePrompt,
71 base::Unretained(this)), 71 base::Unretained(this)),
72 base::TimeDelta::FromSeconds(1)); 72 base::TimeDelta::FromSeconds(1));
73 } else { 73 } else {
74 SetInputsEnabled(true); 74 SetInputsEnabled(true);
75 cvc_input_->SetInvalid(true);
75 message_label_->SetText(base::ASCIIToUTF16("Verification error.")); 76 message_label_->SetText(base::ASCIIToUTF16("Verification error."));
76 GetDialogClientView()->UpdateDialogButtons(); 77 GetDialogClientView()->UpdateDialogButtons();
77 } 78 }
78 Layout(); 79 Layout();
79 } 80 }
80 81
81 void SetInputsEnabled(bool enabled) { 82 void SetInputsEnabled(bool enabled) {
82 cvc_input_->SetEnabled(enabled); 83 cvc_input_->SetEnabled(enabled);
83 84
84 if (month_input_) 85 if (month_input_)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 194
194 if (controller_->ShouldRequestExpirationDate()) { 195 if (controller_->ShouldRequestExpirationDate()) {
195 month_input_ = new views::Combobox(&month_combobox_model_); 196 month_input_ = new views::Combobox(&month_combobox_model_);
196 month_input_->set_listener(this); 197 month_input_->set_listener(this);
197 input_row->AddChildView(month_input_); 198 input_row->AddChildView(month_input_);
198 year_input_ = new views::Combobox(&year_combobox_model_); 199 year_input_ = new views::Combobox(&year_combobox_model_);
199 year_input_->set_listener(this); 200 year_input_->set_listener(this);
200 input_row->AddChildView(year_input_); 201 input_row->AddChildView(year_input_);
201 } 202 }
202 203
203 cvc_input_ = new views::Textfield(); 204 cvc_input_ = new DecoratedTextfield(
204 cvc_input_->set_controller(this); 205 base::string16(),
205 cvc_input_->set_placeholder_text( 206 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC),
206 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC)); 207 this);
207 cvc_input_->set_default_width_in_chars(10); 208 cvc_input_->set_default_width_in_chars(10);
208 input_row->AddChildView(cvc_input_); 209 input_row->AddChildView(cvc_input_);
209 210
210 views::ImageView* cvc_image = new views::ImageView(); 211 views::ImageView* cvc_image = new views::ImageView();
211 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 212 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
212 213
213 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid())); 214 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid()));
214 215
215 input_row->AddChildView(cvc_image); 216 input_row->AddChildView(cvc_image);
216 217
217 message_label_ = new views::Label(); 218 message_label_ = new views::Label();
218 input_row->AddChildView(message_label_); 219 input_row->AddChildView(message_label_);
219 message_label_->SetVisible(false); 220 message_label_->SetVisible(false);
220 } 221 }
221 222
222 void ClosePrompt() { GetWidget()->Close(); } 223 void ClosePrompt() { GetWidget()->Close(); }
223 224
224 CardUnmaskPromptController* controller_; 225 CardUnmaskPromptController* controller_;
225 226
226 views::Textfield* cvc_input_; 227 DecoratedTextfield* cvc_input_;
227 228
228 // These will be null when expiration date is not required. 229 // These will be null when expiration date is not required.
229 views::Combobox* month_input_; 230 views::Combobox* month_input_;
230 views::Combobox* year_input_; 231 views::Combobox* year_input_;
231 232
232 MonthComboboxModel month_combobox_model_; 233 MonthComboboxModel month_combobox_model_;
233 YearComboboxModel year_combobox_model_; 234 YearComboboxModel year_combobox_model_;
234 235
235 // TODO(estade): this is a temporary standin in place of some spinner UI 236 // TODO(estade): this is a temporary standin in place of some spinner UI
236 // as well as a better error message. 237 // as well as a better error message.
237 views::Label* message_label_; 238 views::Label* message_label_;
238 239
239 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews); 240 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews);
240 }; 241 };
241 242
242 } // namespace 243 } // namespace
243 244
244 // static 245 // static
245 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( 246 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow(
246 CardUnmaskPromptController* controller) { 247 CardUnmaskPromptController* controller) {
247 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller); 248 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller);
248 view->Show(); 249 view->Show();
249 return view; 250 return view;
250 } 251 }
251 252
252 } // namespace autofill 253 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698