OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 5 #ifndef ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
6 #define ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 6 #define ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/common/login_status.h" | 11 #include "ash/common/login_status.h" |
12 #include "ash/common/system/tray/tray_background_view.h" | 12 #include "ash/common/system/tray/tray_background_view.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "ui/base/models/simple_menu_model.h" | 16 #include "ui/base/models/simple_menu_model.h" |
| 17 #include "ui/gfx/animation/animation_container.h" |
17 #include "ui/message_center/message_center_tray.h" | 18 #include "ui/message_center/message_center_tray.h" |
18 #include "ui/message_center/message_center_tray_delegate.h" | 19 #include "ui/message_center/message_center_tray_delegate.h" |
19 #include "ui/views/bubble/tray_bubble_view.h" | 20 #include "ui/views/bubble/tray_bubble_view.h" |
20 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
21 | 22 |
22 // Status area tray for showing browser and app notifications. This hosts | 23 // Status area tray for showing browser and app notifications. This hosts |
23 // a MessageCenter class which manages the notification list. This class | 24 // a MessageCenter class which manages the notification list. This class |
24 // contains the Ash specific tray implementation. | 25 // contains the Ash specific tray implementation. |
25 // | 26 // |
26 // Note: These are not related to system notifications (i.e NotificationView | 27 // Note: These are not related to system notifications (i.e NotificationView |
(...skipping 10 matching lines...) Expand all Loading... |
37 class MessageCenter; | 38 class MessageCenter; |
38 class MessageCenterBubble; | 39 class MessageCenterBubble; |
39 class MessagePopupCollection; | 40 class MessagePopupCollection; |
40 } | 41 } |
41 | 42 |
42 namespace ash { | 43 namespace ash { |
43 class AshPopupAlignmentDelegate; | 44 class AshPopupAlignmentDelegate; |
44 class SystemTray; | 45 class SystemTray; |
45 class WebNotificationBubbleWrapper; | 46 class WebNotificationBubbleWrapper; |
46 class WebNotificationButton; | 47 class WebNotificationButton; |
| 48 class WebNotificationImage; |
| 49 class WebNotificationLabel; |
47 class WmWindow; | 50 class WmWindow; |
48 | 51 |
49 class ASH_EXPORT WebNotificationTray | 52 class ASH_EXPORT WebNotificationTray |
50 : public TrayBackgroundView, | 53 : public TrayBackgroundView, |
51 public views::TrayBubbleView::Delegate, | 54 public views::TrayBubbleView::Delegate, |
52 public message_center::MessageCenterTrayDelegate, | 55 public message_center::MessageCenterTrayDelegate, |
53 public views::ButtonListener, | |
54 public base::SupportsWeakPtr<WebNotificationTray>, | 56 public base::SupportsWeakPtr<WebNotificationTray>, |
55 public ui::SimpleMenuModel::Delegate { | 57 public ui::SimpleMenuModel::Delegate { |
56 public: | 58 public: |
57 WebNotificationTray(WmShelf* shelf, | 59 WebNotificationTray(WmShelf* shelf, |
58 WmWindow* status_area_window, | 60 WmWindow* status_area_window, |
59 SystemTray* system_tray); | 61 SystemTray* system_tray); |
60 ~WebNotificationTray() override; | 62 ~WebNotificationTray() override; |
61 | 63 |
| 64 static void DisableAnimationsForTest(bool disable); |
| 65 |
62 // Sets the height of the system tray bubble (or legacy notification bubble) | 66 // Sets the height of the system tray bubble (or legacy notification bubble) |
63 // from the edge of the work area so that the web notification popups don't | 67 // from the edge of the work area so that the web notification popups don't |
64 // overlap with the tray. Pass 0 if no bubble is shown. | 68 // overlap with the tray. Pass 0 if no bubble is shown. |
65 void SetTrayBubbleHeight(int height); | 69 void SetTrayBubbleHeight(int height); |
66 | 70 |
67 // Returns the current tray bubble height or 0 if there is no bubble. | 71 // Returns the current tray bubble height or 0 if there is no bubble. |
68 int tray_bubble_height_for_test() const; | 72 int tray_bubble_height_for_test() const; |
69 | 73 |
70 // Returns true if it should block the auto hide behavior of the shelf. | 74 // Returns true if it should block the auto hide behavior of the shelf. |
71 bool ShouldBlockShelfAutoHide() const; | 75 bool ShouldBlockShelfAutoHide() const; |
(...skipping 27 matching lines...) Expand all Loading... |
99 base::string16 GetAccessibleNameForBubble() override; | 103 base::string16 GetAccessibleNameForBubble() override; |
100 gfx::Rect GetAnchorRect(views::Widget* anchor_widget, | 104 gfx::Rect GetAnchorRect(views::Widget* anchor_widget, |
101 AnchorType anchor_type, | 105 AnchorType anchor_type, |
102 AnchorAlignment anchor_alignment) const override; | 106 AnchorAlignment anchor_alignment) const override; |
103 void OnBeforeBubbleWidgetInit( | 107 void OnBeforeBubbleWidgetInit( |
104 views::Widget* anchor_widget, | 108 views::Widget* anchor_widget, |
105 views::Widget* bubble_widget, | 109 views::Widget* bubble_widget, |
106 views::Widget::InitParams* params) const override; | 110 views::Widget::InitParams* params) const override; |
107 void HideBubble(const views::TrayBubbleView* bubble_view) override; | 111 void HideBubble(const views::TrayBubbleView* bubble_view) override; |
108 | 112 |
109 // Overridden from ButtonListener. | |
110 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
111 | |
112 // Overridden from MessageCenterTrayDelegate. | 113 // Overridden from MessageCenterTrayDelegate. |
113 void OnMessageCenterTrayChanged() override; | 114 void OnMessageCenterTrayChanged() override; |
114 bool ShowMessageCenter() override; | 115 bool ShowMessageCenter() override; |
115 void HideMessageCenter() override; | 116 void HideMessageCenter() override; |
116 bool ShowPopups() override; | 117 bool ShowPopups() override; |
117 void HidePopups() override; | 118 void HidePopups() override; |
118 bool ShowNotifierSettings() override; | 119 bool ShowNotifierSettings() override; |
119 bool IsContextMenuEnabled() const override; | 120 bool IsContextMenuEnabled() const override; |
120 message_center::MessageCenterTray* GetMessageCenterTray() override; | 121 message_center::MessageCenterTray* GetMessageCenterTray() override; |
121 | 122 |
122 // Overridden from SimpleMenuModel::Delegate. | 123 // Overridden from ui::SimpleMenuModel::Delegate. |
123 bool IsCommandIdChecked(int command_id) const override; | 124 bool IsCommandIdChecked(int command_id) const override; |
124 bool IsCommandIdEnabled(int command_id) const override; | 125 bool IsCommandIdEnabled(int command_id) const override; |
125 void ExecuteCommand(int command_id, int event_flags) override; | 126 void ExecuteCommand(int command_id, int event_flags) override; |
126 | 127 |
127 message_center::MessageCenter* message_center() const; | 128 message_center::MessageCenter* message_center() const; |
128 | 129 |
129 private: | 130 private: |
130 friend class WebNotificationTrayTest; | 131 friend class WebNotificationTrayTest; |
131 | 132 |
132 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 133 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 169 |
169 // Testing accessors. | 170 // Testing accessors. |
170 bool IsPopupVisible() const; | 171 bool IsPopupVisible() const; |
171 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | 172 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); |
172 | 173 |
173 WmWindow* status_area_window_; | 174 WmWindow* status_area_window_; |
174 SystemTray* system_tray_; | 175 SystemTray* system_tray_; |
175 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; | 176 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; |
176 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; | 177 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; |
177 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; | 178 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; |
178 WebNotificationButton* button_; | 179 std::unique_ptr<WebNotificationImage> bell_icon_; |
| 180 std::unique_ptr<WebNotificationLabel> counter_; |
| 181 |
| 182 scoped_refptr<gfx::AnimationContainer> animation_container_ = |
| 183 new gfx::AnimationContainer(); |
| 184 |
| 185 std::unordered_map<std::string, WebNotificationImage*> visible_small_icons_; |
179 | 186 |
180 bool show_message_center_on_unlock_; | 187 bool show_message_center_on_unlock_; |
181 | 188 |
182 bool should_update_tray_content_; | 189 bool should_update_tray_content_; |
183 | 190 |
184 // True when the shelf auto hide behavior has to be blocked. Previously | 191 // True when the shelf auto hide behavior has to be blocked. Previously |
185 // this was done by checking |message_center_bubble_| but actually | 192 // this was done by checking |message_center_bubble_| but actually |
186 // the check can be called when creating this object, so it would cause | 193 // the check can be called when creating this object, so it would cause |
187 // flickers of the shelf from hidden to shown. See: crbug.com/181213 | 194 // flickers of the shelf from hidden to shown. See: crbug.com/181213 |
188 bool should_block_shelf_auto_hide_; | 195 bool should_block_shelf_auto_hide_; |
189 | 196 |
190 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; | 197 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; |
191 | 198 |
192 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 199 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
193 }; | 200 }; |
194 | 201 |
195 } // namespace ash | 202 } // namespace ash |
196 | 203 |
197 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 204 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
OLD | NEW |