Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Side by Side Diff: ui/message_center/views/notifier_settings_view.h

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: fix cros build Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_ 5 #ifndef UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_ 6 #define UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
(...skipping 17 matching lines...) Expand all
28 class Label; 28 class Label;
29 } 29 }
30 30
31 namespace message_center { 31 namespace message_center {
32 32
33 // A class to show the list of notifier extensions / URL patterns and allow 33 // A class to show the list of notifier extensions / URL patterns and allow
34 // users to customize the settings. 34 // users to customize the settings.
35 class MESSAGE_CENTER_EXPORT NotifierSettingsView 35 class MESSAGE_CENTER_EXPORT NotifierSettingsView
36 : public NotifierSettingsObserver, 36 : public NotifierSettingsObserver,
37 public views::View, 37 public views::View,
38 public views::ButtonListener, 38 public views::ImageButtonDelegate,
39 public views::ComboboxListener { 39 public views::ComboboxListener {
40 public: 40 public:
41 explicit NotifierSettingsView(NotifierSettingsProvider* provider); 41 explicit NotifierSettingsView(NotifierSettingsProvider* provider);
42 ~NotifierSettingsView() override; 42 ~NotifierSettingsView() override;
43 43
44 bool IsScrollable(); 44 bool IsScrollable();
45 45
46 // Overridden from NotifierSettingsDelegate: 46 // NotifierSettingsDelegate:
47 void UpdateIconImage(const NotifierId& notifier_id, 47 void UpdateIconImage(const NotifierId& notifier_id,
48 const gfx::Image& icon) override; 48 const gfx::Image& icon) override;
49 void NotifierGroupChanged() override; 49 void NotifierGroupChanged() override;
50 void NotifierEnabledChanged(const NotifierId& notifier_id, 50 void NotifierEnabledChanged(const NotifierId& notifier_id,
51 bool enabled) override; 51 bool enabled) override;
52 52
53 void set_provider(NotifierSettingsProvider* new_provider) { 53 void set_provider(NotifierSettingsProvider* new_provider) {
54 provider_ = new_provider; 54 provider_ = new_provider;
55 } 55 }
56 56
57 private: 57 private:
58 FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest, TestLearnMoreButton); 58 FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest, TestLearnMoreButton);
59 59
60 class MESSAGE_CENTER_EXPORT NotifierButton : public views::CustomButton, 60 class MESSAGE_CENTER_EXPORT NotifierButton
61 public views::ButtonListener { 61 : public views::CustomButton,
62 public views::ImageButtonDelegate {
62 public: 63 public:
63 NotifierButton(NotifierSettingsProvider* provider, 64 NotifierButton(NotifierSettingsProvider* provider,
64 std::unique_ptr<Notifier> notifier, 65 std::unique_ptr<Notifier> notifier,
65 views::ButtonListener* listener); 66 views::ImageButtonDelegate* listener);
66 ~NotifierButton() override; 67 ~NotifierButton() override;
67 68
68 void UpdateIconImage(const gfx::Image& icon); 69 void UpdateIconImage(const gfx::Image& icon);
69 void SetChecked(bool checked); 70 void SetChecked(bool checked);
70 bool checked() const; 71 bool checked() const;
71 bool has_learn_more() const; 72 bool has_learn_more() const;
72 const Notifier& notifier() const; 73 const Notifier& notifier() const;
73 74
74 void SendLearnMorePressedForTest(); 75 void SendLearnMorePressedForTest();
75 76
76 private: 77 private:
77 // Overridden from views::ButtonListener: 78 // views::ImageButtonDelegate:
78 void ButtonPressed(views::Button* button, const ui::Event& event) override; 79 void ButtonPressed(views::Button* button, const ui::Event& event) override;
79 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 80 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
80 81
81 bool ShouldHaveLearnMoreButton() const; 82 bool ShouldHaveLearnMoreButton() const;
82 // Helper function to reset the layout when the view has substantially 83 // Helper function to reset the layout when the view has substantially
83 // changed. 84 // changed.
84 void GridChanged(bool has_learn_more, bool has_icon_view); 85 void GridChanged(bool has_learn_more, bool has_icon_view);
85 86
86 NotifierSettingsProvider* provider_; // Weak. 87 NotifierSettingsProvider* provider_; // Weak.
87 std::unique_ptr<Notifier> notifier_; 88 std::unique_ptr<Notifier> notifier_;
88 // |icon_view_| is owned by us because sometimes we don't leave it 89 // |icon_view_| is owned by us because sometimes we don't leave it
89 // in the view hierarchy. 90 // in the view hierarchy.
90 std::unique_ptr<views::ImageView> icon_view_; 91 std::unique_ptr<views::ImageView> icon_view_;
91 views::Label* name_view_; 92 views::Label* name_view_;
92 views::Checkbox* checkbox_; 93 views::Checkbox* checkbox_;
93 views::ImageButton* learn_more_; 94 views::ImageButton* learn_more_;
94 95
95 DISALLOW_COPY_AND_ASSIGN(NotifierButton); 96 DISALLOW_COPY_AND_ASSIGN(NotifierButton);
96 }; 97 };
97 98
98 // Given a new list of notifiers, updates the view to reflect it. 99 // Given a new list of notifiers, updates the view to reflect it.
99 void UpdateContentsView(std::vector<std::unique_ptr<Notifier>> notifiers); 100 void UpdateContentsView(std::vector<std::unique_ptr<Notifier>> notifiers);
100 101
101 // Overridden from views::View: 102 // views::View:
102 void Layout() override; 103 void Layout() override;
103 gfx::Size GetMinimumSize() const override; 104 gfx::Size GetMinimumSize() const override;
104 gfx::Size GetPreferredSize() const override; 105 gfx::Size GetPreferredSize() const override;
105 bool OnKeyPressed(const ui::KeyEvent& event) override; 106 bool OnKeyPressed(const ui::KeyEvent& event) override;
106 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; 107 bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
107 108
108 // Overridden from views::ButtonListener: 109 // views::ImageButtonDelegate:
109 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 110 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
110 111
111 // Overridden from views::ComboboxListener: 112 // views::ComboboxListener:
112 void OnPerformAction(views::Combobox* combobox) override; 113 void OnPerformAction(views::Combobox* combobox) override;
113 114
114 // Callback for views::MenuModelAdapter. 115 // Callback for views::MenuModelAdapter.
115 void OnMenuClosed(); 116 void OnMenuClosed();
116 117
117 views::ImageButton* title_arrow_; 118 views::ImageButton* title_arrow_;
118 views::Label* title_label_; 119 views::Label* title_label_;
119 views::Combobox* notifier_group_combobox_; 120 views::Combobox* notifier_group_combobox_;
120 views::ScrollView* scroller_; 121 views::ScrollView* scroller_;
121 NotifierSettingsProvider* provider_; 122 NotifierSettingsProvider* provider_;
122 std::set<NotifierButton*> buttons_; 123 std::set<NotifierButton*> buttons_;
123 std::unique_ptr<ui::ComboboxModel> notifier_group_model_; 124 std::unique_ptr<ui::ComboboxModel> notifier_group_model_;
124 125
125 DISALLOW_COPY_AND_ASSIGN(NotifierSettingsView); 126 DISALLOW_COPY_AND_ASSIGN(NotifierSettingsView);
126 }; 127 };
127 128
128 } // namespace message_center 129 } // namespace message_center
129 130
130 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_ 131 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698