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

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

Issue 1021913004: views - fade out more cvc prompt elements during verification process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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
« no previous file with comments | « chrome/browser/ui/views/autofill/card_unmask_prompt_views.h ('k') | 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 "chrome/browser/ui/views/autofill/card_unmask_prompt_views.h" 5 #include "chrome/browser/ui/views/autofill/card_unmask_prompt_views.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" 10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.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/gfx/canvas.h"
22 #include "ui/views/background.h" 23 #include "ui/views/background.h"
23 #include "ui/views/controls/button/checkbox.h" 24 #include "ui/views/controls/button/checkbox.h"
24 #include "ui/views/controls/combobox/combobox.h" 25 #include "ui/views/controls/combobox/combobox.h"
25 #include "ui/views/controls/image_view.h" 26 #include "ui/views/controls/image_view.h"
26 #include "ui/views/controls/label.h" 27 #include "ui/views/controls/label.h"
27 #include "ui/views/layout/box_layout.h" 28 #include "ui/views/layout/box_layout.h"
28 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
29 #include "ui/views/window/dialog_client_view.h" 30 #include "ui/views/window/dialog_client_view.h"
30 31
31 namespace autofill { 32 namespace autofill {
(...skipping 12 matching lines...) Expand all
44 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller); 45 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller);
45 view->Show(); 46 view->Show();
46 return view; 47 return view;
47 } 48 }
48 49
49 CardUnmaskPromptViews::CardUnmaskPromptViews( 50 CardUnmaskPromptViews::CardUnmaskPromptViews(
50 CardUnmaskPromptController* controller) 51 CardUnmaskPromptController* controller)
51 : controller_(controller), 52 : controller_(controller),
52 main_contents_(nullptr), 53 main_contents_(nullptr),
53 permanent_error_label_(nullptr), 54 permanent_error_label_(nullptr),
55 input_row_(nullptr),
54 cvc_input_(nullptr), 56 cvc_input_(nullptr),
55 month_input_(nullptr), 57 month_input_(nullptr),
56 year_input_(nullptr), 58 year_input_(nullptr),
57 error_label_(nullptr), 59 error_label_(nullptr),
60 storage_row_(nullptr),
58 storage_checkbox_(nullptr), 61 storage_checkbox_(nullptr),
59 progress_overlay_(nullptr), 62 progress_overlay_(nullptr),
60 progress_label_(nullptr), 63 progress_label_(nullptr),
64 overlay_animation_(this),
61 weak_ptr_factory_(this) { 65 weak_ptr_factory_(this) {
62 } 66 }
63 67
64 CardUnmaskPromptViews::~CardUnmaskPromptViews() { 68 CardUnmaskPromptViews::~CardUnmaskPromptViews() {
65 if (controller_) 69 if (controller_)
66 controller_->OnUnmaskDialogClosed(); 70 controller_->OnUnmaskDialogClosed();
67 } 71 }
68 72
69 void CardUnmaskPromptViews::Show() { 73 void CardUnmaskPromptViews::Show() {
70 constrained_window::ShowWebModalDialogViews(this, 74 constrained_window::ShowWebModalDialogViews(this,
71 controller_->GetWebContents()); 75 controller_->GetWebContents());
72 } 76 }
73 77
74 void CardUnmaskPromptViews::ControllerGone() { 78 void CardUnmaskPromptViews::ControllerGone() {
75 controller_ = nullptr; 79 controller_ = nullptr;
76 ClosePrompt(); 80 ClosePrompt();
77 } 81 }
78 82
79 void CardUnmaskPromptViews::DisableAndWaitForVerification() { 83 void CardUnmaskPromptViews::DisableAndWaitForVerification() {
80 SetInputsEnabled(false); 84 SetInputsEnabled(false);
85 progress_overlay_->SetOpacity(0.0);
81 progress_overlay_->SetVisible(true); 86 progress_overlay_->SetVisible(true);
87 overlay_animation_.Show();
82 GetDialogClientView()->UpdateDialogButtons(); 88 GetDialogClientView()->UpdateDialogButtons();
83 Layout(); 89 Layout();
84 } 90 }
85 91
86 void CardUnmaskPromptViews::GotVerificationResult( 92 void CardUnmaskPromptViews::GotVerificationResult(
87 const base::string16& error_message, 93 const base::string16& error_message,
88 bool allow_retry) { 94 bool allow_retry) {
89 if (error_message.empty()) { 95 if (error_message.empty()) {
90 progress_label_->SetText(l10n_util::GetStringUTF16( 96 progress_label_->SetText(l10n_util::GetStringUTF16(
91 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_SUCCESS)); 97 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_SUCCESS));
92 base::MessageLoop::current()->PostDelayedTask( 98 base::MessageLoop::current()->PostDelayedTask(
93 FROM_HERE, base::Bind(&CardUnmaskPromptViews::ClosePrompt, 99 FROM_HERE, base::Bind(&CardUnmaskPromptViews::ClosePrompt,
94 weak_ptr_factory_.GetWeakPtr()), 100 weak_ptr_factory_.GetWeakPtr()),
95 controller_->GetSuccessMessageDuration()); 101 controller_->GetSuccessMessageDuration());
96 } else { 102 } else {
97 // TODO(estade): it's somewhat jarring when the error comes back too 103 // TODO(estade): it's somewhat jarring when the error comes back too
98 // quickly. 104 // quickly.
105 overlay_animation_.Reset();
106 storage_row_->SetOpacity(1.0);
99 progress_overlay_->SetVisible(false); 107 progress_overlay_->SetVisible(false);
100 108
101 if (allow_retry) { 109 if (allow_retry) {
102 SetInputsEnabled(true); 110 SetInputsEnabled(true);
103 111
104 // If there is more than one input showing, don't mark anything as 112 // If there is more than one input showing, don't mark anything as
105 // invalid since we don't know the location of the problem. 113 // invalid since we don't know the location of the problem.
106 if (!controller_->ShouldRequestExpirationDate()) 114 if (!controller_->ShouldRequestExpirationDate())
107 cvc_input_->SetInvalid(true); 115 cvc_input_->SetInvalid(true);
108 116
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 year_input_->SetEnabled(enabled); 157 year_input_->SetEnabled(enabled);
150 } 158 }
151 159
152 views::View* CardUnmaskPromptViews::GetContentsView() { 160 views::View* CardUnmaskPromptViews::GetContentsView() {
153 InitIfNecessary(); 161 InitIfNecessary();
154 return this; 162 return this;
155 } 163 }
156 164
157 views::View* CardUnmaskPromptViews::CreateFootnoteView() { 165 views::View* CardUnmaskPromptViews::CreateFootnoteView() {
158 // Local storage checkbox and (?) tooltip. 166 // Local storage checkbox and (?) tooltip.
159 views::View* storage_row = new views::View(); 167 storage_row_ = new FadeOutView();
160 views::BoxLayout* storage_row_layout = new views::BoxLayout( 168 views::BoxLayout* storage_row_layout = new views::BoxLayout(
161 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0); 169 views::BoxLayout::kHorizontal, kEdgePadding, kEdgePadding, 0);
162 storage_row->SetLayoutManager(storage_row_layout); 170 storage_row_->SetLayoutManager(storage_row_layout);
163 storage_row->SetBorder( 171 storage_row_->SetBorder(
164 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); 172 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor));
165 storage_row->set_background( 173 storage_row_->set_background(
166 views::Background::CreateSolidBackground(kShadingColor)); 174 views::Background::CreateSolidBackground(kShadingColor));
167 175
168 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16( 176 storage_checkbox_ = new views::Checkbox(l10n_util::GetStringUTF16(
169 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX)); 177 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_CHECKBOX));
170 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState()); 178 storage_checkbox_->SetChecked(controller_->GetStoreLocallyStartState());
171 storage_row->AddChildView(storage_checkbox_); 179 storage_row_->AddChildView(storage_checkbox_);
172 storage_row_layout->SetFlexForView(storage_checkbox_, 1); 180 storage_row_layout->SetFlexForView(storage_checkbox_, 1);
173 181
174 storage_row->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16( 182 storage_row_->AddChildView(new TooltipIcon(l10n_util::GetStringUTF16(
175 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))); 183 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP)));
176 184
177 return storage_row; 185 return storage_row_;
178 } 186 }
179 187
180 gfx::Size CardUnmaskPromptViews::GetPreferredSize() const { 188 gfx::Size CardUnmaskPromptViews::GetPreferredSize() const {
181 // Must hardcode a width so the label knows where to wrap. TODO(estade): 189 // Must hardcode a width so the label knows where to wrap. TODO(estade):
182 // This can lead to a weird looking dialog if we end up getting allocated 190 // This can lead to a weird looking dialog if we end up getting allocated
183 // more width than we ask for, e.g. if the title is super long. 191 // more width than we ask for, e.g. if the title is super long.
184 const int kWidth = 375; 192 const int kWidth = 375;
185 return gfx::Size(kWidth, GetHeightForWidth(kWidth)); 193 return gfx::Size(kWidth, GetHeightForWidth(kWidth));
186 } 194 }
187 195
188 void CardUnmaskPromptViews::Layout() { 196 void CardUnmaskPromptViews::Layout() {
189 for (int i = 0; i < child_count(); ++i) { 197 gfx::Rect contents_bounds = GetContentsBounds();
190 child_at(i)->SetBoundsRect(GetContentsBounds()); 198 main_contents_->SetBoundsRect(contents_bounds);
191 } 199
200 // The progress overlay extends from the top of the input row
201 // to the bottom of the content area.
202 gfx::RectF input_rect = input_row_->GetContentsBounds();
203 View::ConvertRectToTarget(input_row_, this, &input_rect);
204 input_rect.set_height(contents_bounds.height());
205 contents_bounds.Intersect(gfx::ToNearestRect(input_rect));
206 progress_overlay_->SetBoundsRect(contents_bounds);
192 } 207 }
193 208
194 int CardUnmaskPromptViews::GetHeightForWidth(int width) const { 209 int CardUnmaskPromptViews::GetHeightForWidth(int width) const {
195 if (!has_children()) 210 if (!has_children())
196 return 0; 211 return 0;
197 const gfx::Insets insets = GetInsets(); 212 const gfx::Insets insets = GetInsets();
198 return main_contents_->GetHeightForWidth(width - insets.width()) + 213 return main_contents_->GetHeightForWidth(width - insets.width()) +
199 insets.height(); 214 insets.height();
200 } 215 }
201 216
202 void CardUnmaskPromptViews::OnNativeThemeChanged(const ui::NativeTheme* theme) { 217 void CardUnmaskPromptViews::OnNativeThemeChanged(const ui::NativeTheme* theme) {
203 SkColor bg_color = 218 SkColor bg_color =
204 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); 219 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
205 bg_color = SkColorSetA(bg_color, 0xDD);
206 progress_overlay_->set_background( 220 progress_overlay_->set_background(
207 views::Background::CreateSolidBackground(bg_color)); 221 views::Background::CreateSolidBackground(bg_color));
208 } 222 }
209 223
210 ui::ModalType CardUnmaskPromptViews::GetModalType() const { 224 ui::ModalType CardUnmaskPromptViews::GetModalType() const {
211 return ui::MODAL_TYPE_CHILD; 225 return ui::MODAL_TYPE_CHILD;
212 } 226 }
213 227
214 base::string16 CardUnmaskPromptViews::GetWindowTitle() const { 228 base::string16 CardUnmaskPromptViews::GetWindowTitle() const {
215 return controller_->GetWindowTitle(); 229 return controller_->GetWindowTitle();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 month_input_->SetInvalid(true); 307 month_input_->SetInvalid(true);
294 year_input_->SetInvalid(true); 308 year_input_->SetInvalid(true);
295 error_label_->SetMultiLine(true); 309 error_label_->SetMultiLine(true);
296 SetRetriableErrorMessage(l10n_util::GetStringUTF16( 310 SetRetriableErrorMessage(l10n_util::GetStringUTF16(
297 IDS_AUTOFILL_CARD_UNMASK_INVALID_EXPIRATION_DATE)); 311 IDS_AUTOFILL_CARD_UNMASK_INVALID_EXPIRATION_DATE));
298 } 312 }
299 313
300 GetDialogClientView()->UpdateDialogButtons(); 314 GetDialogClientView()->UpdateDialogButtons();
301 } 315 }
302 316
317 void CardUnmaskPromptViews::AnimationProgressed(
318 const gfx::Animation* animation) {
319 progress_overlay_->SetOpacity(animation->GetCurrentValue());
320 storage_row_->SetOpacity(1.0 - animation->GetCurrentValue());
321 }
322
303 void CardUnmaskPromptViews::InitIfNecessary() { 323 void CardUnmaskPromptViews::InitIfNecessary() {
304 if (has_children()) 324 if (has_children())
305 return; 325 return;
306 326
307 main_contents_ = new views::View(); 327 main_contents_ = new views::View();
308 main_contents_->SetLayoutManager( 328 main_contents_->SetLayoutManager(
309 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 10)); 329 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 10));
310 AddChildView(main_contents_); 330 AddChildView(main_contents_);
311 331
312 permanent_error_label_ = new views::Label(); 332 permanent_error_label_ = new views::Label();
(...skipping 15 matching lines...) Expand all
328 main_contents_->AddChildView(controls_container); 348 main_contents_->AddChildView(controls_container);
329 349
330 views::Label* instructions = 350 views::Label* instructions =
331 new views::Label(controller_->GetInstructionsMessage()); 351 new views::Label(controller_->GetInstructionsMessage());
332 352
333 instructions->SetMultiLine(true); 353 instructions->SetMultiLine(true);
334 instructions->SetHorizontalAlignment(gfx::ALIGN_LEFT); 354 instructions->SetHorizontalAlignment(gfx::ALIGN_LEFT);
335 instructions->SetBorder(views::Border::CreateEmptyBorder(0, 0, 15, 0)); 355 instructions->SetBorder(views::Border::CreateEmptyBorder(0, 0, 15, 0));
336 controls_container->AddChildView(instructions); 356 controls_container->AddChildView(instructions);
337 357
338 views::View* input_row = new views::View(); 358 input_row_ = new views::View();
339 input_row->SetLayoutManager( 359 input_row_->SetLayoutManager(
340 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5)); 360 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5));
341 controls_container->AddChildView(input_row); 361 controls_container->AddChildView(input_row_);
342 362
343 if (controller_->ShouldRequestExpirationDate()) { 363 if (controller_->ShouldRequestExpirationDate()) {
344 month_input_ = new views::Combobox(&month_combobox_model_); 364 month_input_ = new views::Combobox(&month_combobox_model_);
345 month_input_->set_listener(this); 365 month_input_->set_listener(this);
346 input_row->AddChildView(month_input_); 366 input_row_->AddChildView(month_input_);
347 input_row->AddChildView(new views::Label(l10n_util::GetStringUTF16( 367 input_row_->AddChildView(new views::Label(l10n_util::GetStringUTF16(
348 IDS_AUTOFILL_CARD_UNMASK_EXPIRATION_DATE_SEPARATOR))); 368 IDS_AUTOFILL_CARD_UNMASK_EXPIRATION_DATE_SEPARATOR)));
349 year_input_ = new views::Combobox(&year_combobox_model_); 369 year_input_ = new views::Combobox(&year_combobox_model_);
350 year_input_->set_listener(this); 370 year_input_->set_listener(this);
351 input_row->AddChildView(year_input_); 371 input_row_->AddChildView(year_input_);
352 input_row->AddChildView(new views::Label(base::ASCIIToUTF16(" "))); 372 input_row_->AddChildView(new views::Label(base::ASCIIToUTF16(" ")));
353 } 373 }
354 374
355 cvc_input_ = new DecoratedTextfield( 375 cvc_input_ = new DecoratedTextfield(
356 base::string16(), 376 base::string16(),
357 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC), this); 377 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC), this);
358 cvc_input_->set_default_width_in_chars(8); 378 cvc_input_->set_default_width_in_chars(8);
359 input_row->AddChildView(cvc_input_); 379 input_row_->AddChildView(cvc_input_);
360 380
361 views::ImageView* cvc_image = new views::ImageView(); 381 views::ImageView* cvc_image = new views::ImageView();
362 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 382 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
363 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid())); 383 cvc_image->SetImage(rb.GetImageSkiaNamed(controller_->GetCvcImageRid()));
364 input_row->AddChildView(cvc_image); 384 input_row_->AddChildView(cvc_image);
365 385
366 // Reserve vertical space for the error label, assuming it's one line. 386 // Reserve vertical space for the error label, assuming it's one line.
367 error_label_ = new views::Label(base::ASCIIToUTF16(" ")); 387 error_label_ = new views::Label(base::ASCIIToUTF16(" "));
368 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 388 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
369 error_label_->SetEnabledColor(kWarningColor); 389 error_label_->SetEnabledColor(kWarningColor);
370 error_label_->SetBorder(views::Border::CreateEmptyBorder(3, 0, 5, 0)); 390 error_label_->SetBorder(views::Border::CreateEmptyBorder(3, 0, 5, 0));
371 controls_container->AddChildView(error_label_); 391 controls_container->AddChildView(error_label_);
372 392
373 progress_overlay_ = new views::View(); 393 progress_overlay_ = new FadeOutView();
394 progress_overlay_->set_fade_everything(true);
374 views::BoxLayout* progress_layout = 395 views::BoxLayout* progress_layout =
375 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 396 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
376 progress_layout->set_main_axis_alignment( 397 progress_layout->set_main_axis_alignment(
377 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); 398 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER);
378 progress_layout->set_cross_axis_alignment( 399 progress_layout->set_cross_axis_alignment(
379 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 400 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
380 progress_overlay_->SetLayoutManager(progress_layout); 401 progress_overlay_->SetLayoutManager(progress_layout);
381 402
382 progress_overlay_->SetVisible(false); 403 progress_overlay_->SetVisible(false);
383 AddChildView(progress_overlay_); 404 AddChildView(progress_overlay_);
384 405
385 progress_label_ = new views::Label(l10n_util::GetStringUTF16( 406 progress_label_ = new views::Label(l10n_util::GetStringUTF16(
386 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_IN_PROGRESS)); 407 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_IN_PROGRESS));
387 progress_overlay_->AddChildView(progress_label_); 408 progress_overlay_->AddChildView(progress_label_);
388 } 409 }
389 410
390 bool CardUnmaskPromptViews::ExpirationDateIsValid() const { 411 bool CardUnmaskPromptViews::ExpirationDateIsValid() const {
391 if (!controller_->ShouldRequestExpirationDate()) 412 if (!controller_->ShouldRequestExpirationDate())
392 return true; 413 return true;
393 414
394 return controller_->InputExpirationIsValid( 415 return controller_->InputExpirationIsValid(
395 month_input_->GetTextForRow(month_input_->selected_index()), 416 month_input_->GetTextForRow(month_input_->selected_index()),
396 year_input_->GetTextForRow(year_input_->selected_index())); 417 year_input_->GetTextForRow(year_input_->selected_index()));
397 } 418 }
398 419
399 void CardUnmaskPromptViews::ClosePrompt() { 420 void CardUnmaskPromptViews::ClosePrompt() {
400 GetWidget()->Close(); 421 GetWidget()->Close();
401 } 422 }
402 423
424 CardUnmaskPromptViews::FadeOutView::FadeOutView()
425 : fade_everything_(false), opacity_(1.0) {
426 }
427 CardUnmaskPromptViews::FadeOutView::~FadeOutView() {
428 }
429
430 void CardUnmaskPromptViews::FadeOutView::PaintChildren(
431 gfx::Canvas* canvas,
432 const views::CullSet& cull_set) {
433 if (opacity_ > 0.99)
434 return views::View::PaintChildren(canvas, cull_set);
435
436 canvas->SaveLayerAlpha(0xff * opacity_);
437 views::View::PaintChildren(canvas, cull_set);
438 canvas->Restore();
439 }
440
441 void CardUnmaskPromptViews::FadeOutView::OnPaint(gfx::Canvas* canvas) {
442 if (!fade_everything_ || opacity_ > 0.99)
443 return views::View::OnPaint(canvas);
444
445 canvas->SaveLayerAlpha(0xff * opacity_);
446 views::View::OnPaint(canvas);
447 canvas->Restore();
448 }
449
450 void CardUnmaskPromptViews::FadeOutView::SetOpacity(double opacity) {
451 opacity_ = opacity;
452 SchedulePaint();
453 }
454
403 } // namespace autofill 455 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/card_unmask_prompt_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698