Revert of Revert of [Telemetry] Add browser option that allows disabling crash servic...
[chromium-blink-merge.git] / ui / message_center / message_center_tray.h
blob5cd6b8d314c49384e28e16df3cc6afc6a7bad977
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 "base/strings/string16.h"
10 #include "ui/message_center/message_center_export.h"
11 #include "ui/message_center/message_center_observer.h"
12 #include "ui/message_center/message_center_tray_delegate.h"
13 #include "ui/message_center/notifier_settings.h"
15 namespace ui {
16 class MenuModel;
19 namespace message_center {
21 class MessageCenter;
22 class MessageBubbleBase;
23 class MessagePopupBubble;
24 class QuietModeBubble;
26 // Implementation found with each supported platform's implementation of
27 // MessageCenterTrayDelegate.
28 MessageCenterTrayDelegate* CreateMessageCenterTray();
30 // Class that observes a MessageCenter. Manages the popup and message center
31 // bubbles. Tells the MessageCenterTrayHost when the tray is changed, as well
32 // as when bubbles are shown and hidden.
33 class MESSAGE_CENTER_EXPORT MessageCenterTray : public MessageCenterObserver {
34 public:
35 MessageCenterTray(MessageCenterTrayDelegate* delegate,
36 message_center::MessageCenter* message_center);
37 ~MessageCenterTray() override;
39 // Shows or updates the message center bubble and hides the popup bubble.
40 // Returns whether the message center is visible after the call, whether or
41 // not it was visible before.
42 bool ShowMessageCenterBubble();
44 // Hides the message center if visible and returns whether the message center
45 // was visible before.
46 bool HideMessageCenterBubble();
48 // Marks the message center as "not visible" (this method will not hide the
49 // message center).
50 void MarkMessageCenterHidden();
52 void ToggleMessageCenterBubble();
54 // Causes an update if the popup bubble is already shown.
55 void ShowPopupBubble();
57 // Returns whether the popup was visible before.
58 bool HidePopupBubble();
60 // Toggles the visibility of the settings view in the message center bubble.
61 void ShowNotifierSettingsBubble();
63 // Creates a model for the context menu for a notification card.
64 scoped_ptr<ui::MenuModel> CreateNotificationMenuModel(
65 const NotifierId& notifier_id,
66 const base::string16& display_source);
68 bool message_center_visible() { return message_center_visible_; }
69 bool popups_visible() { return popups_visible_; }
70 MessageCenterTrayDelegate* delegate() { return delegate_; }
71 const message_center::MessageCenter* message_center() const {
72 return message_center_;
74 message_center::MessageCenter* message_center() { return message_center_; }
76 // Overridden from MessageCenterObserver:
77 void OnNotificationAdded(const std::string& notification_id) override;
78 void OnNotificationRemoved(const std::string& notification_id,
79 bool by_user) override;
80 void OnNotificationUpdated(const std::string& notification_id) override;
81 void OnNotificationClicked(const std::string& notification_id) override;
82 void OnNotificationButtonClicked(const std::string& notification_id,
83 int button_index) override;
84 void OnNotificationDisplayed(const std::string& notification_id,
85 const DisplaySource source) override;
86 void OnQuietModeChanged(bool in_quiet_mode) override;
87 void OnBlockingStateChanged(NotificationBlocker* blocker) override;
89 private:
90 void OnMessageCenterChanged();
91 void NotifyMessageCenterTrayChanged();
92 void HidePopupBubbleInternal();
94 // |message_center_| is a weak pointer that must live longer than
95 // MessageCenterTray.
96 message_center::MessageCenter* message_center_;
97 bool message_center_visible_;
98 bool popups_visible_;
99 // |delegate_| is a weak pointer that must live longer than MessageCenterTray.
100 MessageCenterTrayDelegate* delegate_;
102 DISALLOW_COPY_AND_ASSIGN(MessageCenterTray);
105 } // namespace message_center
107 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_