Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ui / message_center / message_center_tray.h
blob66b5109db91cb9c931b52dab4d7b16b583ad22ab
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.
5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_
6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_
8 #include "base/observer_list.h"
9 #include "ui/base/models/simple_menu_model.h"
10 #include "ui/message_center/message_center.h"
11 #include "ui/message_center/message_center_export.h"
12 #include "ui/message_center/message_center_tray_delegate.h"
14 namespace message_center {
16 class MessageBubbleBase;
17 class MessagePopupBubble;
18 class QuietModeBubble;
20 // Implementation found with each supported platform's implementation of
21 // MessageCenterTrayDelegate.
22 MessageCenterTrayDelegate* CreateMessageCenterTray();
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
28 : public message_center::MessageCenter::Observer,
29 public ui::SimpleMenuModel::Delegate {
30 public:
31 MessageCenterTray(MessageCenterTrayDelegate* delegate,
32 message_center::MessageCenter* message_center);
33 virtual ~MessageCenterTray();
35 // Shows or updates the message center bubble and hides the popup bubble.
36 // Returns whether the message center is visible after the call, whether or
37 // not it was visible before.
38 bool ShowMessageCenterBubble();
40 // Returns whether the message center was visible before.
41 bool HideMessageCenterBubble();
43 void ToggleMessageCenterBubble();
45 // Causes an update if the popup bubble is already shown.
46 void ShowPopupBubble();
48 // Returns whether the popup was visible before.
49 bool HidePopupBubble();
51 // Creates the menu model for quiet mode and returns it. The caller must
52 // take the ownership of the return value.
53 ui::MenuModel* CreateQuietModeMenu();
55 bool message_center_visible() { return message_center_visible_; }
56 bool popups_visible() { return popups_visible_; }
57 MessageCenterTrayDelegate* delegate() { return delegate_; }
58 const message_center::MessageCenter* message_center() const {
59 return message_center_;
61 message_center::MessageCenter* message_center() { return message_center_; }
63 // Overridden from message_center::MessageCenter::Observer:
64 virtual void OnMessageCenterChanged(bool new_notification) OVERRIDE;
66 // Overridden from SimpleMenuModel::Delegate.
67 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
68 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
69 virtual bool GetAcceleratorForCommandId(
70 int command_id,
71 ui::Accelerator* accelerator) OVERRIDE;
72 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
74 private:
75 void NotifyMessageCenterTrayChanged();
77 // |message_center_| is a weak pointer that must live longer than
78 // MessageCenterTray.
79 message_center::MessageCenter* message_center_;
80 bool message_center_visible_;
81 bool popups_visible_;
82 // |delegate_| is a weak pointer that must live longer than MessageCenterTray.
83 MessageCenterTrayDelegate* delegate_;
85 DISALLOW_COPY_AND_ASSIGN(MessageCenterTray);
88 } // namespace message_center
90 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_