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..84f58747ad9f6c4c7383fb2b8df23be36f7b04a3 |
--- /dev/null |
+++ b/ui/message_center/message_center_tray.h |
@@ -0,0 +1,128 @@ |
+// 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 "base/observer_list.h" |
+#include "ui/message_center/message_center.h" |
+#include "ui/message_center/message_center_export.h" |
+#include "ui/views/bubble/tray_bubble_view.h" |
+ |
+template <typename T> struct DefaultSingletonTraits; |
+ |
+namespace message_center { |
+class MessageBubbleBase; |
+class MessagePopupBubble; |
+class QuietModeBubble; |
+} |
+ |
+namespace views { |
+class Widget; |
+} |
+ |
+namespace ui { |
+ |
+class MESSAGE_CENTER_EXPORT MessageCenterTrayObserver { |
+ public: |
+ virtual ~MessageCenterTrayObserver() {} |
+ |
+ virtual void OnMessageCenterTrayChanged() {}; |
+ virtual void OnShowMessageCenterBubble() {}; |
Pete Williamson
2013/01/17 19:07:45
Remove these events if they end up not getting use
dewittj
2013/01/18 00:57:46
Done.
|
+ virtual void OnHideMessageCenterBubble() {}; |
+ virtual void OnHidePopupBubble() {}; |
+}; |
+ |
+class MESSAGE_CENTER_EXPORT MessageCenterTrayDelegate { |
+ public: |
+ virtual ~MessageCenterTrayDelegate () {} |
+ |
+ virtual bool ShowPopups(message_center::MessageBubbleBase* bubble) = 0; |
+ virtual void HidePopups() = 0; |
+ virtual void UpdatePopups() {} |
+ virtual bool ShowMessageCenter(message_center::MessageBubbleBase* bubble) = 0; |
+ virtual void HideMessageCenter() = 0; |
+ virtual void UpdateMessageCenter() {} |
+}; |
+ |
+ |
+// 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 message_center::MessageCenter::Observer { |
+ public: |
+ explicit MessageCenterTray(MessageCenterTrayDelegate* host); |
+ virtual ~MessageCenterTray(); |
+ |
+ void AddObserver(MessageCenterTrayObserver* observer); |
+ void RemoveObserver(MessageCenterTrayObserver* observer); |
+ |
+ // 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_visible_; } |
+ |
+ bool IsPopupVisible() { return popups_visible_; } |
+ |
+ views::TrayBubbleView* GetPopupBubbleView(); |
+ views::TrayBubbleView* GetMessageCenterBubbleView(); |
+ |
+ MessageCenterTrayDelegate* delegate() { return delegate_; } |
+ message_center::MessageCenter* message_center() { |
+ return message_center_; |
+ } |
+ |
+ // Overridden from message_center::MessageCenter::Observer. |
+ virtual void OnMessageCenterChanged(bool new_notification) OVERRIDE; |
+ |
+ private: |
+ // Notify each observer of events. |
+ void NotifyMessageCenterTrayChanged() { |
+ FOR_EACH_OBSERVER(MessageCenterTrayObserver, |
+ observers_, |
+ OnMessageCenterTrayChanged()); |
+ } |
+ void NotifyShowMessageCenterBubble() { |
+ FOR_EACH_OBSERVER(MessageCenterTrayObserver, |
+ observers_, |
+ OnShowMessageCenterBubble()); |
+ } |
+ void NotifyHideMessageCenterBubble() { |
+ FOR_EACH_OBSERVER(MessageCenterTrayObserver, |
+ observers_, |
+ OnHideMessageCenterBubble()); |
+ } |
+ void NotifyHidePopupBubble() { |
+ FOR_EACH_OBSERVER(MessageCenterTrayObserver, |
+ observers_, |
+ OnHidePopupBubble()); |
+ } |
+ |
+ |
+ message_center::MessageCenter* message_center_; |
+ bool message_center_visible_; |
+ bool popups_visible_; |
+ MessageCenterTrayDelegate* delegate_; |
+ ObserverList<MessageCenterTrayObserver> observers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MessageCenterTray); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |