Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / views / message_center / web_notification_tray.h
bloba37dd9e1b641d797db3e3bb890fc1a742736eedc
1 // Copyright 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 CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_
6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/status_icons/status_icon_menu_model.h"
10 #include "chrome/browser/status_icons/status_icon_observer.h"
11 #include "chrome/browser/ui/views/message_center/message_center_widget_delegate.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "ui/base/models/simple_menu_model.h"
15 #include "ui/gfx/rect.h"
16 #include "ui/message_center/message_center_tray.h"
17 #include "ui/message_center/message_center_tray_delegate.h"
18 #include "ui/views/widget/widget_observer.h"
20 class StatusIcon;
22 namespace message_center {
23 class MessageCenter;
24 class MessagePopupCollection;
27 namespace views {
28 class Widget;
31 namespace message_center {
33 struct PositionInfo;
35 class MessageCenterWidgetDelegate;
37 // A MessageCenterTrayDelegate implementation that exposes the MessageCenterTray
38 // via a system tray icon. The notification popups will be displayed in the
39 // corner of the screen and the message center will be displayed by the system
40 // tray icon on click.
41 class WebNotificationTray : public message_center::MessageCenterTrayDelegate,
42 public StatusIconObserver,
43 public base::SupportsWeakPtr<WebNotificationTray>,
44 public StatusIconMenuModel::Delegate {
45 public:
46 WebNotificationTray();
47 virtual ~WebNotificationTray();
49 message_center::MessageCenter* message_center();
51 // MessageCenterTrayDelegate implementation.
52 virtual bool ShowPopups() OVERRIDE;
53 virtual void HidePopups() OVERRIDE;
54 virtual bool ShowMessageCenter() OVERRIDE;
55 virtual void HideMessageCenter() OVERRIDE;
56 virtual void OnMessageCenterTrayChanged() OVERRIDE;
57 virtual bool ShowNotifierSettings() OVERRIDE;
59 // StatusIconObserver implementation.
60 virtual void OnStatusIconClicked() OVERRIDE;
61 #if defined(OS_WIN)
62 virtual void OnBalloonClicked() OVERRIDE;
64 // This shows a platform-specific balloon informing the user of the existence
65 // of the message center in the status tray area.
66 void DisplayFirstRunBalloon();
67 #endif
69 // StatusIconMenuModel::Delegate implementation.
70 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
72 // Changes the icon and hovertext based on number of unread notifications.
73 void UpdateStatusIcon();
74 void SendHideMessageCenter();
75 void MarkMessageCenterHidden();
77 // Gets the point where the status icon was clicked.
78 gfx::Point mouse_click_point() { return mouse_click_point_; }
79 virtual MessageCenterTray* GetMessageCenterTray() OVERRIDE;
81 private:
82 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications);
83 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotificationPopupBubble);
84 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest,
85 ManyMessageCenterNotifications);
86 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManyPopupNotifications);
88 // The actual process to show the message center. Set |show_settings| to true
89 // if the message center should be initialized with the settings visible.
90 // Returns true if the center is successfully created.
91 bool ShowMessageCenterInternal(bool show_settings);
93 PositionInfo GetPositionInfo();
95 void CreateStatusIcon(const gfx::ImageSkia& image, const string16& tool_tip);
96 void DestroyStatusIcon();
97 void AddQuietModeMenu(StatusIcon* status_icon);
98 MessageCenterWidgetDelegate* GetMessageCenterWidgetDelegateForTest();
100 MessageCenterWidgetDelegate* message_center_delegate_;
101 scoped_ptr<message_center::MessagePopupCollection> popup_collection_;
103 StatusIcon* status_icon_;
104 StatusIconMenuModel* status_icon_menu_;
105 bool message_center_visible_;
106 scoped_ptr<MessageCenterTray> message_center_tray_;
107 gfx::Point mouse_click_point_;
109 bool should_update_tray_content_;
110 bool last_quiet_mode_state_;
112 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray);
115 } // namespace message_center
117 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_