Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / autofill / card_unmask_prompt_views.h
blob001f250fdde1a3b8e79890bd2d1867355b373c22
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 "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"
12 #include "ui/views/controls/combobox/combobox_listener.h"
13 #include "ui/views/controls/textfield/textfield_controller.h"
14 #include "ui/views/window/dialog_delegate.h"
16 namespace views {
17 class ImageView;
18 class Label;
19 class Checkbox;
20 class CheckmarkThrobber;
23 namespace autofill {
25 class DecoratedTextfield;
27 class CardUnmaskPromptViews : public CardUnmaskPromptView,
28 views::ComboboxListener,
29 views::DialogDelegateView,
30 views::TextfieldController,
31 gfx::AnimationDelegate {
32 public:
33 explicit CardUnmaskPromptViews(CardUnmaskPromptController* controller);
35 ~CardUnmaskPromptViews() override;
37 void Show();
39 // CardUnmaskPromptView
40 void ControllerGone() override;
41 void DisableAndWaitForVerification() override;
42 void GotVerificationResult(const base::string16& error_message,
43 bool allow_retry) override;
45 // views::DialogDelegateView
46 View* GetContentsView() override;
47 views::View* CreateFootnoteView() override;
49 // views::View
50 gfx::Size GetPreferredSize() const override;
51 void Layout() override;
52 int GetHeightForWidth(int width) const override;
53 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
54 ui::ModalType GetModalType() const override;
55 base::string16 GetWindowTitle() const override;
56 void DeleteDelegate() override;
57 int GetDialogButtons() const override;
58 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
59 bool ShouldDefaultButtonBeBlue() const override;
60 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
61 views::View* GetInitiallyFocusedView() override;
62 bool Cancel() override;
63 bool Accept() override;
65 // views::TextfieldController
66 void ContentsChanged(views::Textfield* sender,
67 const base::string16& new_contents) override;
68 // views::ComboboxListener
69 void OnPerformAction(views::Combobox* combobox) override;
71 // gfx::AnimationDelegate
72 void AnimationProgressed(const gfx::Animation* animation) override;
74 private:
75 friend class CardUnmaskPromptViewTesterViews;
77 // A view that allows changing the opacity of its contents.
78 class FadeOutView : public views::View {
79 public:
80 FadeOutView();
81 ~FadeOutView() override;
83 // views::View
84 void PaintChildren(const PaintContext& context) override;
85 void OnPaint(gfx::Canvas* canvas) override;
87 void set_fade_everything(bool fade_everything) {
88 fade_everything_ = fade_everything;
90 void SetOpacity(double opacity);
92 private:
93 // Controls whether the background and border are faded out as well. Default
94 // is false, meaning only children are faded.
95 bool fade_everything_;
97 // On a scale of 0-1, how much to fade out the contents of this view. 0 is
98 // totally invisible, 1 is totally visible.
99 double opacity_;
101 DISALLOW_COPY_AND_ASSIGN(FadeOutView);
104 void InitIfNecessary();
105 void SetRetriableErrorMessage(const base::string16& message);
106 bool ExpirationDateIsValid() const;
107 void SetInputsEnabled(bool enabled);
108 void ClosePrompt();
110 CardUnmaskPromptController* controller_;
112 views::View* main_contents_;
114 // The error label for permanent errors (where the user can't retry).
115 views::Label* permanent_error_label_;
117 // Holds the cvc and expiration inputs.
118 views::View* input_row_;
120 DecoratedTextfield* cvc_input_;
122 // These will be null when expiration date is not required.
123 views::Combobox* month_input_;
124 views::Combobox* year_input_;
126 MonthComboboxModel month_combobox_model_;
127 YearComboboxModel year_combobox_model_;
129 // The error icon and label for most errors, which live beneath the inputs.
130 views::ImageView* error_icon_;
131 views::Label* error_label_;
133 FadeOutView* storage_row_;
134 views::Checkbox* storage_checkbox_;
136 FadeOutView* progress_overlay_;
137 views::CheckmarkThrobber* progress_throbber_;
138 views::Label* progress_label_;
140 gfx::SlideAnimation overlay_animation_;
142 base::WeakPtrFactory<CardUnmaskPromptViews> weak_ptr_factory_;
144 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptViews);
147 } // namespace autofill
149 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_CARD_UNMASK_PROMPT_VIEWS_H_