| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 5 #ifndef ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
| 6 #define ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 6 #define ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/system/tray/tray_background_view.h" | 9 #include "ash/system/tray/tray_background_view.h" |
| 10 #include "ash/system/user/login_status.h" | 10 #include "ash/system/user/login_status.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "ui/aura/event_filter.h" | 12 #include "ui/aura/event_filter.h" |
| 13 | 13 |
| 14 namespace aura { | 14 namespace aura { |
| 15 class LocatedEvent; | 15 class LocatedEvent; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 class ImageSkia; | 19 class ImageSkia; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace views { | 22 namespace views { |
| 23 class ImageView; | 23 class Label; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace ash { | 26 namespace ash { |
| 27 | 27 |
| 28 namespace internal { | 28 namespace internal { |
| 29 class StatusAreaWidget; | 29 class StatusAreaWidget; |
| 30 class WebNotificationList; | 30 class WebNotificationList; |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Status area tray for showing browser and app notifications. The client | 33 // Status area tray for showing browser and app notifications. The client |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void RemoveAllNotifications(); | 97 void RemoveAllNotifications(); |
| 98 | 98 |
| 99 // Set the notification image. | 99 // Set the notification image. |
| 100 void SetNotificationImage(const std::string& id, | 100 void SetNotificationImage(const std::string& id, |
| 101 const gfx::ImageSkia& image); | 101 const gfx::ImageSkia& image); |
| 102 | 102 |
| 103 // Disable all notifications matching notification |id|. | 103 // Disable all notifications matching notification |id|. |
| 104 void DisableByExtension(const std::string& id); | 104 void DisableByExtension(const std::string& id); |
| 105 void DisableByUrl(const std::string& id); | 105 void DisableByUrl(const std::string& id); |
| 106 | 106 |
| 107 // Show the notification bubble. Should only be called by StatusAreaWidget. | 107 // Show the message center bubble. Should only be called by StatusAreaWidget. |
| 108 void ShowBubble(); | 108 void ShowMessageCenterBubble(); |
| 109 | 109 |
| 110 // Hide the notification bubble. Should only be called by StatusAreaWidget. | 110 // Hide the message center bubble. Should only be called by StatusAreaWidget. |
| 111 void HideBubble(); | 111 void HideMessageCenterBubble(); |
| 112 |
| 113 // Show a single notification bubble for the most recent notification. |
| 114 void ShowNotificationBubble(); |
| 115 |
| 116 // Hide the single notification bubble if visible. |
| 117 void HideNotificationBubble(); |
| 112 | 118 |
| 113 // Updates tray visibility login status of the system changes. | 119 // Updates tray visibility login status of the system changes. |
| 114 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); | 120 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); |
| 115 | 121 |
| 116 // Request the Delegate to the settings dialog. | 122 // Request the Delegate to the settings dialog. |
| 117 void ShowSettings(const std::string& id); | 123 void ShowSettings(const std::string& id); |
| 118 | 124 |
| 119 // Called when a notification is clicked on. Event is passed to the Delegate. | 125 // Called when a notification is clicked on. Event is passed to the Delegate. |
| 120 void OnClicked(const std::string& id); | 126 void OnClicked(const std::string& id); |
| 121 | 127 |
| 122 internal::StatusAreaWidget* status_area_widget() { | |
| 123 return status_area_widget_; | |
| 124 } | |
| 125 | |
| 126 // Overridden from TrayBackgroundView. | 128 // Overridden from TrayBackgroundView. |
| 127 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | 129 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; |
| 128 | 130 |
| 129 // Overridden from internal::ActionableView. | 131 // Overridden from internal::ActionableView. |
| 130 virtual bool PerformAction(const views::Event& event) OVERRIDE; | 132 virtual bool PerformAction(const views::Event& event) OVERRIDE; |
| 131 | 133 |
| 132 private: | 134 private: |
| 133 class Bubble; | 135 class Bubble; |
| 134 class BubbleContentsView; | |
| 135 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 136 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |
| 136 | 137 |
| 137 void SetBorder(); | |
| 138 void SetTrayContainerBorder(); | |
| 139 int GetNotificationCount() const; | 138 int GetNotificationCount() const; |
| 140 void UpdateIcon(); | 139 void UpdateTray(); |
| 141 void UpdateBubbleAndIcon(); | 140 void UpdateTrayAndBubble(); |
| 141 void HideBubble(Bubble* bubble); |
| 142 | 142 |
| 143 const internal::WebNotificationList* notification_list() const { | 143 const internal::WebNotificationList* notification_list() const { |
| 144 return notification_list_.get(); | 144 return notification_list_.get(); |
| 145 } | 145 } |
| 146 views::View* tray_container() const { return tray_container_; } | 146 Bubble* message_center_bubble() const { return message_center_bubble_.get(); } |
| 147 Bubble* bubble() const { return bubble_.get(); } | 147 Bubble* notification_bubble() const { return notification_bubble_.get(); } |
| 148 | 148 |
| 149 internal::StatusAreaWidget* status_area_widget_; // Unowned parent. | |
| 150 scoped_ptr<internal::WebNotificationList> notification_list_; | 149 scoped_ptr<internal::WebNotificationList> notification_list_; |
| 151 scoped_ptr<Bubble> bubble_; | 150 scoped_ptr<Bubble> message_center_bubble_; |
| 152 views::View* tray_container_; | 151 scoped_ptr<Bubble> notification_bubble_; |
| 153 views::ImageView* icon_; | 152 views::Label* count_label_; |
| 154 Delegate* delegate_; | 153 Delegate* delegate_; |
| 155 bool show_bubble_on_unlock_; | 154 bool show_message_center_on_unlock_; |
| 155 int unread_count_; |
| 156 | 156 |
| 157 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 157 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 } // namespace ash | 160 } // namespace ash |
| 161 | 161 |
| 162 #endif // ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 162 #endif // ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
| OLD | NEW |