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