Chromium Code Reviews| 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; | 21 class MessageCenterBubble; |
| 20 class MessagePopupCollection; | 22 class MessagePopupCollection; |
| 21 } | 23 } |
| 22 | 24 |
| 23 namespace views { | 25 namespace views { |
| 24 class Widget; | 26 class Widget; |
| 25 } | 27 } |
| 26 | 28 |
| 27 namespace message_center { | 29 namespace message_center { |
| 28 | 30 |
| 29 namespace internal { | 31 class MessageCenterWidgetDelegate; |
| 30 class NotificationBubbleWrapper; | |
| 31 } | |
| 32 | 32 |
| 33 // A MessageCenterTrayDelegate implementation that exposes the MessageCenterTray | 33 // A MessageCenterTrayDelegate implementation that exposes the MessageCenterTray |
| 34 // via a system tray icon. The notification popups will be displayed in the | 34 // 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 | 35 // corner of the screen and the message center will be displayed by the system |
| 36 // tray icon on click. | 36 // tray icon on click. |
| 37 class WebNotificationTray : public message_center::MessageCenterTrayDelegate, | 37 class WebNotificationTray : public message_center::MessageCenterTrayDelegate, |
| 38 public StatusIconObserver, | 38 public StatusIconObserver, |
| 39 public views::WidgetObserver, | |
|
dewittj
2013/06/28 01:13:18
This doesn't appear to be used in this class.
sidharthms
2013/07/02 18:09:51
Done.
| |
| 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 UpdatePopups() OVERRIDE; | 52 virtual void UpdatePopups() OVERRIDE; |
| 52 virtual void OnMessageCenterTrayChanged() OVERRIDE; | 53 virtual void OnMessageCenterTrayChanged() OVERRIDE; |
| 53 virtual bool ShowNotifierSettings() OVERRIDE; | 54 virtual bool ShowNotifierSettings() OVERRIDE; |
| 54 | 55 |
| 55 // These are forwarded to WebNotificationTray by | |
| 56 // NotificationBubbleWrapper classes since they don't have enough | |
| 57 // context to provide the required data for TrayBubbleView::Delegate. | |
| 58 gfx::Rect GetMessageCenterAnchor(); | |
| 59 gfx::Rect GetPopupAnchor(); | |
| 60 gfx::NativeView GetBubbleWindowContainer(); | |
| 61 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment(); | |
| 62 | |
| 63 // StatusIconObserver implementation. | 56 // StatusIconObserver implementation. |
| 64 virtual void OnStatusIconClicked() OVERRIDE; | 57 virtual void OnStatusIconClicked() OVERRIDE; |
| 65 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 66 virtual void OnBalloonClicked() OVERRIDE; | 59 virtual void OnBalloonClicked() OVERRIDE; |
| 67 | 60 |
| 68 // This shows a platform-specific balloon informing the user of the existence | 61 // This shows a platform-specific balloon informing the user of the existence |
| 69 // of the message center in the status tray area. | 62 // of the message center in the status tray area. |
| 70 void DisplayFirstRunBalloon(); | 63 void DisplayFirstRunBalloon(); |
| 71 #endif | 64 #endif |
| 72 | 65 |
| 73 // Changes the icon and hovertext based on number of unread notifications. | 66 // Changes the icon and hovertext based on number of unread notifications. |
| 74 void UpdateStatusIcon(); | 67 void UpdateStatusIcon(); |
| 75 void HideBubbleWithView(const views::TrayBubbleView* bubble_view); | 68 void HideBubble(); |
| 69 | |
| 70 // Gets the point where the status icon was clicked. | |
| 71 gfx::Point mouse_click_point() { return mouse_click_point_; } | |
| 76 | 72 |
| 77 private: | 73 private: |
| 78 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 74 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |
| 79 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotificationPopupBubble); | 75 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotificationPopupBubble); |
| 80 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, | 76 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, |
| 81 ManyMessageCenterNotifications); | 77 ManyMessageCenterNotifications); |
| 82 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManyPopupNotifications); | 78 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManyPopupNotifications); |
| 83 | 79 |
| 84 // 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 |
| 85 // if the message center should be initialized with the settings visible. | 81 // if the message center should be initialized with the settings visible. |
| 86 // Returns true if the center is successfully created. | 82 // Returns true if the center is successfully created. |
| 87 bool ShowMessageCenterInternal(bool show_settings); | 83 bool ShowMessageCenterInternal(bool show_settings); |
| 88 StatusIcon* GetStatusIcon(); | 84 StatusIcon* GetStatusIcon(); |
| 89 void DestroyStatusIcon(); | 85 void DestroyStatusIcon(); |
| 90 void AddQuietModeMenu(StatusIcon* status_icon); | 86 void AddQuietModeMenu(StatusIcon* status_icon); |
| 91 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | 87 MessageCenterWidgetDelegate* GetMessageCenterWidgetDelegateForTest(); |
| 92 | 88 |
| 93 scoped_ptr<internal::NotificationBubbleWrapper> message_center_bubble_; | 89 MessageCenterWidgetDelegate* message_center_delegate_; |
| 94 scoped_ptr<message_center::MessagePopupCollection> popup_collection_; | 90 scoped_ptr<message_center::MessagePopupCollection> popup_collection_; |
| 95 | 91 |
| 96 StatusIcon* status_icon_; | 92 StatusIcon* status_icon_; |
| 97 bool message_center_visible_; | 93 bool message_center_visible_; |
| 98 scoped_ptr<MessageCenterTray> message_center_tray_; | 94 scoped_ptr<MessageCenterTray> message_center_tray_; |
| 99 gfx::Point mouse_click_point_; | 95 gfx::Point mouse_click_point_; |
| 100 | 96 |
| 101 bool should_update_tray_content_; | 97 bool should_update_tray_content_; |
| 102 | 98 |
| 103 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 99 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
| 104 }; | 100 }; |
| 105 | 101 |
| 106 } // namespace message_center | 102 } // namespace message_center |
| 107 | 103 |
| 108 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ | 104 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_WEB_NOTIFICATION_TRAY_H_ |
| OLD | NEW |