| 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 "chrome/browser/status_icons/status_icon_observer.h" | 9 #include "chrome/browser/status_icons/status_icon_observer.h" |
| 10 #include "chrome/browser/ui/views/message_center/message_center_widget_delegate.
h" |
| 10 #include "ui/base/models/simple_menu_model.h" | 11 #include "ui/base/models/simple_menu_model.h" |
| 12 #include "ui/gfx/rect.h" |
| 11 #include "ui/message_center/message_center_tray.h" | 13 #include "ui/message_center/message_center_tray.h" |
| 12 #include "ui/message_center/message_center_tray_delegate.h" | 14 #include "ui/message_center/message_center_tray_delegate.h" |
| 13 #include "ui/views/bubble/tray_bubble_view.h" | 15 #include "ui/views/widget/widget_observer.h" |
| 14 | 16 |
| 15 class StatusIcon; | 17 class StatusIcon; |
| 16 | 18 |
| 17 namespace message_center { | 19 namespace message_center { |
| 18 class MessageCenter; | 20 class MessageCenter; |
| 19 class MessageCenterBubble; | |
| 20 class MessagePopupCollection; | 21 class MessagePopupCollection; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace views { | 24 namespace views { |
| 24 class Widget; | 25 class Widget; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace message_center { | 28 namespace message_center { |
| 28 | 29 |
| 29 namespace internal { | 30 struct PositionInfo; |
| 30 class NotificationBubbleWrapper; | 31 |
| 31 } | 32 class MessageCenterWidgetDelegate; |
| 32 | 33 |
| 33 // A MessageCenterTrayDelegate implementation that exposes the MessageCenterTray | 34 // A MessageCenterTrayDelegate implementation that exposes the MessageCenterTray |
| 34 // via a system tray icon. The notification popups will be displayed in the | 35 // via a system tray icon. The notification popups will be displayed in the |
| 35 // corner of the screen and the message center will be displayed by the system | 36 // corner of the screen and the message center will be displayed by the system |
| 36 // tray icon on click. | 37 // tray icon on click. |
| 37 class WebNotificationTray : public message_center::MessageCenterTrayDelegate, | 38 class WebNotificationTray : public message_center::MessageCenterTrayDelegate, |
| 38 public StatusIconObserver, | 39 public StatusIconObserver, |
| 39 public base::SupportsWeakPtr<WebNotificationTray> { | 40 public base::SupportsWeakPtr<WebNotificationTray> { |
| 40 public: | 41 public: |
| 41 WebNotificationTray(); | 42 WebNotificationTray(); |
| 42 virtual ~WebNotificationTray(); | 43 virtual ~WebNotificationTray(); |
| 43 | 44 |
| 44 message_center::MessageCenter* message_center(); | 45 message_center::MessageCenter* message_center(); |
| 45 | 46 |
| 46 // MessageCenterTrayDelegate implementation. | 47 // MessageCenterTrayDelegate implementation. |
| 47 virtual bool ShowPopups() OVERRIDE; | 48 virtual bool ShowPopups() OVERRIDE; |
| 48 virtual void HidePopups() OVERRIDE; | 49 virtual void HidePopups() OVERRIDE; |
| 49 virtual bool ShowMessageCenter() OVERRIDE; | 50 virtual bool ShowMessageCenter() OVERRIDE; |
| 50 virtual void HideMessageCenter() OVERRIDE; | 51 virtual void HideMessageCenter() OVERRIDE; |
| 51 virtual void OnMessageCenterTrayChanged() OVERRIDE; | 52 virtual void OnMessageCenterTrayChanged() OVERRIDE; |
| 52 virtual bool ShowNotifierSettings() OVERRIDE; | 53 virtual bool ShowNotifierSettings() OVERRIDE; |
| 53 | 54 |
| 54 // These are forwarded to WebNotificationTray by | |
| 55 // NotificationBubbleWrapper classes since they don't have enough | |
| 56 // context to provide the required data for TrayBubbleView::Delegate. | |
| 57 gfx::Rect GetMessageCenterAnchor(); | |
| 58 gfx::Rect GetPopupAnchor(); | |
| 59 gfx::NativeView GetBubbleWindowContainer(); | |
| 60 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment(); | |
| 61 | |
| 62 // StatusIconObserver implementation. | 55 // StatusIconObserver implementation. |
| 63 virtual void OnStatusIconClicked() OVERRIDE; | 56 virtual void OnStatusIconClicked() OVERRIDE; |
| 64 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 65 virtual void OnBalloonClicked() OVERRIDE; | 58 virtual void OnBalloonClicked() OVERRIDE; |
| 66 | 59 |
| 67 // This shows a platform-specific balloon informing the user of the existence | 60 // This shows a platform-specific balloon informing the user of the existence |
| 68 // of the message center in the status tray area. | 61 // of the message center in the status tray area. |
| 69 void DisplayFirstRunBalloon(); | 62 void DisplayFirstRunBalloon(); |
| 70 #endif | 63 #endif |
| 71 | 64 |
| 72 // Changes the icon and hovertext based on number of unread notifications. | 65 // Changes the icon and hovertext based on number of unread notifications. |
| 73 void UpdateStatusIcon(); | 66 void UpdateStatusIcon(); |
| 74 void HideBubbleWithView(const views::TrayBubbleView* bubble_view); | 67 void SendHideMessageCenter(); |
| 68 void MarkMessageCenterHidden(); |
| 69 |
| 70 // Gets the point where the status icon was clicked. |
| 71 gfx::Point mouse_click_point() { return mouse_click_point_; } |
| 75 | 72 |
| 76 private: | 73 private: |
| 77 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 74 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |
| 78 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotificationPopupBubble); | 75 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotificationPopupBubble); |
| 79 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, | 76 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, |
| 80 ManyMessageCenterNotifications); | 77 ManyMessageCenterNotifications); |
| 81 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManyPopupNotifications); | 78 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManyPopupNotifications); |
| 82 | 79 |
| 83 // The actual process to show the message center. Set |show_settings| to true | 80 // The actual process to show the message center. Set |show_settings| to true |
| 84 // if the message center should be initialized with the settings visible. | 81 // if the message center should be initialized with the settings visible. |
| 85 // Returns true if the center is successfully created. | 82 // Returns true if the center is successfully created. |
| 86 bool ShowMessageCenterInternal(bool show_settings); | 83 bool ShowMessageCenterInternal(bool show_settings); |
| 84 |
| 85 PositionInfo GetPositionInfo(); |
| 86 |
| 87 StatusIcon* GetStatusIcon(); | 87 StatusIcon* GetStatusIcon(); |
| 88 void DestroyStatusIcon(); | 88 void DestroyStatusIcon(); |
| 89 void AddQuietModeMenu(StatusIcon* status_icon); | 89 void AddQuietModeMenu(StatusIcon* status_icon); |
| 90 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | 90 MessageCenterWidgetDelegate* GetMessageCenterWidgetDelegateForTest(); |
| 91 | 91 |
| 92 scoped_ptr<internal::NotificationBubbleWrapper> message_center_bubble_; | 92 MessageCenterWidgetDelegate* message_center_delegate_; |
| 93 scoped_ptr<message_center::MessagePopupCollection> popup_collection_; | 93 scoped_ptr<message_center::MessagePopupCollection> popup_collection_; |
| 94 | 94 |
| 95 StatusIcon* status_icon_; | 95 StatusIcon* status_icon_; |
| 96 bool message_center_visible_; | 96 bool message_center_visible_; |
| 97 scoped_ptr<MessageCenterTray> message_center_tray_; | 97 scoped_ptr<MessageCenterTray> message_center_tray_; |
| 98 gfx::Point mouse_click_point_; | 98 gfx::Point mouse_click_point_; |
| 99 | 99 |
| 100 bool should_update_tray_content_; | 100 bool should_update_tray_content_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 102 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace message_center | 105 } // namespace message_center |
| 106 | 106 |
| 107 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ | 107 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ |
| OLD | NEW |