- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / message_center / web_notification_tray.h
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.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_
6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_
7
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"
19
20 class StatusIcon;
21
22 namespace message_center {
23 class MessageCenter;
24 class MessagePopupCollection;
25 }
26
27 namespace views {
28 class Widget;
29 }
30
31 namespace message_center {
32
33 struct PositionInfo;
34
35 class MessageCenterWidgetDelegate;
36
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();
48
49   message_center::MessageCenter* message_center();
50
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;
58
59   // StatusIconObserver implementation.
60   virtual void OnStatusIconClicked() OVERRIDE;
61 #if defined(OS_WIN)
62   virtual void OnBalloonClicked() OVERRIDE;
63
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
68
69   // StatusIconMenuModel::Delegate implementation.
70   virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
71
72   // Changes the icon and hovertext based on number of unread notifications.
73   void UpdateStatusIcon();
74   void SendHideMessageCenter();
75   void MarkMessageCenterHidden();
76
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;
80
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);
87
88   PositionInfo GetPositionInfo();
89
90   void CreateStatusIcon(const gfx::ImageSkia& image, const string16& tool_tip);
91   void DestroyStatusIcon();
92   void AddQuietModeMenu(StatusIcon* status_icon);
93   MessageCenterWidgetDelegate* GetMessageCenterWidgetDelegateForTest();
94
95   MessageCenterWidgetDelegate* message_center_delegate_;
96   scoped_ptr<message_center::MessagePopupCollection> popup_collection_;
97
98   StatusIcon* status_icon_;
99   StatusIconMenuModel* status_icon_menu_;
100   bool message_center_visible_;
101   scoped_ptr<MessageCenterTray> message_center_tray_;
102   gfx::Point mouse_click_point_;
103
104   bool should_update_tray_content_;
105   bool last_quiet_mode_state_;
106
107   DISALLOW_COPY_AND_ASSIGN(WebNotificationTray);
108 };
109
110 }  // namespace message_center
111
112 #endif  // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_