OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
| 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
| 7 |
| 8 #include "ui/message_center/message_center.h" |
| 9 #include "ui/message_center/message_center_export.h" |
| 10 #include "ui/message_center/message_center_tray_host.h" |
| 11 #include "ui/views/bubble/tray_bubble_view.h" |
| 12 |
| 13 template <typename T> struct DefaultSingletonTraits; |
| 14 |
| 15 namespace { |
| 16 class WebNotificationBubbleWrapper; |
| 17 } |
| 18 |
| 19 namespace message_center { |
| 20 class MessagePopupBubble; |
| 21 class QuietModeBubble; |
| 22 } |
| 23 |
| 24 namespace views { |
| 25 class Widget; |
| 26 } |
| 27 |
| 28 namespace ui { |
| 29 |
| 30 // Class that owns a MessageCenter and hosts it. Manages the popup and message |
| 31 // center bubbles. Tells the MessageCenterTrayHost when the tray is changed, as |
| 32 // well as when bubbles are shown and hidden. |
| 33 class MESSAGE_CENTER_EXPORT MessageCenterTray |
| 34 : public views::TrayBubbleView::Delegate, |
| 35 public message_center::MessageCenter::Observer { |
| 36 public: |
| 37 explicit MessageCenterTray(MessageCenterTrayHost* host); |
| 38 virtual ~MessageCenterTray(); |
| 39 |
| 40 // Shows or updates the message center bubble and hides the popup bubble. |
| 41 void ShowMessageCenterBubble(); |
| 42 |
| 43 // Hides the message center bubble if visible. |
| 44 bool HideMessageCenterBubble(); |
| 45 |
| 46 void ToggleMessageCenterBubble(); |
| 47 |
| 48 // Shows or updates the popup notification bubble if appropriate. Calls |
| 49 // MessageCenterTrayHost::CanShowPopups to determine if the system is in a |
| 50 // good state for popups. |
| 51 void ShowPopupBubble(); |
| 52 |
| 53 // Hides the notification bubble if visible. |
| 54 bool HidePopupBubble(); |
| 55 |
| 56 bool IsMessageCenterVisible() { return message_center_bubble_.get() != NULL; } |
| 57 |
| 58 bool IsPopupVisible() { return popup_bubble_.get() != NULL; } |
| 59 |
| 60 views::TrayBubbleView* GetPopupBubbleView(); |
| 61 views::TrayBubbleView* GetMessageCenterBubbleView(); |
| 62 |
| 63 MessageCenterTrayHost* host() { return host_; } |
| 64 message_center::MessageCenter* message_center() { |
| 65 return message_center_; |
| 66 } |
| 67 |
| 68 // Overridden from views::TrayBubbleView::Delegate. |
| 69 virtual void BubbleViewDestroyed() OVERRIDE; |
| 70 virtual void OnMouseEnteredView() OVERRIDE; |
| 71 virtual void OnMouseExitedView() OVERRIDE; |
| 72 virtual string16 GetAccessibleNameForBubble() OVERRIDE; |
| 73 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, |
| 74 AnchorType anchor_type, |
| 75 AnchorAlignment anchor_alignment) OVERRIDE; |
| 76 virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; |
| 77 |
| 78 // Overridden from message_center::MessageCenter::Host. |
| 79 virtual void OnMessageCenterChanged(bool new_notification) OVERRIDE; |
| 80 |
| 81 private: |
| 82 // Calls MessageCenterTrayHost::OnMessageCenterTrayChanged. |
| 83 void OnChanged(); |
| 84 |
| 85 message_center::MessageCenter* message_center_; |
| 86 scoped_ptr<WebNotificationBubbleWrapper> message_center_bubble_; |
| 87 scoped_ptr<WebNotificationBubbleWrapper> popup_bubble_; |
| 88 MessageCenterTrayHost* host_; |
| 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(MessageCenterTray); |
| 91 }; |
| 92 |
| 93 } // namespace ui |
| 94 |
| 95 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
OLD | NEW |