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

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

Issue 1020013003: Add a regression test for the CardUnmaskPrompt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git add Created 5 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 unified diff | Download patch
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 "chrome/browser/ui/views/autofill/card_unmask_prompt_views.h"
6
5 #include "base/basictypes.h" 7 #include "base/basictypes.h"
6 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
8 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
9 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" 10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h"
10 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h"
11 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" 11 #include "chrome/browser/ui/views/autofill/decorated_textfield.h"
12 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" 12 #include "chrome/browser/ui/views/autofill/tooltip_icon.h"
13 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
14 #include "components/constrained_window/constrained_window_views.h" 14 #include "components/constrained_window/constrained_window_views.h"
15 #include "components/web_modal/web_contents_modal_dialog_host.h" 15 #include "components/web_modal/web_contents_modal_dialog_host.h"
16 #include "components/web_modal/web_contents_modal_dialog_manager.h" 16 #include "components/web_modal/web_contents_modal_dialog_manager.h"
17 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 17 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
18 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
19 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/views/background.h" 22 #include "ui/views/background.h"
23 #include "ui/views/controls/button/checkbox.h" 23 #include "ui/views/controls/button/checkbox.h"
24 #include "ui/views/controls/combobox/combobox.h" 24 #include "ui/views/controls/combobox/combobox.h"
25 #include "ui/views/controls/combobox/combobox_listener.h"
26 #include "ui/views/controls/image_view.h" 25 #include "ui/views/controls/image_view.h"
27 #include "ui/views/controls/label.h" 26 #include "ui/views/controls/label.h"
28 #include "ui/views/controls/textfield/textfield_controller.h"
29 #include "ui/views/layout/box_layout.h" 27 #include "ui/views/layout/box_layout.h"
30 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
31 #include "ui/views/window/dialog_client_view.h" 29 #include "ui/views/window/dialog_client_view.h"
32 #include "ui/views/window/dialog_delegate.h"
33 30
34 namespace autofill { 31 namespace autofill {
35 32
36 namespace {
37
38 // The number of pixels of blank space on the outer horizontal edges of the 33 // The number of pixels of blank space on the outer horizontal edges of the
39 // dialog. 34 // dialog.
40 const int kEdgePadding = 19; 35 const int kEdgePadding = 19;
41 36
42 // From AutofillDialogViews. TODO(estade): share. 37 // From AutofillDialogViews. TODO(estade): share.
43 SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0); 38 SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0);
44 SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0); 39 SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0);
45 40
46 class CardUnmaskPromptViews : public CardUnmaskPromptView, 41 // static
47 views::ComboboxListener, 42 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow(
48 views::DialogDelegateView, 43 CardUnmaskPromptController* controller) {
49 views::TextfieldController { 44 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller);
50 public: 45 view->Show();
51 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller) 46 return view;
52 : controller_(controller), 47 }
53 main_contents_(nullptr),
54 permanent_error_label_(nullptr),
55 cvc_input_(nullptr),
56 month_input_(nullptr),
57 year_input_(nullptr),
58 error_label_(nullptr),
59 storage_checkbox_(nullptr),
60 progress_overlay_(nullptr),
61 progress_label_(nullptr) {}
62 48
63 ~CardUnmaskPromptViews() override { 49 CardUnmaskPromptViews::CardUnmaskPromptViews(
50 CardUnmaskPromptController* controller)
51 : controller_(controller),
52 main_contents_(nullptr),
53 permanent_error_label_(nullptr),
54 cvc_input_(nullptr),
55 month_input_(nullptr),
56 year_input_(nullptr),
57 error_label_(nullptr),
58 storage_checkbox_(nullptr),
59 progress_overlay_(nullptr),
60 progress_label_(nullptr),
61 weak_ptr_factory_(this) {
62 }
63
64 CardUnmaskPromptViews::~CardUnmaskPromptViews() {
64 if (controller_) 65 if (controller_)
65 controller_->OnUnmaskDialogClosed(); 66 controller_->OnUnmaskDialogClosed();
66 } 67 }
67 68
68 void Show() { 69 void CardUnmaskPromptViews::Show() {
69 constrained_window::ShowWebModalDialogViews(this, 70 constrained_window::ShowWebModalDialogViews(this,
70 controller_->GetWebContents()); 71 controller_->GetWebContents());
71 } 72 }
72 73
73 // CardUnmaskPromptView 74 void CardUnmaskPromptViews::ControllerGone() {
74 void ControllerGone() override {
75 controller_ = nullptr; 75 controller_ = nullptr;
76 ClosePrompt(); 76 ClosePrompt();
77 } 77 }
78 78
79 void DisableAndWaitForVerification() override { 79 void CardUnmaskPromptViews::DisableAndWaitForVerification() {
80 SetInputsEnabled(false); 80 SetInputsEnabled(false);
81 progress_overlay_->SetVisible(true); 81 progress_overlay_->SetVisible(true);
82 GetDialogClientView()->UpdateDialogButtons(); 82 GetDialogClientView()->UpdateDialogButtons();
83 Layout(); 83 Layout();
84 } 84 }
85 85
86 void GotVerificationResult(const base::string16& error_message, 86 void CardUnmaskPromptViews::GotVerificationResult(
87 bool allow_retry) override { 87 const base::string16& error_message,
88 bool allow_retry) {
88 if (error_message.empty()) { 89 if (error_message.empty()) {
89 progress_label_->SetText(l10n_util::GetStringUTF16( 90 progress_label_->SetText(l10n_util::GetStringUTF16(
90 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_SUCCESS)); 91 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_SUCCESS));
91 base::MessageLoop::current()->PostDelayedTask( 92 base::MessageLoop::current()->PostDelayedTask(
92 FROM_HERE, base::Bind(&CardUnmaskPromptViews::ClosePrompt, 93 FROM_HERE, base::Bind(&CardUnmaskPromptViews::ClosePrompt,
93 base::Unretained(this)), 94 weak_ptr_factory_.GetWeakPtr()),
94 base::TimeDelta::FromSeconds(1)); 95 controller_->GetSuccessMessageDuration());
95 } else { 96 } else {
96 // TODO(estade): it's somewhat jarring when the error comes back too 97 // TODO(estade): it's somewhat jarring when the error comes back too
97 // quickly. 98 // quickly.
98 progress_overlay_->SetVisible(false); 99 progress_overlay_->SetVisible(false);
99 100
100 if (allow_retry) { 101 if (allow_retry) {
101 SetInputsEnabled(true); 102 SetInputsEnabled(true);
102 103
103 // If there is more than one input showing, don't mark anything as 104 // If there is more than one input showing, don't mark anything as
104 // invalid since we don't know the location of the problem. 105 // invalid since we don't know the location of the problem.
105 if (!controller_->ShouldRequestExpirationDate()) 106 if (!controller_->ShouldRequestExpirationDate())
106 cvc_input_->SetInvalid(true); 107 cvc_input_->SetInvalid(true);
107 108
108 // TODO(estade): When do we hide |error_label_|? 109 // TODO(estade): When do we hide |error_label_|?
109 SetRetriableErrorMessage(error_message); 110 SetRetriableErrorMessage(error_message);
110 } else { 111 } else {
111 permanent_error_label_->SetText(error_message); 112 permanent_error_label_->SetText(error_message);
112 permanent_error_label_->SetVisible(true); 113 permanent_error_label_->SetVisible(true);
113 SetRetriableErrorMessage(base::string16()); 114 SetRetriableErrorMessage(base::string16());
114 } 115 }
115 116
116 GetDialogClientView()->UpdateDialogButtons(); 117 GetDialogClientView()->UpdateDialogButtons();
117 } 118 }
118 119
119 Layout(); 120 Layout();
120 } 121 }
121 122
122 void SetRetriableErrorMessage(const base::string16& message) { 123 void CardUnmaskPromptViews::SetRetriableErrorMessage(
124 const base::string16& message) {
123 if (message.empty()) { 125 if (message.empty()) {
124 error_label_->SetMultiLine(false); 126 error_label_->SetMultiLine(false);
125 error_label_->SetText(base::ASCIIToUTF16(" ")); 127 error_label_->SetText(base::ASCIIToUTF16(" "));
126 } else { 128 } else {
127 error_label_->SetMultiLine(true); 129 error_label_->SetMultiLine(true);
128 error_label_->SetText(message); 130 error_label_->SetText(message);
129 } 131 }
130 132
131 // Update the dialog's size. 133 // Update the dialog's size.
132 if (GetWidget() && controller_->GetWebContents()) { 134 if (GetWidget() && controller_->GetWebContents()) {
133 constrained_window::UpdateWebContentsModalDialogPosition( 135 constrained_window::UpdateWebContentsModalDialogPosition(
134 GetWidget(), 136 GetWidget(),
135 web_modal::WebContentsModalDialogManager::FromWebContents( 137 web_modal::WebContentsModalDialogManager::FromWebContents(
136 controller_->GetWebContents()) 138 controller_->GetWebContents())
137 ->delegate() 139 ->delegate()
138 ->GetWebContentsModalDialogHost()); 140 ->GetWebContentsModalDialogHost());
139 } 141 }
140 } 142 }
141 143
142 void SetInputsEnabled(bool enabled) { 144 void CardUnmaskPromptViews::SetInputsEnabled(bool enabled) {
143 cvc_input_->SetEnabled(enabled); 145 cvc_input_->SetEnabled(enabled);
144 storage_checkbox_->SetEnabled(enabled); 146 storage_checkbox_->SetEnabled(enabled);
145 147
146 if (month_input_) 148 if (month_input_)
147 month_input_->SetEnabled(enabled); 149 month_input_->SetEnabled(enabled);
148 if (year_input_) 150 if (year_input_)
149 year_input_->SetEnabled(enabled); 151 year_input_->SetEnabled(enabled);
150 } 152 }
151 153
152 // views::DialogDelegateView 154 views::View* CardUnmaskPromptViews::GetContentsView() {
153 View* GetContentsView() override {
154 InitIfNecessary(); 155 InitIfNecessary();
155 return this; 156 return this;
156 } 157 }
157 158
158 views::View* CreateFootnoteView() override { 159 views::View* CardUnmaskPromptViews::CreateFootnoteView() {
159 // Local storage checkbox and (?) tooltip. 160 // Local storage checkbox and (?) tooltip.
160 views::View* storage_row = new views::View(); 161 views::View* storage_row = new views::View();
161 views::BoxLayout* storage_row_layout = new views::BoxLayout( 162 views::BoxLayout* storage_row_layout = new views::BoxLayout(
162 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); 163 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0);
163 storage_row->SetLayoutManager(storage_row_layout); 164 storage_row->SetLayoutManager(storage_row_layout);
164 storage_row->SetBorder( 165 storage_row->SetBorder(
165 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); 166 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor));
166 storage_row->set_background( 167 storage_row->set_background(
167 views::Background::CreateSolidBackground(kShadingColor)); 168 views::Background::CreateSolidBackground(kShadingColor));
168 169
169 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( 170 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16(
170 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); 171 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX));
171 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); 172 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState());
172 storage_row->AddChildView(storage_checkbox_); 173 storage_row->AddChildView(storage_checkbox_);
173 storage_row_layout->SetFlexForView(storage_checkbox_, 1); 174 storage_row_layout->SetFlexForView(storage_checkbox_, 1);
174 175
175 storage_row->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( 176 storage_row->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16(
176 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))); 177 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP)));
177 178
178 return storage_row; 179 return storage_row;
179 } 180 }
180 181
181 // views::View 182 gfx::Size CardUnmaskPromptViews::GetPreferredSize() const {
182 gfx::Size GetPreferredSize() const override {
183 // Must hardcode a width so the label knows where to wrap. TODO(estade): 183 // Must hardcode a width so the label knows where to wrap. TODO(estade):
184 // This can lead to a weird looking dialog if we end up getting allocated 184 // This can lead to a weird looking dialog if we end up getting allocated
185 // more width than we ask for, e.g. if the title is super long. 185 // more width than we ask for, e.g. if the title is super long.
186 const int kWidth = 375; 186 const int kWidth = 375;
187 return gfx::Size(kWidth, GetHeightForWidth(kWidth)); 187 return gfx::Size(kWidth, GetHeightForWidth(kWidth));
188 } 188 }
189 189
190 void Layout() override { 190 void CardUnmaskPromptViews::Layout() {
191 for (int i = 0; i < child_count(); ++i) { 191 for (int i = 0; i < child_count(); ++i) {
192 child_at(i)->SetBoundsRect(GetContentsBounds()); 192 child_at(i)->SetBoundsRect(GetContentsBounds());
193 } 193 }
194 } 194 }
195 195
196 int GetHeightForWidth(int width) const override { 196 int CardUnmaskPromptViews::GetHeightForWidth(int width) const {
197 if (!has_children()) 197 if (!has_children())
198 return 0; 198 return 0;
199 const gfx::Insets insets = GetInsets(); 199 const gfx::Insets insets = GetInsets();
200 return main_contents_->GetHeightForWidth(width - insets.width()) + 200 return main_contents_->GetHeightForWidth(width - insets.width()) +
201 insets.height(); 201 insets.height();
202 } 202 }
203 203
204 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { 204 void CardUnmaskPromptViews::OnNativeThemeChanged(
205 const ui::NativeTheme* theme) {
205 SkColor bg_color = 206 SkColor bg_color =
206 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); 207 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
207 bg_color = SkColorSetA(bg_color, 0xDD); 208 bg_color = SkColorSetA(bg_color, 0xDD);
208 progress_overlay_->set_background( 209 progress_overlay_->set_background(
209 views::Background::CreateSolidBackground(bg_color)); 210 views::Background::CreateSolidBackground(bg_color));
210 } 211 }
211 212
212 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; } 213 ui::ModalType CardUnmaskPromptViews::GetModalType() const {
214 return ui::MODAL_TYPE_CHILD;
215 }
213 216
214 base::string16 GetWindowTitle() const override { 217 base::string16 CardUnmaskPromptViews::GetWindowTitle() const {
215 return controller_->GetWindowTitle(); 218 return controller_->GetWindowTitle();
216 } 219 }
217 220
218 void DeleteDelegate() override { delete this; } 221 void CardUnmaskPromptViews::DeleteDelegate() {
222 delete this;
223 }
219 224
220 int GetDialogButtons() const override { 225 int CardUnmaskPromptViews::GetDialogButtons() const {
221 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; 226 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
222 } 227 }
223 228
224 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override { 229 base::string16 CardUnmaskPromptViews::GetDialogButtonLabel(
230 ui::DialogButton button) const {
225 if (button == ui::DIALOG_BUTTON_OK) 231 if (button == ui::DIALOG_BUTTON_OK)
226 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_CONFIRM_BUTTON); 232 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_UNMASK_CONFIRM_BUTTON);
227 233
228 return DialogDelegateView::GetDialogButtonLabel(button); 234 return DialogDelegateView::GetDialogButtonLabel(button);
229 } 235 }
230 236
231 bool ShouldDefaultButtonBeBlue() const override { return true; } 237 bool CardUnmaskPromptViews::ShouldDefaultButtonBeBlue() const {
238 return true;
239 }
232 240
233 bool IsDialogButtonEnabled(ui::DialogButton button) const override { 241 bool CardUnmaskPromptViews::IsDialogButtonEnabled(
242 ui::DialogButton button) const {
234 if (button == ui::DIALOG_BUTTON_CANCEL) 243 if (button == ui::DIALOG_BUTTON_CANCEL)
235 return true; 244 return true;
236 245
237 DCHECK_EQ(ui::DIALOG_BUTTON_OK, button); 246 DCHECK_EQ(ui::DIALOG_BUTTON_OK, button);
238 247
239 return cvc_input_->enabled() && 248 return cvc_input_->enabled() &&
240 controller_->InputCvcIsValid(cvc_input_->text()) && 249 controller_->InputCvcIsValid(cvc_input_->text()) &&
241 ExpirationDateIsValid(); 250 ExpirationDateIsValid();
242 } 251 }
243 252
244 views::View* GetInitiallyFocusedView() override { return cvc_input_; } 253 views::View* CardUnmaskPromptViews::GetInitiallyFocusedView() {
254 return cvc_input_;
255 }
245 256
246 bool Cancel() override { 257 bool CardUnmaskPromptViews::Cancel() {
247 return true; 258 return true;
248 } 259 }
249 260
250 bool Accept() override { 261 bool CardUnmaskPromptViews::Accept() {
251 if (!controller_) 262 if (!controller_)
252 return true; 263 return true;
253 264
254 controller_->OnUnmaskResponse( 265 controller_->OnUnmaskResponse(
255 cvc_input_->text(), 266 cvc_input_->text(),
256 month_input_ 267 month_input_
257 ? month_input_->GetTextForRow(month_input_->selected_index()) 268 ? month_input_->GetTextForRow(month_input_->selected_index())
258 : base::string16(), 269 : base::string16(),
259 year_input_ ? year_input_->GetTextForRow(year_input_->selected_index()) 270 year_input_ ? year_input_->GetTextForRow(year_input_->selected_index())
260 : base::string16(), 271 : base::string16(),
261 storage_checkbox_ ? storage_checkbox_->checked() : false); 272 storage_checkbox_ ? storage_checkbox_->checked() : false);
262 return false; 273 return false;
263 } 274 }
264 275
265 // views::TextfieldController 276 void CardUnmaskPromptViews::ContentsChanged(
266 void ContentsChanged(views::Textfield* sender, 277 views::Textfield* sender,
267 const base::string16& new_contents) override { 278 const base::string16& new_contents) {
268 if (controller_->InputCvcIsValid(new_contents)) 279 if (controller_->InputCvcIsValid(new_contents))
269 cvc_input_->SetInvalid(false); 280 cvc_input_->SetInvalid(false);
270 281
271 GetDialogClientView()->UpdateDialogButtons(); 282 GetDialogClientView()->UpdateDialogButtons();
272 } 283 }
273 284
274 // views::ComboboxListener 285 void CardUnmaskPromptViews::OnPerformAction(views::Combobox* combobox) {
275 void OnPerformAction(views::Combobox* combobox) override {
276 if (ExpirationDateIsValid()) { 286 if (ExpirationDateIsValid()) {
277 if (month_input_->invalid()) { 287 if (month_input_->invalid()) {
278 month_input_->SetInvalid(false); 288 month_input_->SetInvalid(false);
279 year_input_->SetInvalid(false); 289 year_input_->SetInvalid(false);
280 error_label_->SetMultiLine(false); 290 error_label_->SetMultiLine(false);
281 SetRetriableErrorMessage(base::string16()); 291 SetRetriableErrorMessage(base::string16());
282 } 292 }
283 } else if (month_input_->selected_index() != 293 } else if (month_input_->selected_index() !=
284 month_combobox_model_.GetDefaultIndex() && 294 month_combobox_model_.GetDefaultIndex() &&
285 year_input_->selected_index() != 295 year_input_->selected_index() !=
286 year_combobox_model_.GetDefaultIndex()) { 296 year_combobox_model_.GetDefaultIndex()) {
287 month_input_->SetInvalid(true); 297 month_input_->SetInvalid(true);
288 year_input_->SetInvalid(true); 298 year_input_->SetInvalid(true);
289 error_label_->SetMultiLine(true); 299 error_label_->SetMultiLine(true);
290 SetRetriableErrorMessage(l10n_util::GetStringUTF16( 300 SetRetriableErrorMessage(l10n_util::GetStringUTF16(
291 IDS_AUTOFILL_CARD_UNMASK_INVALID_EXPIRATION_DATE)); 301 IDS_AUTOFILL_CARD_UNMASK_INVALID_EXPIRATION_DATE));
292 } 302 }
293 303
294 GetDialogClientView()->UpdateDialogButtons(); 304 GetDialogClientView()->UpdateDialogButtons();
295 } 305 }
296 306
297 private: 307 void CardUnmaskPromptViews::InitIfNecessary() {
298 void InitIfNecessary() {
299 if (has_children()) 308 if (has_children())
300 return; 309 return;
301 310
302 main_contents_ = new views::View(); 311 main_contents_ = new views::View();
303 main_contents_->SetLayoutManager( 312 main_contents_->SetLayoutManager(
304 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 10)); 313 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 10));
305 AddChildView(main_contents_); 314 AddChildView(main_contents_);
306 315
307 permanent_error_label_ = new views::Label(); 316 permanent_error_label_ = new views::Label();
308 permanent_error_label_->set_background( 317 permanent_error_label_->set_background(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 progress_overlay_->SetLayoutManager(progress_layout); 386 progress_overlay_->SetLayoutManager(progress_layout);
378 387
379 progress_overlay_->SetVisible(false); 388 progress_overlay_->SetVisible(false);
380 AddChildView(progress_overlay_); 389 AddChildView(progress_overlay_);
381 390
382 progress_label_ = new views::Label(l10n_util::GetStringUTF16( 391 progress_label_ = new views::Label(l10n_util::GetStringUTF16(
383 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_IN_PROGRESS)); 392 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_IN_PROGRESS));
384 progress_overlay_->AddChildView(progress_label_); 393 progress_overlay_->AddChildView(progress_label_);
385 } 394 }
386 395
387 void ClosePrompt() { GetWidget()->Close(); } 396 bool CardUnmaskPromptViews::ExpirationDateIsValid() const {
388
389 bool ExpirationDateIsValid() const {
390 if (!controller_->ShouldRequestExpirationDate()) 397 if (!controller_->ShouldRequestExpirationDate())
391 return true; 398 return true;
392 399
393 return controller_->InputExpirationIsValid( 400 return controller_->InputExpirationIsValid(
394 month_input_->GetTextForRow(month_input_->selected_index()), 401 month_input_->GetTextForRow(month_input_->selected_index()),
395 year_input_->GetTextForRow(year_input_->selected_index())); 402 year_input_->GetTextForRow(year_input_->selected_index()));
396 } 403 }
397 404
398 CardUnmaskPromptController* controller_; 405 void CardUnmaskPromptViews::ClosePrompt() {
399 406 GetWidget()->Close();
400 views::View* main_contents_; 407 }
401
402 // The error label for permanent errors (where the user can't retry).
403 views::Label* permanent_error_label_;
404
405 DecoratedTextfield* cvc_input_;
406
407 // These will be null when expiration date is not required.
408 views::Combobox* month_input_;
409 views::Combobox* year_input_;
410
411 MonthComboboxModel month_combobox_model_;
412 YearComboboxModel year_combobox_model_;
413
414 // The error label for most errors, which lives beneath the inputs.
415 views::Label* error_label_;
416
417 views::Checkbox* storage_checkbox_;
418
419 views::View* progress_overlay_;
420 views::Label* progress_label_;
421
422 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews);
423 };
424
425 } // namespace
426
427 // static
428 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow(
429 CardUnmaskPromptController* controller) {
430 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller);
431 view->Show();
432 return view;
433 }
434 408
435 } // namespace autofill 409 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698