| OLD | NEW |
| 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // A class to show the list of notifier extensions / URL patterns and allow | 29 // A class to show the list of notifier extensions / URL patterns and allow |
| 30 // users to customize the settings. | 30 // users to customize the settings. |
| 31 class MESSAGE_CENTER_EXPORT NotifierSettingsView | 31 class MESSAGE_CENTER_EXPORT NotifierSettingsView |
| 32 : public NotifierSettingsObserver, | 32 : public NotifierSettingsObserver, |
| 33 public views::View, | 33 public views::View, |
| 34 public views::ButtonListener, | 34 public views::ButtonListener, |
| 35 public views::MenuButtonListener { | 35 public views::MenuButtonListener { |
| 36 public: | 36 public: |
| 37 explicit NotifierSettingsView(NotifierSettingsProvider* provider); | 37 explicit NotifierSettingsView(NotifierSettingsProvider* provider); |
| 38 virtual ~NotifierSettingsView(); | 38 ~NotifierSettingsView() override; |
| 39 | 39 |
| 40 bool IsScrollable(); | 40 bool IsScrollable(); |
| 41 | 41 |
| 42 // Overridden from NotifierSettingsDelegate: | 42 // Overridden from NotifierSettingsDelegate: |
| 43 virtual void UpdateIconImage(const NotifierId& notifier_id, | 43 void UpdateIconImage(const NotifierId& notifier_id, |
| 44 const gfx::Image& icon) override; | 44 const gfx::Image& icon) override; |
| 45 virtual void NotifierGroupChanged() override; | 45 void NotifierGroupChanged() override; |
| 46 virtual void NotifierEnabledChanged(const NotifierId& notifier_id, | 46 void NotifierEnabledChanged(const NotifierId& notifier_id, |
| 47 bool enabled) override; | 47 bool enabled) override; |
| 48 | 48 |
| 49 void set_provider(NotifierSettingsProvider* new_provider) { | 49 void set_provider(NotifierSettingsProvider* new_provider) { |
| 50 provider_ = new_provider; | 50 provider_ = new_provider; |
| 51 } | 51 } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest, TestLearnMoreButton); | 54 FRIEND_TEST_ALL_PREFIXES(NotifierSettingsViewTest, TestLearnMoreButton); |
| 55 | 55 |
| 56 class MESSAGE_CENTER_EXPORT NotifierButton : public views::CustomButton, | 56 class MESSAGE_CENTER_EXPORT NotifierButton : public views::CustomButton, |
| 57 public views::ButtonListener { | 57 public views::ButtonListener { |
| 58 public: | 58 public: |
| 59 NotifierButton(NotifierSettingsProvider* provider, | 59 NotifierButton(NotifierSettingsProvider* provider, |
| 60 Notifier* notifier, | 60 Notifier* notifier, |
| 61 views::ButtonListener* listener); | 61 views::ButtonListener* listener); |
| 62 virtual ~NotifierButton(); | 62 ~NotifierButton() override; |
| 63 | 63 |
| 64 void UpdateIconImage(const gfx::Image& icon); | 64 void UpdateIconImage(const gfx::Image& icon); |
| 65 void SetChecked(bool checked); | 65 void SetChecked(bool checked); |
| 66 bool checked() const; | 66 bool checked() const; |
| 67 bool has_learn_more() const; | 67 bool has_learn_more() const; |
| 68 const Notifier& notifier() const; | 68 const Notifier& notifier() const; |
| 69 | 69 |
| 70 void SendLearnMorePressedForTest(); | 70 void SendLearnMorePressedForTest(); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 // Overridden from views::ButtonListener: | 73 // Overridden from views::ButtonListener: |
| 74 virtual void ButtonPressed(views::Button* button, | 74 void ButtonPressed(views::Button* button, const ui::Event& event) override; |
| 75 const ui::Event& event) override; | 75 void GetAccessibleState(ui::AXViewState* state) override; |
| 76 virtual void GetAccessibleState(ui::AXViewState* state) override; | |
| 77 | 76 |
| 78 bool ShouldHaveLearnMoreButton() const; | 77 bool ShouldHaveLearnMoreButton() const; |
| 79 // Helper function to reset the layout when the view has substantially | 78 // Helper function to reset the layout when the view has substantially |
| 80 // changed. | 79 // changed. |
| 81 void GridChanged(bool has_learn_more, bool has_icon_view); | 80 void GridChanged(bool has_learn_more, bool has_icon_view); |
| 82 | 81 |
| 83 NotifierSettingsProvider* provider_; // Weak. | 82 NotifierSettingsProvider* provider_; // Weak. |
| 84 const scoped_ptr<Notifier> notifier_; | 83 const scoped_ptr<Notifier> notifier_; |
| 85 // |icon_view_| is owned by us because sometimes we don't leave it | 84 // |icon_view_| is owned by us because sometimes we don't leave it |
| 86 // in the view hierarchy. | 85 // in the view hierarchy. |
| 87 scoped_ptr<views::ImageView> icon_view_; | 86 scoped_ptr<views::ImageView> icon_view_; |
| 88 views::Label* name_view_; | 87 views::Label* name_view_; |
| 89 views::Checkbox* checkbox_; | 88 views::Checkbox* checkbox_; |
| 90 views::ImageButton* learn_more_; | 89 views::ImageButton* learn_more_; |
| 91 | 90 |
| 92 DISALLOW_COPY_AND_ASSIGN(NotifierButton); | 91 DISALLOW_COPY_AND_ASSIGN(NotifierButton); |
| 93 }; | 92 }; |
| 94 | 93 |
| 95 // Given a new list of notifiers, updates the view to reflect it. | 94 // Given a new list of notifiers, updates the view to reflect it. |
| 96 void UpdateContentsView(const std::vector<Notifier*>& notifiers); | 95 void UpdateContentsView(const std::vector<Notifier*>& notifiers); |
| 97 | 96 |
| 98 // Overridden from views::View: | 97 // Overridden from views::View: |
| 99 virtual void Layout() override; | 98 void Layout() override; |
| 100 virtual gfx::Size GetMinimumSize() const override; | 99 gfx::Size GetMinimumSize() const override; |
| 101 virtual gfx::Size GetPreferredSize() const override; | 100 gfx::Size GetPreferredSize() const override; |
| 102 virtual bool OnKeyPressed(const ui::KeyEvent& event) override; | 101 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 103 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) override; | 102 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; |
| 104 | 103 |
| 105 // Overridden from views::ButtonListener: | 104 // Overridden from views::ButtonListener: |
| 106 virtual void ButtonPressed(views::Button* sender, | 105 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 107 const ui::Event& event) override; | |
| 108 | 106 |
| 109 // Overridden from views::MenuButtonListener: | 107 // Overridden from views::MenuButtonListener: |
| 110 virtual void OnMenuButtonClicked(views::View* source, | 108 void OnMenuButtonClicked(views::View* source, |
| 111 const gfx::Point& point) override; | 109 const gfx::Point& point) override; |
| 112 | 110 |
| 113 views::ImageButton* title_arrow_; | 111 views::ImageButton* title_arrow_; |
| 114 views::Label* title_label_; | 112 views::Label* title_label_; |
| 115 views::MenuButton* notifier_group_selector_; | 113 views::MenuButton* notifier_group_selector_; |
| 116 views::ScrollView* scroller_; | 114 views::ScrollView* scroller_; |
| 117 NotifierSettingsProvider* provider_; | 115 NotifierSettingsProvider* provider_; |
| 118 std::set<NotifierButton*> buttons_; | 116 std::set<NotifierButton*> buttons_; |
| 119 scoped_ptr<NotifierGroupMenuModel> notifier_group_menu_model_; | 117 scoped_ptr<NotifierGroupMenuModel> notifier_group_menu_model_; |
| 120 scoped_ptr<views::MenuRunner> notifier_group_menu_runner_; | 118 scoped_ptr<views::MenuRunner> notifier_group_menu_runner_; |
| 121 | 119 |
| 122 DISALLOW_COPY_AND_ASSIGN(NotifierSettingsView); | 120 DISALLOW_COPY_AND_ASSIGN(NotifierSettingsView); |
| 123 }; | 121 }; |
| 124 | 122 |
| 125 } // namespace message_center | 123 } // namespace message_center |
| 126 | 124 |
| 127 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_ | 125 #endif // UI_MESSAGE_CENTER_VIEWS_NOTIFIER_SETTINGS_VIEW_H_ |
| OLD | NEW |