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" | 10 #include "ash/system/tray/tray_views.h" |
11 #include "ash/system/user/login_status.h" | 11 #include "ash/system/user/login_status.h" |
12 #include "ash/system/web_notification/message_center.h" | |
13 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "ui/message_center/message_center.h" |
14 | 14 |
15 // Status area tray for showing browser and app notifications. This hosts | 15 // Status area tray for showing browser and app notifications. This hosts |
16 // a MessageCenter class which manages the notification list. This class | 16 // a MessageCenter class which manages the notification list. This class |
17 // contains the Ash specific tray implementation. | 17 // contains the Ash specific tray implementation. |
18 // | 18 // |
19 // Note: These are not related to system notifications (i.e NotificationView | 19 // Note: These are not related to system notifications (i.e NotificationView |
20 // generated by SystemTrayItem). Visibility of one notification type or other | 20 // generated by SystemTrayItem). Visibility of one notification type or other |
21 // is controlled by StatusAreaWidget. | 21 // is controlled by StatusAreaWidget. |
22 | 22 |
23 namespace aura { | 23 namespace aura { |
24 class LocatedEvent; | 24 class LocatedEvent; |
25 } | 25 } |
26 | 26 |
27 namespace gfx { | 27 namespace gfx { |
28 class ImageSkia; | 28 class ImageSkia; |
29 } | 29 } |
30 | 30 |
31 namespace views { | 31 namespace views { |
32 class ImageButton; | 32 class ImageButton; |
33 } | 33 } |
34 | 34 |
35 namespace message_center { | 35 namespace message_center { |
36 class MessageCenterBubble; | 36 class MessageCenterBubble; |
37 class PopupBubble; | 37 class MessagePopupBubble; |
38 } | 38 } |
39 | 39 |
40 namespace ash { | 40 namespace ash { |
41 | 41 |
42 namespace internal { | 42 namespace internal { |
43 class StatusAreaWidget; | 43 class StatusAreaWidget; |
44 class WebNotificationBubbleWrapper; | 44 class WebNotificationBubbleWrapper; |
45 } | 45 } |
46 | 46 |
47 class ASH_EXPORT WebNotificationTray | 47 class ASH_EXPORT WebNotificationTray |
48 : public internal::TrayBackgroundView, | 48 : public internal::TrayBackgroundView, |
49 public message_center::TrayBubbleView::Delegate, | 49 public views::TrayBubbleView::Delegate, |
50 public message_center::MessageCenter::Host, | 50 public message_center::MessageCenter::Host, |
51 public views::ButtonListener { | 51 public views::ButtonListener { |
52 public: | 52 public: |
53 explicit WebNotificationTray(internal::StatusAreaWidget* status_area_widget); | 53 explicit WebNotificationTray(internal::StatusAreaWidget* status_area_widget); |
54 virtual ~WebNotificationTray(); | 54 virtual ~WebNotificationTray(); |
55 | 55 |
56 // Set whether or not the popup notifications should be hidden. | 56 // Set whether or not the popup notifications should be hidden. |
57 void SetHidePopupBubble(bool hide); | 57 void SetHidePopupBubble(bool hide); |
58 | 58 |
59 // Updates tray visibility login status of the system changes. | 59 // Updates tray visibility login status of the system changes. |
60 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); | 60 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); |
61 | 61 |
62 // Returns true if the message center bubble is visible. | 62 // Returns true if the message center bubble is visible. |
63 bool IsMessageCenterBubbleVisible() const; | 63 bool IsMessageCenterBubbleVisible() const; |
64 | 64 |
65 // Returns true if the mouse is inside the notification bubble. | 65 // Returns true if the mouse is inside the notification bubble. |
66 bool IsMouseInNotificationBubble() const; | 66 bool IsMouseInNotificationBubble() const; |
67 | 67 |
68 message_center::MessageCenter* message_center() { | 68 message_center::MessageCenter* message_center() { |
69 return message_center_.get(); | 69 return message_center_.get(); |
70 } | 70 } |
71 | 71 |
72 // Overridden from TrayBackgroundView. | 72 // Overridden from TrayBackgroundView. |
73 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | 73 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; |
74 virtual void AnchorUpdated() OVERRIDE; | 74 virtual void AnchorUpdated() OVERRIDE; |
75 virtual string16 GetAccessibleNameForTray() OVERRIDE; | 75 virtual string16 GetAccessibleNameForTray() OVERRIDE; |
76 virtual void HideBubbleWithView( | 76 virtual void HideBubbleWithView( |
77 const message_center::TrayBubbleView* bubble_view) OVERRIDE; | 77 const views::TrayBubbleView* bubble_view) OVERRIDE; |
78 virtual bool ClickedOutsideBubble() OVERRIDE; | 78 virtual bool ClickedOutsideBubble() OVERRIDE; |
79 | 79 |
80 // Overridden from internal::ActionableView. | 80 // Overridden from internal::ActionableView. |
81 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 81 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
82 | 82 |
83 // Overridden from message_center::TrayBubbleView::Delegate. | 83 // Overridden from views::TrayBubbleView::Delegate. |
84 virtual void BubbleViewDestroyed() OVERRIDE; | 84 virtual void BubbleViewDestroyed() OVERRIDE; |
85 virtual void OnMouseEnteredView() OVERRIDE; | 85 virtual void OnMouseEnteredView() OVERRIDE; |
86 virtual void OnMouseExitedView() OVERRIDE; | 86 virtual void OnMouseExitedView() OVERRIDE; |
87 virtual string16 GetAccessibleNameForBubble() OVERRIDE; | 87 virtual string16 GetAccessibleNameForBubble() OVERRIDE; |
88 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, | 88 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, |
89 AnchorType anchor_type, | 89 AnchorType anchor_type, |
90 AnchorAlignment anchor_alignment) OVERRIDE; | 90 AnchorAlignment anchor_alignment) OVERRIDE; |
91 virtual void HideBubble( | 91 virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; |
92 const message_center::TrayBubbleView* bubble_view) OVERRIDE; | |
93 | 92 |
94 // Overridden from message_center::MessageCenter::Host. | 93 // Overridden from message_center::MessageCenter::Host. |
95 virtual void MessageCenterChanged(bool new_notification) OVERRIDE; | 94 virtual void MessageCenterChanged(bool new_notification) OVERRIDE; |
96 | 95 |
97 // Overridden from ButtonListener. | 96 // Overridden from ButtonListener. |
98 virtual void ButtonPressed(views::Button* sender, | 97 virtual void ButtonPressed(views::Button* sender, |
99 const ui::Event& event) OVERRIDE; | 98 const ui::Event& event) OVERRIDE; |
100 | 99 |
101 private: | 100 private: |
102 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 101 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |
(...skipping 23 matching lines...) Expand all Loading... |
126 internal::WebNotificationBubbleWrapper* message_center_bubble() const { | 125 internal::WebNotificationBubbleWrapper* message_center_bubble() const { |
127 return message_center_bubble_.get(); | 126 return message_center_bubble_.get(); |
128 } | 127 } |
129 | 128 |
130 internal::WebNotificationBubbleWrapper* popup_bubble() const { | 129 internal::WebNotificationBubbleWrapper* popup_bubble() const { |
131 return popup_bubble_.get(); | 130 return popup_bubble_.get(); |
132 } | 131 } |
133 | 132 |
134 // Testing accessors. | 133 // Testing accessors. |
135 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | 134 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); |
136 message_center::PopupBubble* GetPopupBubbleForTest(); | 135 message_center::MessagePopupBubble* GetPopupBubbleForTest(); |
137 | 136 |
138 scoped_ptr<message_center::MessageCenter> message_center_; | 137 scoped_ptr<message_center::MessageCenter> message_center_; |
139 scoped_ptr<internal::WebNotificationBubbleWrapper> message_center_bubble_; | 138 scoped_ptr<internal::WebNotificationBubbleWrapper> message_center_bubble_; |
140 scoped_ptr<internal::WebNotificationBubbleWrapper> popup_bubble_; | 139 scoped_ptr<internal::WebNotificationBubbleWrapper> popup_bubble_; |
141 views::ImageButton* button_; | 140 views::ImageButton* button_; |
142 bool show_message_center_on_unlock_; | 141 bool show_message_center_on_unlock_; |
143 | 142 |
144 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 143 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
145 }; | 144 }; |
146 | 145 |
147 } // namespace ash | 146 } // namespace ash |
148 | 147 |
149 #endif // ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 148 #endif // ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
OLD | NEW |