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_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 5 #ifndef ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
6 #define ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 6 #define ASH_SYSTEM_WEB_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/tray/tray_views.h" | |
11 #include "ash/system/user/login_status.h" | 10 #include "ash/system/user/login_status.h" |
12 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
13 #include "ui/message_center/message_center.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/message_center/message_center_tray.h" | |
14 #include "ui/message_center/message_center_tray_host.h" | |
15 #include "ui/views/bubble/tray_bubble_view.h" | |
14 #include "ui/views/widget/widget_observer.h" | 16 #include "ui/views/widget/widget_observer.h" |
15 | 17 |
16 // Status area tray for showing browser and app notifications. This hosts | 18 // Status area tray for showing browser and app notifications. This hosts |
17 // a MessageCenter class which manages the notification list. This class | 19 // a MessageCenter class which manages the notification list. This class |
18 // contains the Ash specific tray implementation. | 20 // contains the Ash specific tray implementation. |
19 // | 21 // |
20 // Note: These are not related to system notifications (i.e NotificationView | 22 // Note: These are not related to system notifications (i.e NotificationView |
21 // generated by SystemTrayItem). Visibility of one notification type or other | 23 // generated by SystemTrayItem). Visibility of one notification type or other |
22 // is controlled by StatusAreaWidget. | 24 // is controlled by StatusAreaWidget. |
23 | 25 |
24 namespace aura { | 26 namespace message_center { |
25 class LocatedEvent; | 27 class MessageCenter; |
26 } | 28 } |
27 | 29 |
28 namespace gfx { | 30 FORWARD_DECLARE_TEST(WebNotificationTrayTest, |
29 class ImageSkia; | 31 ManyMessageCenterNotifications); |
30 } | |
31 | |
32 namespace views { | |
33 class ImageButton; | |
34 class TrayBubbleView; | |
35 class Widget; | |
36 } | |
37 | |
38 namespace message_center { | |
39 class MessageCenterBubble; | |
40 class MessagePopupBubble; | |
41 class QuietModeBubble; | |
42 } | |
43 | 32 |
44 namespace ash { | 33 namespace ash { |
45 | 34 |
46 namespace internal { | 35 namespace internal { |
47 class StatusAreaWidget; | 36 class StatusAreaWidget; |
48 class WebNotificationBubbleWrapper; | |
49 } | 37 } |
50 | 38 |
51 class ASH_EXPORT WebNotificationTray | 39 class ASH_EXPORT WebNotificationTray |
52 : public internal::TrayBackgroundView, | 40 : public internal::TrayBackgroundView, |
53 public views::TrayBubbleView::Delegate, | 41 public ui::MessageCenterTrayHost, |
54 public message_center::MessageCenter::Observer, | |
55 public views::ButtonListener, | 42 public views::ButtonListener, |
56 public views::WidgetObserver { | 43 public views::WidgetObserver { |
57 public: | 44 public: |
58 explicit WebNotificationTray(internal::StatusAreaWidget* status_area_widget); | 45 explicit WebNotificationTray( |
46 internal::StatusAreaWidget* status_area_widget); | |
59 virtual ~WebNotificationTray(); | 47 virtual ~WebNotificationTray(); |
60 | 48 |
49 virtual bool CanShowMessageCenter(); | |
50 | |
51 // MessageCenterTrayHost implementation part one. | |
52 virtual message_center::MessageCenter* message_center() OVERRIDE; | |
53 virtual void OnShowMessageCenterBubble() OVERRIDE; | |
54 virtual void OnHideMessageCenterBubble() OVERRIDE; | |
55 | |
61 // Set whether or not the popup notifications should be hidden. | 56 // Set whether or not the popup notifications should be hidden. |
62 void SetHidePopupBubble(bool hide); | 57 void SetHidePopupBubble(bool hide); |
63 | 58 |
59 // MessageCenterTrayHost implementation part two. | |
60 virtual bool CanShowPopups() OVERRIDE; | |
61 | |
62 // Displays the quiet mode bubble and adds |this| as an observer. | |
Pete Williamson
2013/01/16 19:43:20
The comment makes it sound like the function does
dewittj
2013/01/16 22:30:40
This isn't a functionality change, just updated co
| |
63 void ShowQuietModeBubble(); | |
64 | |
64 // Updates tray visibility login status of the system changes. | 65 // Updates tray visibility login status of the system changes. |
65 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); | 66 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); |
66 | 67 |
67 // Returns true if it should block the auto hide behavior of the launcher. | 68 // Returns true if it should block the auto hide behavior of the launcher. |
68 bool ShouldBlockLauncherAutoHide() const; | 69 bool ShouldBlockLauncherAutoHide() const; |
69 | 70 |
70 // Returns true if the message center bubble is visible. | 71 // Returns true if the message center bubble is visible. |
71 bool IsMessageCenterBubbleVisible() const; | 72 bool IsMessageCenterBubbleVisible() const; |
72 | 73 |
73 // Returns true if the mouse is inside the notification bubble. | 74 // Returns true if the mouse is inside the notification bubble. |
74 bool IsMouseInNotificationBubble() const; | 75 bool IsMouseInNotificationBubble() const; |
75 | 76 |
76 message_center::MessageCenter* message_center() { | |
77 return message_center_; | |
78 } | |
79 | |
80 // Overridden from TrayBackgroundView. | 77 // Overridden from TrayBackgroundView. |
81 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | 78 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; |
82 virtual void AnchorUpdated() OVERRIDE; | 79 virtual void AnchorUpdated() OVERRIDE; |
83 virtual string16 GetAccessibleNameForTray() OVERRIDE; | 80 virtual string16 GetAccessibleNameForTray() OVERRIDE; |
84 virtual void HideBubbleWithView( | 81 virtual void HideBubbleWithView( |
85 const views::TrayBubbleView* bubble_view) OVERRIDE; | 82 const views::TrayBubbleView* bubble_view) OVERRIDE; |
86 virtual bool ClickedOutsideBubble() OVERRIDE; | |
87 | 83 |
88 // Overridden from internal::ActionableView. | 84 // Overridden from internal::ActionableView. |
89 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 85 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
90 | 86 |
91 // Overridden from views::TrayBubbleView::Delegate. | 87 // MessageCenterTrayHost implementation part three. |
92 virtual void BubbleViewDestroyed() OVERRIDE; | |
93 virtual void OnMouseEnteredView() OVERRIDE; | |
94 virtual void OnMouseExitedView() OVERRIDE; | |
95 virtual string16 GetAccessibleNameForBubble() OVERRIDE; | 88 virtual string16 GetAccessibleNameForBubble() OVERRIDE; |
96 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, | 89 virtual gfx::Rect GetAnchorRect( |
97 AnchorType anchor_type, | 90 views::Widget* anchor_widget, |
98 AnchorAlignment anchor_alignment) OVERRIDE; | 91 views::TrayBubbleView::AnchorType anchor_type, |
99 virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; | 92 views::TrayBubbleView::AnchorAlignment anchor_alignment) OVERRIDE; |
100 | 93 |
101 // Overridden from message_center::MessageCenter::Observer. | 94 // Overridden from views::ButtonListener. |
102 virtual void OnMessageCenterChanged(bool new_notification) OVERRIDE; | |
103 | |
104 // Overridden from ButtonListener. | |
105 virtual void ButtonPressed(views::Button* sender, | 95 virtual void ButtonPressed(views::Button* sender, |
106 const ui::Event& event) OVERRIDE; | 96 const ui::Event& event) OVERRIDE; |
107 | 97 |
108 // Overridden from WidgetObserver. | 98 // Overridden from views::WidgetObserver. |
109 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | 99 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; |
110 | 100 |
101 // MessageCenterTrayHost implementation part four. | |
102 virtual gfx::NativeView GetBubbleWindowContainer() OVERRIDE; | |
103 virtual views::View* GetAnchorView() OVERRIDE; | |
104 virtual views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() OVERRIDE; | |
105 virtual void UpdateInitParams( | |
106 views::TrayBubbleView::InitParams* init_params) OVERRIDE; | |
107 virtual void OnMessageCenterTrayChanged() OVERRIDE; | |
108 | |
109 // Overridden from TrayBackgroundView. | |
110 virtual bool ClickedOutsideBubble() OVERRIDE; | |
111 | |
112 // Tells the tray to show the MessageCenter bubble. | |
113 void ShowMessageCenter(); | |
114 | |
115 bool IsPopupVisible() const; | |
116 | |
111 private: | 117 private: |
112 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 118 FRIEND_TEST_ALL_PREFIXES(::WebNotificationTrayTest, |
113 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotificationPopupBubble); | |
114 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, | |
115 ManyMessageCenterNotifications); | 119 ManyMessageCenterNotifications); |
116 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManyPopupNotifications); | 120 views::ImageButton* button_; |
117 | 121 |
118 // Shows or hides the message center bubble. | 122 scoped_ptr<message_center::QuietModeBubble> quiet_mode_bubble_; |
119 void ToggleMessageCenterBubble(); | 123 scoped_ptr<ui::MessageCenterTray> message_center_tray_; |
120 | 124 |
121 // Shows or updates the message center bubble and hides the popup bubble. | 125 bool show_message_center_on_unlock_; |
122 void ShowMessageCenterBubble(); | 126 bool message_center_visible_; |
123 | 127 |
124 // Hides the message center bubble if visible. | |
125 void HideMessageCenterBubble(); | |
126 | |
127 // Shows or updates the popup notification bubble if appropriate. | |
128 void ShowPopupBubble(); | |
129 | |
130 // Hides the notification bubble if visible. | |
131 void HidePopupBubble(); | |
132 | |
133 // Returns true if it should show the quiet mode bubble. | |
134 bool ShouldShowQuietModeBubble(const ui::Event& event); | |
135 | |
136 // Shows the quiet mode bubble. | |
137 void ShowQuietModeBubble(); | |
138 | |
139 // Updates the tray icon and visibility. | |
140 void UpdateTray(); | |
141 | |
142 internal::WebNotificationBubbleWrapper* message_center_bubble() const { | |
143 return message_center_bubble_.get(); | |
144 } | |
145 | |
146 internal::WebNotificationBubbleWrapper* popup_bubble() const { | |
147 return popup_bubble_.get(); | |
148 } | |
149 | |
150 message_center::QuietModeBubble* quiet_mode_bubble() const { | |
151 return quiet_mode_bubble_.get(); | |
152 } | |
153 | |
154 // Testing accessors. | |
155 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | |
156 message_center::MessagePopupBubble* GetPopupBubbleForTest(); | |
157 | |
158 message_center::MessageCenter* message_center_; | |
159 scoped_ptr<internal::WebNotificationBubbleWrapper> message_center_bubble_; | |
160 scoped_ptr<internal::WebNotificationBubbleWrapper> popup_bubble_; | |
161 scoped_ptr<message_center::QuietModeBubble> quiet_mode_bubble_; | |
162 views::ImageButton* button_; | |
163 bool show_message_center_on_unlock_; | |
164 | |
165 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | |
166 }; | 128 }; |
167 | 129 |
168 } // namespace ash | 130 } // namespace ash |
169 | 131 |
170 #endif // ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 132 #endif // ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
OLD | NEW |