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" | |
18 #include "ui/message_center/message_center_tray.h" | 17 #include "ui/message_center/message_center_tray.h" |
19 #include "ui/message_center/message_center_tray_delegate.h" | 18 #include "ui/message_center/message_center_tray_delegate.h" |
20 #include "ui/views/bubble/tray_bubble_view.h" | 19 #include "ui/views/bubble/tray_bubble_view.h" |
21 | 20 |
22 // Status area tray for showing browser and app notifications. This hosts | 21 // Status area tray for showing browser and app notifications. This hosts |
23 // a MessageCenter class which manages the notification list. This class | 22 // a MessageCenter class which manages the notification list. This class |
24 // contains the Ash specific tray implementation. | 23 // contains the Ash specific tray implementation. |
25 // | 24 // |
26 // Note: These are not related to system notifications (i.e NotificationView | 25 // Note: These are not related to system notifications (i.e NotificationView |
27 // generated by SystemTrayItem). Visibility of one notification type or other | 26 // generated by SystemTrayItem). Visibility of one notification type or other |
28 // is controlled by StatusAreaWidget. | 27 // is controlled by StatusAreaWidget. |
29 | 28 |
30 namespace views { | 29 namespace views { |
31 class MenuRunner; | 30 class MenuRunner; |
32 } | 31 } |
33 | 32 |
34 namespace message_center { | 33 namespace message_center { |
35 class MessageBubbleBase; | 34 class MessageBubbleBase; |
36 class MessageCenter; | 35 class MessageCenter; |
37 class MessageCenterBubble; | 36 class MessageCenterBubble; |
38 class MessagePopupCollection; | 37 class MessagePopupCollection; |
39 } | 38 } |
40 | 39 |
41 namespace ash { | 40 namespace ash { |
42 class AshPopupAlignmentDelegate; | 41 class AshPopupAlignmentDelegate; |
43 class SystemTray; | 42 class SystemTray; |
44 class WebNotificationBubbleWrapper; | 43 class WebNotificationBubbleWrapper; |
45 class WebNotificationButton; | 44 class WebNotificationIcon; |
46 class WebNotificationImage; | |
47 class WebNotificationLabel; | |
48 class WmWindow; | 45 class WmWindow; |
49 | 46 |
50 class ASH_EXPORT WebNotificationTray | 47 class ASH_EXPORT WebNotificationTray |
51 : public TrayBackgroundView, | 48 : public TrayBackgroundView, |
52 public views::TrayBubbleView::Delegate, | 49 public views::TrayBubbleView::Delegate, |
53 public message_center::MessageCenterTrayDelegate, | 50 public message_center::MessageCenterTrayDelegate, |
54 public base::SupportsWeakPtr<WebNotificationTray>, | 51 public base::SupportsWeakPtr<WebNotificationTray>, |
55 public ui::SimpleMenuModel::Delegate { | 52 public ui::SimpleMenuModel::Delegate { |
56 public: | 53 public: |
57 WebNotificationTray(WmShelf* shelf, | 54 WebNotificationTray(WmShelf* shelf, |
58 WmWindow* status_area_window, | 55 WmWindow* status_area_window, |
59 SystemTray* system_tray); | 56 SystemTray* system_tray); |
60 ~WebNotificationTray() override; | 57 ~WebNotificationTray() override; |
61 | 58 |
62 static void DisableAnimationsForTest(bool disable); | |
63 | |
64 // Sets the height of the system tray bubble (or legacy notification bubble) | 59 // Sets the height of the system tray bubble (or legacy notification bubble) |
65 // from the edge of the work area so that the web notification popups don't | 60 // from the edge of the work area so that the web notification popups don't |
66 // overlap with the tray. Pass 0 if no bubble is shown. | 61 // overlap with the tray. Pass 0 if no bubble is shown. |
67 void SetTrayBubbleHeight(int height); | 62 void SetTrayBubbleHeight(int height); |
68 | 63 |
69 // Returns the current tray bubble height or 0 if there is no bubble. | 64 // Returns the current tray bubble height or 0 if there is no bubble. |
70 int tray_bubble_height_for_test() const; | 65 int tray_bubble_height_for_test() const; |
71 | 66 |
72 // Returns true if it should block the auto hide behavior of the shelf. | 67 // Returns true if it should block the auto hide behavior of the shelf. |
73 bool ShouldBlockShelfAutoHide() const; | 68 bool ShouldBlockShelfAutoHide() const; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Overridden from MessageCenterTrayDelegate. | 106 // Overridden from MessageCenterTrayDelegate. |
112 void OnMessageCenterTrayChanged() override; | 107 void OnMessageCenterTrayChanged() override; |
113 bool ShowMessageCenter() override; | 108 bool ShowMessageCenter() override; |
114 void HideMessageCenter() override; | 109 void HideMessageCenter() override; |
115 bool ShowPopups() override; | 110 bool ShowPopups() override; |
116 void HidePopups() override; | 111 void HidePopups() override; |
117 bool ShowNotifierSettings() override; | 112 bool ShowNotifierSettings() override; |
118 bool IsContextMenuEnabled() const override; | 113 bool IsContextMenuEnabled() const override; |
119 message_center::MessageCenterTray* GetMessageCenterTray() override; | 114 message_center::MessageCenterTray* GetMessageCenterTray() override; |
120 | 115 |
121 // Overridden from ui::SimpleMenuModel::Delegate. | 116 // Overridden from SimpleMenuModel::Delegate. |
122 bool IsCommandIdChecked(int command_id) const override; | 117 bool IsCommandIdChecked(int command_id) const override; |
123 bool IsCommandIdEnabled(int command_id) const override; | 118 bool IsCommandIdEnabled(int command_id) const override; |
124 void ExecuteCommand(int command_id, int event_flags) override; | 119 void ExecuteCommand(int command_id, int event_flags) override; |
125 | 120 |
126 message_center::MessageCenter* message_center() const; | 121 message_center::MessageCenter* message_center() const; |
127 | 122 |
128 private: | 123 private: |
129 friend class WebNotificationTrayTest; | 124 friend class WebNotificationTrayTest; |
130 | 125 |
131 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 126 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 162 |
168 // Testing accessors. | 163 // Testing accessors. |
169 bool IsPopupVisible() const; | 164 bool IsPopupVisible() const; |
170 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | 165 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); |
171 | 166 |
172 WmWindow* status_area_window_; | 167 WmWindow* status_area_window_; |
173 SystemTray* system_tray_; | 168 SystemTray* system_tray_; |
174 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; | 169 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; |
175 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; | 170 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; |
176 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; | 171 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; |
177 std::unique_ptr<WebNotificationImage> bell_icon_; | 172 WebNotificationIcon* icon_; |
178 std::unique_ptr<WebNotificationLabel> counter_; | |
179 | |
180 scoped_refptr<gfx::AnimationContainer> animation_container_ = | |
181 new gfx::AnimationContainer(); | |
182 | |
183 std::unordered_map<std::string, WebNotificationImage*> visible_small_icons_; | |
184 | 173 |
185 bool show_message_center_on_unlock_; | 174 bool show_message_center_on_unlock_; |
186 | 175 |
187 bool should_update_tray_content_; | 176 bool should_update_tray_content_; |
188 | 177 |
189 // True when the shelf auto hide behavior has to be blocked. Previously | 178 // True when the shelf auto hide behavior has to be blocked. Previously |
190 // this was done by checking |message_center_bubble_| but actually | 179 // this was done by checking |message_center_bubble_| but actually |
191 // the check can be called when creating this object, so it would cause | 180 // the check can be called when creating this object, so it would cause |
192 // flickers of the shelf from hidden to shown. See: crbug.com/181213 | 181 // flickers of the shelf from hidden to shown. See: crbug.com/181213 |
193 bool should_block_shelf_auto_hide_; | 182 bool should_block_shelf_auto_hide_; |
194 | 183 |
195 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; | 184 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; |
196 | 185 |
197 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 186 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
198 }; | 187 }; |
199 | 188 |
200 } // namespace ash | 189 } // namespace ash |
201 | 190 |
202 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 191 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
OLD | NEW |