OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_ |
7 | 7 |
8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.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 "ui/gfx/animation/animation_delegate.h" |
| 11 #include "ui/gfx/animation/slide_animation.h" |
10 #include "ui/views/controls/combobox/combobox_listener.h" | 12 #include "ui/views/controls/combobox/combobox_listener.h" |
11 #include "ui/views/controls/textfield/textfield_controller.h" | 13 #include "ui/views/controls/textfield/textfield_controller.h" |
12 #include "ui/views/window/dialog_delegate.h" | 14 #include "ui/views/window/dialog_delegate.h" |
13 | 15 |
14 namespace views { | 16 namespace views { |
15 class Label; | 17 class Label; |
16 class Checkbox; | 18 class Checkbox; |
17 } | 19 } |
18 | 20 |
19 namespace autofill { | 21 namespace autofill { |
20 | 22 |
21 class DecoratedTextfield; | 23 class DecoratedTextfield; |
22 | 24 |
23 class CardUnmaskPromptViews : public CardUnmaskPromptView, | 25 class CardUnmaskPromptViews : public CardUnmaskPromptView, |
24 views::ComboboxListener, | 26 views::ComboboxListener, |
25 views::DialogDelegateView, | 27 views::DialogDelegateView, |
26 views::TextfieldController { | 28 views::TextfieldController, |
| 29 gfx::AnimationDelegate { |
27 public: | 30 public: |
28 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller); | 31 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller); |
29 | 32 |
30 ~CardUnmaskPromptViews() override; | 33 ~CardUnmaskPromptViews() override; |
31 | 34 |
32 void Show(); | 35 void Show(); |
33 | 36 |
34 // CardUnmaskPromptView | 37 // CardUnmaskPromptView |
35 void ControllerGone() override; | 38 void ControllerGone() override; |
36 void DisableAndWaitForVerification() override; | 39 void DisableAndWaitForVerification() override; |
(...skipping 19 matching lines...) Expand all Loading... |
56 views::View* GetInitiallyFocusedView() override; | 59 views::View* GetInitiallyFocusedView() override; |
57 bool Cancel() override; | 60 bool Cancel() override; |
58 bool Accept() override; | 61 bool Accept() override; |
59 | 62 |
60 // views::TextfieldController | 63 // views::TextfieldController |
61 void ContentsChanged(views::Textfield* sender, | 64 void ContentsChanged(views::Textfield* sender, |
62 const base::string16& new_contents) override; | 65 const base::string16& new_contents) override; |
63 // views::ComboboxListener | 66 // views::ComboboxListener |
64 void OnPerformAction(views::Combobox* combobox) override; | 67 void OnPerformAction(views::Combobox* combobox) override; |
65 | 68 |
| 69 // gfx::AnimationDelegate |
| 70 void AnimationProgressed(const gfx::Animation* animation) override; |
| 71 |
66 private: | 72 private: |
67 friend class CardUnmaskPromptViewTesterViews; | 73 friend class CardUnmaskPromptViewTesterViews; |
68 | 74 |
| 75 // A view that allows changing the opacity of its contents. |
| 76 class FadeOutView : public views::View { |
| 77 public: |
| 78 FadeOutView(); |
| 79 ~FadeOutView() override; |
| 80 |
| 81 // views::View |
| 82 void PaintChildren(gfx::Canvas* canvas, |
| 83 const views::CullSet& cull_set) override; |
| 84 void OnPaint(gfx::Canvas* canvas) override; |
| 85 |
| 86 void set_fade_everything(bool fade_everything) { |
| 87 fade_everything_ = fade_everything; |
| 88 } |
| 89 void SetOpacity(double opacity); |
| 90 |
| 91 private: |
| 92 // Controls whether the background and border are faded out as well. Default |
| 93 // is false, meaning only children are faded. |
| 94 bool fade_everything_; |
| 95 |
| 96 // On a scale of 0-1, how much to fade out the contents of this view. 0 is |
| 97 // totally invisible, 1 is totally visible. |
| 98 double opacity_; |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(FadeOutView); |
| 101 }; |
| 102 |
69 void InitIfNecessary(); | 103 void InitIfNecessary(); |
70 void SetRetriableErrorMessage(const base::string16& message); | 104 void SetRetriableErrorMessage(const base::string16& message); |
71 bool ExpirationDateIsValid() const; | 105 bool ExpirationDateIsValid() const; |
72 void SetInputsEnabled(bool enabled); | 106 void SetInputsEnabled(bool enabled); |
73 void ClosePrompt(); | 107 void ClosePrompt(); |
74 | 108 |
75 CardUnmaskPromptController* controller_; | 109 CardUnmaskPromptController* controller_; |
76 | 110 |
77 views::View* main_contents_; | 111 views::View* main_contents_; |
78 | 112 |
79 // The error label for permanent errors (where the user can't retry). | 113 // The error label for permanent errors (where the user can't retry). |
80 views::Label* permanent_error_label_; | 114 views::Label* permanent_error_label_; |
81 | 115 |
| 116 // Holds the cvc and expiration inputs. |
| 117 views::View* input_row_; |
| 118 |
82 DecoratedTextfield* cvc_input_; | 119 DecoratedTextfield* cvc_input_; |
83 | 120 |
84 // These will be null when expiration date is not required. | 121 // These will be null when expiration date is not required. |
85 views::Combobox* month_input_; | 122 views::Combobox* month_input_; |
86 views::Combobox* year_input_; | 123 views::Combobox* year_input_; |
87 | 124 |
88 MonthComboboxModel month_combobox_model_; | 125 MonthComboboxModel month_combobox_model_; |
89 YearComboboxModel year_combobox_model_; | 126 YearComboboxModel year_combobox_model_; |
90 | 127 |
91 // The error label for most errors, which lives beneath the inputs. | 128 // The error label for most errors, which lives beneath the inputs. |
92 views::Label* error_label_; | 129 views::Label* error_label_; |
93 | 130 |
| 131 FadeOutView* storage_row_; |
94 views::Checkbox* storage_checkbox_; | 132 views::Checkbox* storage_checkbox_; |
95 | 133 |
96 views::View* progress_overlay_; | 134 FadeOutView* progress_overlay_; |
97 views::Label* progress_label_; | 135 views::Label* progress_label_; |
98 | 136 |
| 137 gfx::SlideAnimation overlay_animation_; |
| 138 |
99 base::WeakPtrFactory<CardUnmaskPromptViews> weak_ptr_factory_; | 139 base::WeakPtrFactory<CardUnmaskPromptViews> weak_ptr_factory_; |
100 | 140 |
101 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews); | 141 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews); |
102 }; | 142 }; |
103 | 143 |
104 } // namespace autofill | 144 } // namespace autofill |
105 | 145 |
106 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_ | 146 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_ |
OLD | NEW |