Chromium Code Reviews| 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 "base/observer_list.h" | |
| 9 #include "ui/message_center/message_center.h" | |
| 10 #include "ui/message_center/message_center_export.h" | |
| 11 #include "ui/views/bubble/tray_bubble_view.h" | |
| 12 | |
| 13 template <typename T> struct DefaultSingletonTraits; | |
| 14 | |
| 15 namespace message_center { | |
| 16 class MessageBubbleBase; | |
| 17 class MessagePopupBubble; | |
| 18 class QuietModeBubble; | |
| 19 } | |
| 20 | |
| 21 namespace views { | |
| 22 class Widget; | |
| 23 } | |
| 24 | |
| 25 namespace ui { | |
| 26 | |
| 27 class MESSAGE_CENTER_EXPORT MessageCenterTrayObserver { | |
| 28 public: | |
| 29 virtual ~MessageCenterTrayObserver() {} | |
| 30 | |
| 31 virtual void OnMessageCenterTrayChanged() {}; | |
| 32 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.
| |
| 33 virtual void OnHideMessageCenterBubble() {}; | |
| 34 virtual void OnHidePopupBubble() {}; | |
| 35 }; | |
| 36 | |
| 37 class MESSAGE_CENTER_EXPORT MessageCenterTrayDelegate { | |
| 38 public: | |
| 39 virtual ~MessageCenterTrayDelegate () {} | |
| 40 | |
| 41 virtual bool ShowPopups(message_center::MessageBubbleBase* bubble) = 0; | |
| 42 virtual void HidePopups() = 0; | |
| 43 virtual void UpdatePopups() {} | |
| 44 virtual bool ShowMessageCenter(message_center::MessageBubbleBase* bubble) = 0; | |
| 45 virtual void HideMessageCenter() = 0; | |
| 46 virtual void UpdateMessageCenter() {} | |
| 47 }; | |
| 48 | |
| 49 | |
| 50 // Class that owns a MessageCenter and hosts it. Manages the popup and message | |
| 51 // center bubbles. Tells the MessageCenterTrayHost when the tray is changed, as | |
| 52 // well as when bubbles are shown and hidden. | |
| 53 class MESSAGE_CENTER_EXPORT MessageCenterTray | |
| 54 : public message_center::MessageCenter::Observer { | |
| 55 public: | |
| 56 explicit MessageCenterTray(MessageCenterTrayDelegate* host); | |
| 57 virtual ~MessageCenterTray(); | |
| 58 | |
| 59 void AddObserver(MessageCenterTrayObserver* observer); | |
| 60 void RemoveObserver(MessageCenterTrayObserver* observer); | |
| 61 | |
| 62 // Shows or updates the message center bubble and hides the popup bubble. | |
| 63 void ShowMessageCenterBubble(); | |
| 64 | |
| 65 // Hides the message center bubble if visible. | |
| 66 bool HideMessageCenterBubble(); | |
| 67 | |
| 68 void ToggleMessageCenterBubble(); | |
| 69 | |
| 70 // Shows or updates the popup notification bubble if appropriate. Calls | |
| 71 // MessageCenterTrayHost::CanShowPopups to determine if the system is in a | |
| 72 // good state for popups. | |
| 73 void ShowPopupBubble(); | |
| 74 | |
| 75 // Hides the notification bubble if visible. | |
| 76 bool HidePopupBubble(); | |
| 77 | |
| 78 bool IsMessageCenterVisible() { return message_center_visible_; } | |
| 79 | |
| 80 bool IsPopupVisible() { return popups_visible_; } | |
| 81 | |
| 82 views::TrayBubbleView* GetPopupBubbleView(); | |
| 83 views::TrayBubbleView* GetMessageCenterBubbleView(); | |
| 84 | |
| 85 MessageCenterTrayDelegate* delegate() { return delegate_; } | |
| 86 message_center::MessageCenter* message_center() { | |
| 87 return message_center_; | |
| 88 } | |
| 89 | |
| 90 // Overridden from message_center::MessageCenter::Observer. | |
| 91 virtual void OnMessageCenterChanged(bool new_notification) OVERRIDE; | |
| 92 | |
| 93 private: | |
| 94 // Notify each observer of events. | |
| 95 void NotifyMessageCenterTrayChanged() { | |
| 96 FOR_EACH_OBSERVER(MessageCenterTrayObserver, | |
| 97 observers_, | |
| 98 OnMessageCenterTrayChanged()); | |
| 99 } | |
| 100 void NotifyShowMessageCenterBubble() { | |
| 101 FOR_EACH_OBSERVER(MessageCenterTrayObserver, | |
| 102 observers_, | |
| 103 OnShowMessageCenterBubble()); | |
| 104 } | |
| 105 void NotifyHideMessageCenterBubble() { | |
| 106 FOR_EACH_OBSERVER(MessageCenterTrayObserver, | |
| 107 observers_, | |
| 108 OnHideMessageCenterBubble()); | |
| 109 } | |
| 110 void NotifyHidePopupBubble() { | |
| 111 FOR_EACH_OBSERVER(MessageCenterTrayObserver, | |
| 112 observers_, | |
| 113 OnHidePopupBubble()); | |
| 114 } | |
| 115 | |
| 116 | |
| 117 message_center::MessageCenter* message_center_; | |
| 118 bool message_center_visible_; | |
| 119 bool popups_visible_; | |
| 120 MessageCenterTrayDelegate* delegate_; | |
| 121 ObserverList<MessageCenterTrayObserver> observers_; | |
| 122 | |
| 123 DISALLOW_COPY_AND_ASSIGN(MessageCenterTray); | |
| 124 }; | |
| 125 | |
| 126 } // namespace ui | |
| 127 | |
| 128 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ | |
| OLD | NEW |