| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/prefs/pref_member.h" | |
| 10 #include "chrome/browser/status_icons/status_icon_menu_model.h" | 9 #include "chrome/browser/status_icons/status_icon_menu_model.h" |
| 11 #include "chrome/browser/status_icons/status_icon_observer.h" | 10 #include "chrome/browser/status_icons/status_icon_observer.h" |
| 12 #include "chrome/browser/ui/views/message_center/message_center_widget_delegate.
h" | 11 #include "chrome/browser/ui/views/message_center/message_center_widget_delegate.
h" |
| 13 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 15 #include "ui/base/models/simple_menu_model.h" | 14 #include "ui/base/models/simple_menu_model.h" |
| 16 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 17 #include "ui/message_center/message_center_tray.h" | 16 #include "ui/message_center/message_center_tray.h" |
| 18 #include "ui/message_center/message_center_tray_delegate.h" | 17 #include "ui/message_center/message_center_tray_delegate.h" |
| 19 #include "ui/views/widget/widget_observer.h" | 18 #include "ui/views/widget/widget_observer.h" |
| 20 | 19 |
| 21 #if defined(OS_WIN) | |
| 22 #include "base/threading/thread.h" | |
| 23 #endif | |
| 24 | |
| 25 class PrefService; | |
| 26 class StatusIcon; | 20 class StatusIcon; |
| 27 | 21 |
| 28 namespace message_center { | 22 namespace message_center { |
| 29 class MessageCenter; | 23 class MessageCenter; |
| 30 class MessagePopupCollection; | 24 class MessagePopupCollection; |
| 31 } | 25 } |
| 32 | 26 |
| 33 namespace views { | 27 namespace views { |
| 34 class Widget; | 28 class Widget; |
| 35 } | 29 } |
| 36 | 30 |
| 37 namespace message_center { | 31 namespace message_center { |
| 38 | 32 |
| 39 struct PositionInfo; | 33 struct PositionInfo; |
| 40 | 34 |
| 41 class MessageCenterWidgetDelegate; | 35 class MessageCenterWidgetDelegate; |
| 42 | 36 |
| 43 // A MessageCenterTrayDelegate implementation that exposes the MessageCenterTray | 37 // A MessageCenterTrayDelegate implementation that exposes the MessageCenterTray |
| 44 // via a system tray icon. The notification popups will be displayed in the | 38 // via a system tray icon. The notification popups will be displayed in the |
| 45 // corner of the screen and the message center will be displayed by the system | 39 // corner of the screen and the message center will be displayed by the system |
| 46 // tray icon on click. | 40 // tray icon on click. |
| 47 class WebNotificationTray : public message_center::MessageCenterTrayDelegate, | 41 class WebNotificationTray : public message_center::MessageCenterTrayDelegate, |
| 48 public StatusIconObserver, | 42 public StatusIconObserver, |
| 49 public base::SupportsWeakPtr<WebNotificationTray>, | 43 public base::SupportsWeakPtr<WebNotificationTray>, |
| 50 public StatusIconMenuModel::Delegate { | 44 public StatusIconMenuModel::Delegate { |
| 51 public: | 45 public: |
| 52 explicit WebNotificationTray(PrefService* local_state); | 46 WebNotificationTray(); |
| 53 virtual ~WebNotificationTray(); | 47 virtual ~WebNotificationTray(); |
| 54 | 48 |
| 55 message_center::MessageCenter* message_center(); | 49 message_center::MessageCenter* message_center(); |
| 56 | 50 |
| 57 // MessageCenterTrayDelegate implementation. | 51 // MessageCenterTrayDelegate implementation. |
| 58 virtual bool ShowPopups() OVERRIDE; | 52 virtual bool ShowPopups() OVERRIDE; |
| 59 virtual void HidePopups() OVERRIDE; | 53 virtual void HidePopups() OVERRIDE; |
| 60 virtual bool ShowMessageCenter() OVERRIDE; | 54 virtual bool ShowMessageCenter() OVERRIDE; |
| 61 virtual void HideMessageCenter() OVERRIDE; | 55 virtual void HideMessageCenter() OVERRIDE; |
| 62 virtual void OnMessageCenterTrayChanged() OVERRIDE; | 56 virtual void OnMessageCenterTrayChanged() OVERRIDE; |
| 63 virtual bool ShowNotifierSettings() OVERRIDE; | 57 virtual bool ShowNotifierSettings() OVERRIDE; |
| 64 virtual bool IsContextMenuEnabled() const OVERRIDE; | 58 virtual bool IsContextMenuEnabled() const OVERRIDE; |
| 65 | 59 |
| 66 // StatusIconObserver implementation. | 60 // StatusIconObserver implementation. |
| 67 virtual void OnStatusIconClicked() OVERRIDE; | 61 virtual void OnStatusIconClicked() OVERRIDE; |
| 68 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| 69 virtual void OnBalloonClicked() OVERRIDE; | 63 virtual void OnBalloonClicked() OVERRIDE; |
| 70 | 64 |
| 71 // This shows a platform-specific balloon informing the user of the existence | 65 // This shows a platform-specific balloon informing the user of the existence |
| 72 // of the message center in the status tray area. | 66 // of the message center in the status tray area. |
| 73 void DisplayFirstRunBalloon(); | 67 void DisplayFirstRunBalloon(); |
| 74 | |
| 75 void EnforceStatusIconVisible(); | |
| 76 #endif | 68 #endif |
| 77 | 69 |
| 78 // StatusIconMenuModel::Delegate implementation. | 70 // StatusIconMenuModel::Delegate implementation. |
| 79 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; | 71 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; |
| 80 | 72 |
| 81 // Changes the icon and hovertext based on number of unread notifications. | 73 // Changes the icon and hovertext based on number of unread notifications. |
| 82 void UpdateStatusIcon(); | 74 void UpdateStatusIcon(); |
| 83 void SendHideMessageCenter(); | 75 void SendHideMessageCenter(); |
| 84 void MarkMessageCenterHidden(); | 76 void MarkMessageCenterHidden(); |
| 85 | 77 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 96 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManuallyCloseMessageCenter); | 88 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManuallyCloseMessageCenter); |
| 97 | 89 |
| 98 PositionInfo GetPositionInfo(); | 90 PositionInfo GetPositionInfo(); |
| 99 | 91 |
| 100 void CreateStatusIcon(const gfx::ImageSkia& image, | 92 void CreateStatusIcon(const gfx::ImageSkia& image, |
| 101 const base::string16& tool_tip); | 93 const base::string16& tool_tip); |
| 102 void DestroyStatusIcon(); | 94 void DestroyStatusIcon(); |
| 103 void AddQuietModeMenu(StatusIcon* status_icon); | 95 void AddQuietModeMenu(StatusIcon* status_icon); |
| 104 MessageCenterWidgetDelegate* GetMessageCenterWidgetDelegateForTest(); | 96 MessageCenterWidgetDelegate* GetMessageCenterWidgetDelegateForTest(); |
| 105 | 97 |
| 106 #if defined(OS_WIN) | |
| 107 // This member variable keeps track of whether EnforceStatusIconVisible has | |
| 108 // been invoked on this machine, so the user still has control after we try | |
| 109 // promoting it the first time. | |
| 110 scoped_ptr<BooleanPrefMember> did_force_tray_visible_; | |
| 111 #endif | |
| 112 | |
| 113 MessageCenterWidgetDelegate* message_center_delegate_; | 98 MessageCenterWidgetDelegate* message_center_delegate_; |
| 114 scoped_ptr<message_center::MessagePopupCollection> popup_collection_; | 99 scoped_ptr<message_center::MessagePopupCollection> popup_collection_; |
| 115 | 100 |
| 116 StatusIcon* status_icon_; | 101 StatusIcon* status_icon_; |
| 117 StatusIconMenuModel* status_icon_menu_; | 102 StatusIconMenuModel* status_icon_menu_; |
| 118 scoped_ptr<MessageCenterTray> message_center_tray_; | 103 scoped_ptr<MessageCenterTray> message_center_tray_; |
| 119 gfx::Point mouse_click_point_; | 104 gfx::Point mouse_click_point_; |
| 120 | 105 |
| 121 bool should_update_tray_content_; | 106 bool should_update_tray_content_; |
| 122 bool last_quiet_mode_state_; | 107 bool last_quiet_mode_state_; |
| 123 | 108 |
| 124 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 109 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
| 125 }; | 110 }; |
| 126 | 111 |
| 127 } // namespace message_center | 112 } // namespace message_center |
| 128 | 113 |
| 129 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ | 114 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ |
| OLD | NEW |