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_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 5 #ifndef ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
6 #define ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 6 #define ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/system/tray/tray_background_view.h" | 9 #include "ash/system/tray/tray_background_view.h" |
10 #include "ash/system/user/login_status.h" | 10 #include "ash/system/user/login_status.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "ui/aura/event_filter.h" | 12 #include "ui/aura/event_filter.h" |
13 | 13 |
14 namespace aura { | 14 namespace aura { |
15 class LocatedEvent; | 15 class LocatedEvent; |
16 } | 16 } |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 class ImageSkia; | 19 class ImageSkia; |
20 } | 20 } |
21 | 21 |
22 namespace views { | 22 namespace views { |
23 class Label; | 23 class ImageButton; |
24 } | 24 } |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 | 27 |
28 namespace internal { | 28 namespace internal { |
29 class StatusAreaWidget; | 29 class StatusAreaWidget; |
30 class WebNotificationButtonView; | 30 class WebNotificationButtonView; |
31 class WebNotificationList; | 31 class WebNotificationList; |
32 class WebNotificationMenuModel; | 32 class WebNotificationMenuModel; |
33 class WebNotificationView; | 33 class WebNotificationView; |
34 } | 34 } |
35 | 35 |
36 // Status area tray for showing browser and app notifications. The client | 36 // Status area tray for showing browser and app notifications. The client |
37 // (e.g. Chrome) calls [Add|Remove|Update]Notification to create and update | 37 // (e.g. Chrome) calls [Add|Remove|Update]Notification to create and update |
38 // notifications in the tray. It can also implement Delegate to receive | 38 // notifications in the tray. It can also implement Delegate to receive |
39 // callbacks when a notification is removed (closed), clicked on, or a menu | 39 // callbacks when a notification is removed (closed), clicked on, or a menu |
40 // item is triggered. | 40 // item is triggered. |
41 // | 41 // |
42 // Note: These are not related to system notifications (i.e NotificationView | 42 // Note: These are not related to system notifications (i.e NotificationView |
43 // generated by SystemTrayItem). Visibility of one notification type or other | 43 // generated by SystemTrayItem). Visibility of one notification type or other |
44 // is controlled by StatusAreaWidget. | 44 // is controlled by StatusAreaWidget. |
45 | 45 |
46 class ASH_EXPORT WebNotificationTray : public internal::TrayBackgroundView { | 46 class ASH_EXPORT WebNotificationTray : public internal::TrayBackgroundView, |
| 47 public views::ButtonListener { |
47 public: | 48 public: |
48 class Delegate { | 49 class Delegate { |
49 public: | 50 public: |
50 virtual ~Delegate() {} | 51 virtual ~Delegate() {} |
51 | 52 |
52 // Called when the notification associated with |notification_id| is | 53 // Called when the notification associated with |notification_id| is |
53 // removed (i.e. closed by the user). | 54 // removed (i.e. closed by the user). |
54 virtual void NotificationRemoved(const std::string& notifcation_id) = 0; | 55 virtual void NotificationRemoved(const std::string& notifcation_id) = 0; |
55 | 56 |
56 // Request to disable the extension associated with |notification_id|. | 57 // Request to disable the extension associated with |notification_id|. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool IsMouseInNotificationBubble() const; | 115 bool IsMouseInNotificationBubble() const; |
115 | 116 |
116 // Overridden from TrayBackgroundView. | 117 // Overridden from TrayBackgroundView. |
117 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | 118 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; |
118 virtual void AnchorUpdated() OVERRIDE; | 119 virtual void AnchorUpdated() OVERRIDE; |
119 virtual string16 GetAccessibleName() OVERRIDE; | 120 virtual string16 GetAccessibleName() OVERRIDE; |
120 | 121 |
121 // Overridden from internal::ActionableView. | 122 // Overridden from internal::ActionableView. |
122 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 123 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
123 | 124 |
| 125 // Overridden from ButtonListener. |
| 126 virtual void ButtonPressed(views::Button* sender, |
| 127 const ui::Event& event) OVERRIDE; |
| 128 |
124 // Constants exposed for unit tests: | 129 // Constants exposed for unit tests: |
125 static const size_t kMaxVisibleTrayNotifications; | 130 static const size_t kMaxVisibleTrayNotifications; |
126 static const size_t kMaxVisiblePopupNotifications; | 131 static const size_t kMaxVisiblePopupNotifications; |
127 | 132 |
128 private: | 133 private: |
129 class Bubble; | 134 class Bubble; |
130 class MessageCenterBubble; | 135 class MessageCenterBubble; |
131 class PopupBubble; | 136 class PopupBubble; |
132 friend class internal::WebNotificationButtonView; | 137 friend class internal::WebNotificationButtonView; |
133 friend class internal::WebNotificationMenuModel; | 138 friend class internal::WebNotificationMenuModel; |
(...skipping 14 matching lines...) Expand all Loading... |
148 // Disables all notifications matching notification |id|. | 153 // Disables all notifications matching notification |id|. |
149 void DisableByExtension(const std::string& id); | 154 void DisableByExtension(const std::string& id); |
150 void DisableByUrl(const std::string& id); | 155 void DisableByUrl(const std::string& id); |
151 | 156 |
152 // Requests the Delegate to the settings dialog. | 157 // Requests the Delegate to the settings dialog. |
153 void ShowSettings(const std::string& id); | 158 void ShowSettings(const std::string& id); |
154 | 159 |
155 // Called when a notification is clicked on. Event is passed to the Delegate. | 160 // Called when a notification is clicked on. Event is passed to the Delegate. |
156 void OnClicked(const std::string& id); | 161 void OnClicked(const std::string& id); |
157 | 162 |
| 163 // Shows or hides the message center bubble. |
| 164 void ToggleMessageCenterBubble(); |
| 165 |
158 // Shows or updates the message center bubble and hides the popup bubble. | 166 // Shows or updates the message center bubble and hides the popup bubble. |
159 void ShowMessageCenterBubble(); | 167 void ShowMessageCenterBubble(); |
160 | 168 |
161 // Hides the message center bubble if visible. | 169 // Hides the message center bubble if visible. |
162 void HideMessageCenterBubble(); | 170 void HideMessageCenterBubble(); |
163 | 171 |
164 // Shows or updates the popup notification bubble if appropriate. | 172 // Shows or updates the popup notification bubble if appropriate. |
165 void ShowPopupBubble(); | 173 void ShowPopupBubble(); |
166 | 174 |
167 // Hides the notification bubble if visible. | 175 // Hides the notification bubble if visible. |
(...skipping 19 matching lines...) Expand all Loading... |
187 return notification_list_.get(); | 195 return notification_list_.get(); |
188 } | 196 } |
189 MessageCenterBubble* message_center_bubble() const { | 197 MessageCenterBubble* message_center_bubble() const { |
190 return message_center_bubble_.get(); | 198 return message_center_bubble_.get(); |
191 } | 199 } |
192 PopupBubble* popup_bubble() const { return popup_bubble_.get(); } | 200 PopupBubble* popup_bubble() const { return popup_bubble_.get(); } |
193 | 201 |
194 scoped_ptr<internal::WebNotificationList> notification_list_; | 202 scoped_ptr<internal::WebNotificationList> notification_list_; |
195 scoped_ptr<MessageCenterBubble> message_center_bubble_; | 203 scoped_ptr<MessageCenterBubble> message_center_bubble_; |
196 scoped_ptr<PopupBubble> popup_bubble_; | 204 scoped_ptr<PopupBubble> popup_bubble_; |
197 views::Label* count_label_; | 205 views::ImageButton* button_; |
198 Delegate* delegate_; | 206 Delegate* delegate_; |
199 bool show_message_center_on_unlock_; | 207 bool show_message_center_on_unlock_; |
200 | 208 |
201 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 209 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
202 }; | 210 }; |
203 | 211 |
204 } // namespace ash | 212 } // namespace ash |
205 | 213 |
206 #endif // ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 214 #endif // ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
OLD | NEW |