Move VISUAL_STATE promise to activation
[chromium-blink-merge.git] / ui / message_center / views / notifier_settings_view.h
blob394d60db8cc88fe0b24a124015a0ab35b71d27af
1 // Copyright (c) 2013 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 UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_
8 #include <set>
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/message_center/message_center_export.h"
12 #include "ui/message_center/notifier_settings.h"
13 #include "ui/message_center/views/message_bubble_base.h"
14 #include "ui/views/controls/button/checkbox.h"
15 #include "ui/views/controls/button/image_button.h"
16 #include "ui/views/controls/button/menu_button_listener.h"
17 #include "ui/views/controls/image_view.h"
18 #include "ui/views/view.h"
20 namespace views {
21 class Label;
22 class MenuButton;
23 class MenuRunner;
26 namespace message_center {
27 class NotifierGroupMenuModel;
29 // A class to show the list of notifier extensions / URL patterns and allow
30 // users to customize the settings.
31 class MESSAGE_CENTER_EXPORT NotifierSettingsView
32 : public NotifierSettingsObserver,
33 public views::View,
34 public views::ButtonListener,
35 public views::MenuButtonListener {
36 public:
37 explicit NotifierSettingsView(NotifierSettingsProvider* provider);
38 ~NotifierSettingsView() override;
40 bool IsScrollable();
42 // Overridden from NotifierSettingsDelegate:
43 void UpdateIconImage(const NotifierId& notifier_id,
44 const gfx::Image& icon) override;
45 void NotifierGroupChanged() override;
46 void NotifierEnabledChanged(const NotifierId& notifier_id,
47 bool enabled) override;
49 void set_provider(NotifierSettingsProvider* new_provider) {
50 provider_ = new_provider;
53 private:
54 FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest, TestLearnMoreButton);
56 class MESSAGE_CENTER_EXPORT NotifierButton : public views::CustomButton,
57 public views::ButtonListener {
58 public:
59 NotifierButton(NotifierSettingsProvider* provider,
60 Notifier* notifier,
61 views::ButtonListener* listener);
62 ~NotifierButton() override;
64 void UpdateIconImage(const gfx::Image& icon);
65 void SetChecked(bool checked);
66 bool checked() const;
67 bool has_learn_more() const;
68 const Notifier& notifier() const;
70 void SendLearnMorePressedForTest();
72 private:
73 // Overridden from views::ButtonListener:
74 void ButtonPressed(views::Button* button, const ui::Event& event) override;
75 void GetAccessibleState(ui::AXViewState* state) override;
77 bool ShouldHaveLearnMoreButton() const;
78 // Helper function to reset the layout when the view has substantially
79 // changed.
80 void GridChanged(bool has_learn_more, bool has_icon_view);
82 NotifierSettingsProvider* provider_; // Weak.
83 const scoped_ptr<Notifier> notifier_;
84 // |icon_view_| is owned by us because sometimes we don't leave it
85 // in the view hierarchy.
86 scoped_ptr<views::ImageView> icon_view_;
87 views::Label* name_view_;
88 views::Checkbox* checkbox_;
89 views::ImageButton* learn_more_;
91 DISALLOW_COPY_AND_ASSIGN(NotifierButton);
94 // Given a new list of notifiers, updates the view to reflect it.
95 void UpdateContentsView(const std::vector<Notifier*>& notifiers);
97 // Overridden from views::View:
98 void Layout() override;
99 gfx::Size GetMinimumSize() const override;
100 gfx::Size GetPreferredSize() const override;
101 bool OnKeyPressed(const ui::KeyEvent& event) override;
102 bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
104 // Overridden from views::ButtonListener:
105 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
107 // Overridden from views::MenuButtonListener:
108 void OnMenuButtonClicked(views::View* source,
109 const gfx::Point& point) override;
111 views::ImageButton* title_arrow_;
112 views::Label* title_label_;
113 views::MenuButton* notifier_group_selector_;
114 views::ScrollView* scroller_;
115 NotifierSettingsProvider* provider_;
116 std::set<NotifierButton*> buttons_;
117 scoped_ptr<NotifierGroupMenuModel> notifier_group_menu_model_;
118 scoped_ptr<views::MenuRunner> notifier_group_menu_runner_;
120 DISALLOW_COPY_AND_ASSIGN(NotifierSettingsView);
123 } // namespace message_center
125 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_