| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ | 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
| 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ | 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "ui/base/models/simple_menu_model.h" |
| 9 #include "ui/message_center/message_center_export.h" | 10 #include "ui/message_center/message_center_export.h" |
| 10 #include "ui/message_center/message_center_observer.h" | 11 #include "ui/message_center/message_center_observer.h" |
| 11 #include "ui/message_center/message_center_tray_delegate.h" | 12 #include "ui/message_center/message_center_tray_delegate.h" |
| 12 | 13 |
| 13 namespace message_center { | 14 namespace message_center { |
| 14 | 15 |
| 15 class MessageCenter; | 16 class MessageCenter; |
| 16 class MessageBubbleBase; | 17 class MessageBubbleBase; |
| 17 class MessagePopupBubble; | 18 class MessagePopupBubble; |
| 19 class Notification; |
| 18 class QuietModeBubble; | 20 class QuietModeBubble; |
| 19 | 21 |
| 20 // Implementation found with each supported platform's implementation of | 22 // Implementation found with each supported platform's implementation of |
| 21 // MessageCenterTrayDelegate. | 23 // MessageCenterTrayDelegate. |
| 22 MessageCenterTrayDelegate* CreateMessageCenterTray(); | 24 MessageCenterTrayDelegate* CreateMessageCenterTray(); |
| 23 | 25 |
| 24 // Class that observes a MessageCenter. Manages the popup and message center | 26 // Class that observes a MessageCenter. Manages the popup and message center |
| 25 // bubbles. Tells the MessageCenterTrayHost when the tray is changed, as well | 27 // bubbles. Tells the MessageCenterTrayHost when the tray is changed, as well |
| 26 // as when bubbles are shown and hidden. | 28 // as when bubbles are shown and hidden. |
| 27 class MESSAGE_CENTER_EXPORT MessageCenterTray : public MessageCenterObserver { | 29 class MESSAGE_CENTER_EXPORT MessageCenterTray |
| 30 : public MessageCenterObserver, |
| 31 public ui::SimpleMenuModel::Delegate { |
| 28 public: | 32 public: |
| 29 MessageCenterTray(MessageCenterTrayDelegate* delegate, | 33 MessageCenterTray(MessageCenterTrayDelegate* delegate, |
| 30 message_center::MessageCenter* message_center); | 34 message_center::MessageCenter* message_center); |
| 31 virtual ~MessageCenterTray(); | 35 virtual ~MessageCenterTray(); |
| 32 | 36 |
| 33 // Shows or updates the message center bubble and hides the popup bubble. | 37 // Shows or updates the message center bubble and hides the popup bubble. |
| 34 // Returns whether the message center is visible after the call, whether or | 38 // Returns whether the message center is visible after the call, whether or |
| 35 // not it was visible before. | 39 // not it was visible before. |
| 36 bool ShowMessageCenterBubble(); | 40 bool ShowMessageCenterBubble(); |
| 37 | 41 |
| 38 // Hides the message center if visible and returns whether the message center | 42 // Hides the message center if visible and returns whether the message center |
| 39 // was visible before. | 43 // was visible before. |
| 40 bool HideMessageCenterBubble(); | 44 bool HideMessageCenterBubble(); |
| 41 | 45 |
| 42 // Marks the message center as "not visible" (this method will not hide the | 46 // Marks the message center as "not visible" (this method will not hide the |
| 43 // message center). | 47 // message center). |
| 44 void MarkMessageCenterHidden(); | 48 void MarkMessageCenterHidden(); |
| 45 | 49 |
| 46 void ToggleMessageCenterBubble(); | 50 void ToggleMessageCenterBubble(); |
| 47 | 51 |
| 48 // Causes an update if the popup bubble is already shown. | 52 // Causes an update if the popup bubble is already shown. |
| 49 void ShowPopupBubble(); | 53 void ShowPopupBubble(); |
| 50 | 54 |
| 51 // Returns whether the popup was visible before. | 55 // Returns whether the popup was visible before. |
| 52 bool HidePopupBubble(); | 56 bool HidePopupBubble(); |
| 53 | 57 |
| 54 // Toggles the visibility of the settings view in the message center bubble. | 58 // Toggles the visibility of the settings view in the message center bubble. |
| 55 void ShowNotifierSettingsBubble(); | 59 void ShowNotifierSettingsBubble(); |
| 56 | 60 |
| 61 // Creates a new model of the context menu for the notification of |id|. |
| 62 scoped_ptr<ui::MenuModel> CreateMenuModelForNotification( |
| 63 const std::string& id); |
| 64 |
| 57 bool message_center_visible() { return message_center_visible_; } | 65 bool message_center_visible() { return message_center_visible_; } |
| 58 bool popups_visible() { return popups_visible_; } | 66 bool popups_visible() { return popups_visible_; } |
| 59 MessageCenterTrayDelegate* delegate() { return delegate_; } | 67 MessageCenterTrayDelegate* delegate() { return delegate_; } |
| 60 const message_center::MessageCenter* message_center() const { | 68 const message_center::MessageCenter* message_center() const { |
| 61 return message_center_; | 69 return message_center_; |
| 62 } | 70 } |
| 63 message_center::MessageCenter* message_center() { return message_center_; } | 71 message_center::MessageCenter* message_center() { return message_center_; } |
| 64 | 72 |
| 65 // Overridden from MessageCenterObserver: | 73 // Overridden from MessageCenterObserver: |
| 66 virtual void OnNotificationAdded(const std::string& notification_id) OVERRIDE; | 74 virtual void OnNotificationAdded(const std::string& notification_id) OVERRIDE; |
| 67 virtual void OnNotificationRemoved(const std::string& notification_id, | 75 virtual void OnNotificationRemoved(const std::string& notification_id, |
| 68 bool by_user) OVERRIDE; | 76 bool by_user) OVERRIDE; |
| 69 virtual void OnNotificationUpdated( | 77 virtual void OnNotificationUpdated( |
| 70 const std::string& notification_id) OVERRIDE; | 78 const std::string& notification_id) OVERRIDE; |
| 71 virtual void OnNotificationClicked( | 79 virtual void OnNotificationClicked( |
| 72 const std::string& notification_id) OVERRIDE; | 80 const std::string& notification_id) OVERRIDE; |
| 73 virtual void OnNotificationButtonClicked( | 81 virtual void OnNotificationButtonClicked( |
| 74 const std::string& notification_id, | 82 const std::string& notification_id, |
| 75 int button_index) OVERRIDE; | 83 int button_index) OVERRIDE; |
| 76 virtual void OnNotificationDisplayed( | 84 virtual void OnNotificationDisplayed( |
| 77 const std::string& notification_id) OVERRIDE; | 85 const std::string& notification_id) OVERRIDE; |
| 78 virtual void OnQuietModeChanged(bool in_quiet_mode) OVERRIDE; | 86 virtual void OnQuietModeChanged(bool in_quiet_mode) OVERRIDE; |
| 79 virtual void OnBlockingStateChanged(NotificationBlocker* blocker) OVERRIDE; | 87 virtual void OnBlockingStateChanged(NotificationBlocker* blocker) OVERRIDE; |
| 80 | 88 |
| 89 // Overridden from ui::SimpleMenuModel::Delegate: |
| 90 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 91 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 92 virtual bool GetAcceleratorForCommandId( |
| 93 int command_id, |
| 94 ui::Accelerator* accelerator) OVERRIDE; |
| 95 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 96 virtual void MenuClosed(ui::SimpleMenuModel* source) OVERRIDE; |
| 97 |
| 81 private: | 98 private: |
| 82 void OnMessageCenterChanged(); | 99 void OnMessageCenterChanged(); |
| 83 void NotifyMessageCenterTrayChanged(); | 100 void NotifyMessageCenterTrayChanged(); |
| 84 void HidePopupBubbleInternal(); | 101 void HidePopupBubbleInternal(); |
| 85 | 102 |
| 86 // |message_center_| is a weak pointer that must live longer than | 103 // |message_center_| is a weak pointer that must live longer than |
| 87 // MessageCenterTray. | 104 // MessageCenterTray. |
| 88 message_center::MessageCenter* message_center_; | 105 message_center::MessageCenter* message_center_; |
| 89 bool message_center_visible_; | 106 bool message_center_visible_; |
| 90 bool popups_visible_; | 107 bool popups_visible_; |
| 91 // |delegate_| is a weak pointer that must live longer than MessageCenterTray. | 108 // |delegate_| is a weak pointer that must live longer than MessageCenterTray. |
| 92 MessageCenterTrayDelegate* delegate_; | 109 MessageCenterTrayDelegate* delegate_; |
| 93 | 110 |
| 111 // The notification for the current context menu. |
| 112 Notification* context_menu_notification_; |
| 113 |
| 94 DISALLOW_COPY_AND_ASSIGN(MessageCenterTray); | 114 DISALLOW_COPY_AND_ASSIGN(MessageCenterTray); |
| 95 }; | 115 }; |
| 96 | 116 |
| 97 } // namespace message_center | 117 } // namespace message_center |
| 98 | 118 |
| 99 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ | 119 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ |
| OLD | NEW |