| OLD | NEW |
| 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/create_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/autofill/core/browser/ui/card_unmask_prompt_controller.h" |
| 14 #include "components/constrained_window/constrained_window_views.h" | 15 #include "components/constrained_window/constrained_window_views.h" |
| 15 #include "components/web_modal/web_contents_modal_dialog_host.h" | 16 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 16 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 17 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 17 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 18 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/compositor/compositing_recorder.h" | 23 #include "ui/compositor/compositing_recorder.h" |
| 23 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/geometry/safe_integer_conversions.h" | 25 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 25 #include "ui/views/background.h" | 26 #include "ui/views/background.h" |
| 26 #include "ui/views/controls/button/checkbox.h" | 27 #include "ui/views/controls/button/checkbox.h" |
| 27 #include "ui/views/controls/combobox/combobox.h" | 28 #include "ui/views/controls/combobox/combobox.h" |
| 28 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
| 29 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| 30 #include "ui/views/controls/throbber.h" | 31 #include "ui/views/controls/throbber.h" |
| 31 #include "ui/views/layout/box_layout.h" | 32 #include "ui/views/layout/box_layout.h" |
| 32 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 33 #include "ui/views/window/dialog_client_view.h" | 34 #include "ui/views/window/dialog_client_view.h" |
| 34 | 35 |
| 35 namespace autofill { | 36 namespace autofill { |
| 36 | 37 |
| 37 // The number of pixels of blank space on the outer horizontal edges of the | 38 // The number of pixels of blank space on the outer horizontal edges of the |
| 38 // dialog. | 39 // dialog. |
| 39 const int kEdgePadding = 19; | 40 const int kEdgePadding = 19; |
| 40 | 41 |
| 41 SkColor kGreyTextColor = SkColorSetRGB(0x64, 0x64, 0x64); | 42 SkColor kGreyTextColor = SkColorSetRGB(0x64, 0x64, 0x64); |
| 42 | 43 |
| 43 // static | 44 CardUnmaskPromptView* CreateCardUnmaskPromptView( |
| 44 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( | 45 CardUnmaskPromptController* controller, |
| 45 CardUnmaskPromptController* controller) { | 46 content::WebContents* web_contents) { |
| 46 CardUnmaskPromptViews* view = new CardUnmaskPromptViews(controller); | 47 return new CardUnmaskPromptViews(controller, web_contents); |
| 47 view->Show(); | |
| 48 return view; | |
| 49 } | 48 } |
| 50 | 49 |
| 51 CardUnmaskPromptViews::CardUnmaskPromptViews( | 50 CardUnmaskPromptViews::CardUnmaskPromptViews( |
| 52 CardUnmaskPromptController* controller) | 51 CardUnmaskPromptController* controller, |
| 52 content::WebContents* web_contents) |
| 53 : controller_(controller), | 53 : controller_(controller), |
| 54 web_contents_(web_contents), |
| 54 main_contents_(nullptr), | 55 main_contents_(nullptr), |
| 55 permanent_error_label_(nullptr), | 56 permanent_error_label_(nullptr), |
| 56 input_row_(nullptr), | 57 input_row_(nullptr), |
| 57 cvc_input_(nullptr), | 58 cvc_input_(nullptr), |
| 58 month_input_(nullptr), | 59 month_input_(nullptr), |
| 59 year_input_(nullptr), | 60 year_input_(nullptr), |
| 60 error_icon_(nullptr), | 61 error_icon_(nullptr), |
| 61 error_label_(nullptr), | 62 error_label_(nullptr), |
| 62 storage_row_(nullptr), | 63 storage_row_(nullptr), |
| 63 storage_checkbox_(nullptr), | 64 storage_checkbox_(nullptr), |
| 64 progress_overlay_(nullptr), | 65 progress_overlay_(nullptr), |
| 65 progress_throbber_(nullptr), | 66 progress_throbber_(nullptr), |
| 66 progress_label_(nullptr), | 67 progress_label_(nullptr), |
| 67 overlay_animation_(this), | 68 overlay_animation_(this), |
| 68 weak_ptr_factory_(this) { | 69 weak_ptr_factory_(this) { |
| 69 } | 70 } |
| 70 | 71 |
| 71 CardUnmaskPromptViews::~CardUnmaskPromptViews() { | 72 CardUnmaskPromptViews::~CardUnmaskPromptViews() { |
| 72 if (controller_) | 73 if (controller_) |
| 73 controller_->OnUnmaskDialogClosed(); | 74 controller_->OnUnmaskDialogClosed(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void CardUnmaskPromptViews::Show() { | 77 void CardUnmaskPromptViews::Show() { |
| 77 constrained_window::ShowWebModalDialogViews(this, | 78 constrained_window::ShowWebModalDialogViews(this, web_contents_); |
| 78 controller_->GetWebContents()); | |
| 79 } | 79 } |
| 80 | 80 |
| 81 void CardUnmaskPromptViews::ControllerGone() { | 81 void CardUnmaskPromptViews::ControllerGone() { |
| 82 controller_ = nullptr; | 82 controller_ = nullptr; |
| 83 ClosePrompt(); | 83 ClosePrompt(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void CardUnmaskPromptViews::DisableAndWaitForVerification() { | 86 void CardUnmaskPromptViews::DisableAndWaitForVerification() { |
| 87 SetInputsEnabled(false); | 87 SetInputsEnabled(false); |
| 88 progress_overlay_->SetAlpha(0); | 88 progress_overlay_->SetAlpha(0); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 error_label_->SetMultiLine(false); | 140 error_label_->SetMultiLine(false); |
| 141 error_label_->SetText(base::ASCIIToUTF16(" ")); | 141 error_label_->SetText(base::ASCIIToUTF16(" ")); |
| 142 error_icon_->SetVisible(false); | 142 error_icon_->SetVisible(false); |
| 143 } else { | 143 } else { |
| 144 error_label_->SetMultiLine(true); | 144 error_label_->SetMultiLine(true); |
| 145 error_label_->SetText(message); | 145 error_label_->SetText(message); |
| 146 error_icon_->SetVisible(true); | 146 error_icon_->SetVisible(true); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Update the dialog's size. | 149 // Update the dialog's size. |
| 150 if (GetWidget() && controller_->GetWebContents()) { | 150 if (GetWidget() && web_contents_) { |
| 151 constrained_window::UpdateWebContentsModalDialogPosition( | 151 constrained_window::UpdateWebContentsModalDialogPosition( |
| 152 GetWidget(), web_modal::WebContentsModalDialogManager::FromWebContents( | 152 GetWidget(), |
| 153 controller_->GetWebContents()) | 153 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents_) |
| 154 ->delegate() | 154 ->delegate() |
| 155 ->GetWebContentsModalDialogHost()); | 155 ->GetWebContentsModalDialogHost()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 Layout(); | 158 Layout(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void CardUnmaskPromptViews::SetInputsEnabled(bool enabled) { | 161 void CardUnmaskPromptViews::SetInputsEnabled(bool enabled) { |
| 162 cvc_input_->SetEnabled(enabled); | 162 cvc_input_->SetEnabled(enabled); |
| 163 if (storage_checkbox_) | 163 if (storage_checkbox_) |
| 164 storage_checkbox_->SetEnabled(enabled); | 164 storage_checkbox_->SetEnabled(enabled); |
| 165 if (month_input_) | 165 if (month_input_) |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 views::View::OnPaint(canvas); | 478 views::View::OnPaint(canvas); |
| 479 canvas->Restore(); | 479 canvas->Restore(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void CardUnmaskPromptViews::FadeOutView::SetAlpha(uint8_t alpha) { | 482 void CardUnmaskPromptViews::FadeOutView::SetAlpha(uint8_t alpha) { |
| 483 alpha_ = alpha; | 483 alpha_ = alpha; |
| 484 SchedulePaint(); | 484 SchedulePaint(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 } // namespace autofill | 487 } // namespace autofill |
| OLD | NEW |