Index: ui/message_center/message_center_tray.h |
diff --git a/ui/message_center/message_center_tray.h b/ui/message_center/message_center_tray.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7dfae34828541fe87ec64773dc179ae1e2dfa4c3 |
--- /dev/null |
+++ b/ui/message_center/message_center_tray.h |
@@ -0,0 +1,95 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
+#define UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
+ |
+#include "ui/message_center/message_center.h" |
+#include "ui/message_center/message_center_export.h" |
+#include "ui/message_center/message_center_tray_host.h" |
+#include "ui/views/bubble/tray_bubble_view.h" |
+ |
+template <typename T> struct DefaultSingletonTraits; |
+ |
+namespace { |
+class WebNotificationBubbleWrapper; |
+} |
+ |
+namespace message_center { |
+class MessagePopupBubble; |
+class QuietModeBubble; |
+} |
+ |
+namespace views { |
+class Widget; |
+} |
+ |
+namespace ui { |
+ |
+// Class that owns a MessageCenter and hosts it. Manages the popup and message |
+// center bubbles. Tells the MessageCenterTrayHost when the tray is changed, as |
+// well as when bubbles are shown and hidden. |
+class MESSAGE_CENTER_EXPORT MessageCenterTray |
+ : public views::TrayBubbleView::Delegate, |
+ public message_center::MessageCenter::Observer { |
+ public: |
+ explicit MessageCenterTray(MessageCenterTrayHost* host); |
+ virtual ~MessageCenterTray(); |
+ |
+ // Shows or updates the message center bubble and hides the popup bubble. |
+ void ShowMessageCenterBubble(); |
+ |
+ // Hides the message center bubble if visible. |
+ bool HideMessageCenterBubble(); |
+ |
+ void ToggleMessageCenterBubble(); |
+ |
+ // Shows or updates the popup notification bubble if appropriate. Calls |
+ // MessageCenterTrayHost::CanShowPopups to determine if the system is in a |
+ // good state for popups. |
+ void ShowPopupBubble(); |
+ |
+ // Hides the notification bubble if visible. |
+ bool HidePopupBubble(); |
+ |
+ bool IsMessageCenterVisible() { return message_center_bubble_.get() != NULL; } |
+ |
+ bool IsPopupVisible() { return popup_bubble_.get() != NULL; } |
+ |
+ views::TrayBubbleView* GetPopupBubbleView(); |
+ views::TrayBubbleView* GetMessageCenterBubbleView(); |
+ |
+ MessageCenterTrayHost* host() { return host_; } |
+ message_center::MessageCenter* message_center() { |
+ return message_center_; |
+ } |
+ |
+ // Overridden from views::TrayBubbleView::Delegate. |
+ virtual void BubbleViewDestroyed() OVERRIDE; |
+ virtual void OnMouseEnteredView() OVERRIDE; |
+ virtual void OnMouseExitedView() OVERRIDE; |
+ virtual string16 GetAccessibleNameForBubble() OVERRIDE; |
+ virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, |
+ AnchorType anchor_type, |
+ AnchorAlignment anchor_alignment) OVERRIDE; |
+ virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; |
+ |
+ // Overridden from message_center::MessageCenter::Host. |
+ virtual void OnMessageCenterChanged(bool new_notification) OVERRIDE; |
+ |
+ private: |
+ // Calls MessageCenterTrayHost::OnMessageCenterTrayChanged. |
+ void OnChanged(); |
+ |
+ message_center::MessageCenter* message_center_; |
+ scoped_ptr<WebNotificationBubbleWrapper> message_center_bubble_; |
+ scoped_ptr<WebNotificationBubbleWrapper> popup_bubble_; |
+ MessageCenterTrayHost* host_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MessageCenterTray); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |