Rename vector icon header files.
[chromium-blink-merge.git] / chrome / browser / ui / views / autofill / card_unmask_prompt_views.h
blobf67aa7d2965cf3c61f739705c212e4f9130e4cad
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_
8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
9 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h"
10 #include "ui/gfx/animation/animation_delegate.h"
11 #include "ui/gfx/animation/slide_animation.h"
12 #include "ui/views/controls/combobox/combobox_listener.h"
13 #include "ui/views/controls/link_listener.h"
14 #include "ui/views/controls/textfield/textfield_controller.h"
15 #include "ui/views/window/dialog_delegate.h"
17 namespace content {
18 class WebContents;
21 namespace views {
22 class Checkbox;
23 class ImageView;
24 class Label;
25 class Link;
26 class Throbber;
29 namespace autofill {
31 class DecoratedTextfield;
33 class CardUnmaskPromptViews : public CardUnmaskPromptView,
34 views::ComboboxListener,
35 views::DialogDelegateView,
36 views::TextfieldController,
37 views::LinkListener,
38 gfx::AnimationDelegate {
39 public:
40 CardUnmaskPromptViews(CardUnmaskPromptController* controller,
41 content::WebContents* web_contents);
42 ~CardUnmaskPromptViews() override;
44 // CardUnmaskPromptView
45 void Show() override;
46 void ControllerGone() override;
47 void DisableAndWaitForVerification() override;
48 void GotVerificationResult(const base::string16& error_message,
49 bool allow_retry) override;
51 // views::DialogDelegateView
52 View* GetContentsView() override;
53 views::View* CreateFootnoteView() override;
55 // views::View
56 gfx::Size GetPreferredSize() const override;
57 void Layout() override;
58 int GetHeightForWidth(int width) const override;
59 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
60 ui::ModalType GetModalType() const override;
61 base::string16 GetWindowTitle() const override;
62 void DeleteDelegate() override;
63 int GetDialogButtons() const override;
64 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
65 bool ShouldDefaultButtonBeBlue() const override;
66 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
67 views::View* GetInitiallyFocusedView() override;
68 bool Cancel() override;
69 bool Accept() override;
71 // views::TextfieldController
72 void ContentsChanged(views::Textfield* sender,
73 const base::string16& new_contents) override;
75 // views::ComboboxListener
76 void OnPerformAction(views::Combobox* combobox) override;
78 // views::LinkListener
79 void LinkClicked(views::Link* source, int event_flags) override;
81 // gfx::AnimationDelegate
82 void AnimationProgressed(const gfx::Animation* animation) override;
84 private:
85 friend class CardUnmaskPromptViewTesterViews;
87 // A view that allows changing the opacity of its contents.
88 class FadeOutView : public views::View {
89 public:
90 FadeOutView();
91 ~FadeOutView() override;
93 // views::View
94 void PaintChildren(const ui::PaintContext& context) override;
95 void OnPaint(gfx::Canvas* canvas) override;
97 void set_fade_everything(bool fade_everything) {
98 fade_everything_ = fade_everything;
101 // Set the alpha channel for this view. 0 is transparent and 255 is opaque.
102 void SetAlpha(uint8_t alpha);
104 private:
105 // Controls whether the background and border are faded out as well. Default
106 // is false, meaning only children are faded.
107 bool fade_everything_;
109 // The alpha channel for this view. 0 is transparent and 255 is opaque.
110 uint8_t alpha_;
112 DISALLOW_COPY_AND_ASSIGN(FadeOutView);
115 void InitIfNecessary();
116 void SetRetriableErrorMessage(const base::string16& message);
117 bool ExpirationDateIsValid() const;
118 void SetInputsEnabled(bool enabled);
119 void ShowNewCardLink();
120 void ClosePrompt();
122 CardUnmaskPromptController* controller_;
123 content::WebContents* web_contents_;
125 views::View* main_contents_;
127 // Expository language at the top of the dialog.
128 views::Label* instructions_;
130 // The error label for permanent errors (where the user can't retry).
131 views::Label* permanent_error_label_;
133 // Holds the cvc and expiration inputs.
134 views::View* input_row_;
136 DecoratedTextfield* cvc_input_;
138 views::Combobox* month_input_;
139 views::Combobox* year_input_;
141 MonthComboboxModel month_combobox_model_;
142 YearComboboxModel year_combobox_model_;
144 views::Link* new_card_link_;
146 // The error icon and label for most errors, which live beneath the inputs.
147 views::ImageView* error_icon_;
148 views::Label* error_label_;
150 FadeOutView* storage_row_;
151 views::Checkbox* storage_checkbox_;
153 FadeOutView* progress_overlay_;
154 views::Throbber* progress_throbber_;
155 views::Label* progress_label_;
157 gfx::SlideAnimation overlay_animation_;
159 base::WeakPtrFactory<CardUnmaskPromptViews> weak_ptr_factory_;
161 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews);
164 } // namespace autofill
166 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_