Home | History | Annotate | Download | only in message_center
      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
      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_export.h"
     10 #include "ui/message_center/message_center_observer.h"
     11 #include "ui/message_center/message_center_tray_delegate.h"
     12 
     13 namespace message_center {
     14 
     15 class MessageCenter;
     16 class MessageBubbleBase;
     17 class MessagePopupBubble;
     18 class QuietModeBubble;
     19 
     20 // Implementation found with each supported platform's implementation of
     21 // MessageCenterTrayDelegate.
     22 MessageCenterTrayDelegate* CreateMessageCenterTray();
     23 
     24 // Class that observes a MessageCenter. Manages the popup and message center
     25 // bubbles. Tells the MessageCenterTrayHost when the tray is changed, as well
     26 // as when bubbles are shown and hidden.
     27 class MESSAGE_CENTER_EXPORT MessageCenterTray : public MessageCenterObserver {
     28  public:
     29   MessageCenterTray(MessageCenterTrayDelegate* delegate,
     30                     message_center::MessageCenter* message_center);
     31   virtual ~MessageCenterTray();
     32 
     33   // 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
     35   // not it was visible before.
     36   bool ShowMessageCenterBubble();
     37 
     38   // Hides the message center if visible and returns whether the message center
     39   // was visible before.
     40   bool HideMessageCenterBubble();
     41 
     42   // Marks the message center as "not visible" (this method will not hide the
     43   // message center).
     44   void MarkMessageCenterHidden();
     45 
     46   void ToggleMessageCenterBubble();
     47 
     48   // Causes an update if the popup bubble is already shown.
     49   void ShowPopupBubble();
     50 
     51   // Returns whether the popup was visible before.
     52   bool HidePopupBubble();
     53 
     54   // Toggles the visibility of the settings view in the message center bubble.
     55   void ShowNotifierSettingsBubble();
     56 
     57   bool message_center_visible() { return message_center_visible_; }
     58   bool popups_visible() { return popups_visible_; }
     59   MessageCenterTrayDelegate* delegate() { return delegate_; }
     60   const message_center::MessageCenter* message_center() const {
     61     return message_center_;
     62   }
     63   message_center::MessageCenter* message_center() { return message_center_; }
     64 
     65   // Overridden from MessageCenterObserver:
     66   virtual void OnNotificationAdded(const std::string& notification_id) OVERRIDE;
     67   virtual void OnNotificationRemoved(const std::string& notification_id,
     68                                      bool by_user) OVERRIDE;
     69   virtual void OnNotificationUpdated(
     70       const std::string& notification_id) OVERRIDE;
     71   virtual void OnNotificationClicked(
     72       const std::string& notification_id) OVERRIDE;
     73   virtual void OnNotificationButtonClicked(
     74       const std::string& notification_id,
     75       int button_index) OVERRIDE;
     76   virtual void OnNotificationDisplayed(
     77       const std::string& notification_id) OVERRIDE;
     78   virtual void OnQuietModeChanged(bool in_quiet_mode) OVERRIDE;
     79   virtual void OnBlockingStateChanged(NotificationBlocker* blocker) OVERRIDE;
     80 
     81  private:
     82   void OnMessageCenterChanged();
     83   void NotifyMessageCenterTrayChanged();
     84   void HidePopupBubbleInternal();
     85 
     86   // |message_center_| is a weak pointer that must live longer than
     87   // MessageCenterTray.
     88   message_center::MessageCenter* message_center_;
     89   bool message_center_visible_;
     90   bool popups_visible_;
     91   // |delegate_| is a weak pointer that must live longer than MessageCenterTray.
     92   MessageCenterTrayDelegate* delegate_;
     93 
     94   DISALLOW_COPY_AND_ASSIGN(MessageCenterTray);
     95 };
     96 
     97 }  // namespace message_center
     98 
     99 #endif  // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_
    100