| 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_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 5 #ifndef ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
| 6 #define ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 6 #define ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/common/login_status.h" | 11 #include "ash/common/login_status.h" |
| 12 #include "ash/common/system/tray/tray_background_view.h" | 12 #include "ash/common/system/tray/tray_background_view.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "ui/base/models/simple_menu_model.h" | 16 #include "ui/base/models/simple_menu_model.h" |
| 17 #include "ui/gfx/animation/animation_container.h" |
| 17 #include "ui/message_center/message_center_tray.h" | 18 #include "ui/message_center/message_center_tray.h" |
| 18 #include "ui/message_center/message_center_tray_delegate.h" | 19 #include "ui/message_center/message_center_tray_delegate.h" |
| 19 #include "ui/views/bubble/tray_bubble_view.h" | 20 #include "ui/views/bubble/tray_bubble_view.h" |
| 20 | 21 |
| 21 // Status area tray for showing browser and app notifications. This hosts | 22 // Status area tray for showing browser and app notifications. This hosts |
| 22 // a MessageCenter class which manages the notification list. This class | 23 // a MessageCenter class which manages the notification list. This class |
| 23 // contains the Ash specific tray implementation. | 24 // contains the Ash specific tray implementation. |
| 24 // | 25 // |
| 25 // Note: These are not related to system notifications (i.e NotificationView | 26 // Note: These are not related to system notifications (i.e NotificationView |
| 26 // generated by SystemTrayItem). Visibility of one notification type or other | 27 // generated by SystemTrayItem). Visibility of one notification type or other |
| 27 // is controlled by StatusAreaWidget. | 28 // is controlled by StatusAreaWidget. |
| 28 | 29 |
| 29 namespace views { | 30 namespace views { |
| 30 class MenuRunner; | 31 class MenuRunner; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace message_center { | 34 namespace message_center { |
| 34 class MessageBubbleBase; | 35 class MessageBubbleBase; |
| 35 class MessageCenter; | 36 class MessageCenter; |
| 36 class MessageCenterBubble; | 37 class MessageCenterBubble; |
| 37 class MessagePopupCollection; | 38 class MessagePopupCollection; |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace ash { | 41 namespace ash { |
| 41 class AshPopupAlignmentDelegate; | 42 class AshPopupAlignmentDelegate; |
| 42 class SystemTray; | 43 class SystemTray; |
| 43 class WebNotificationBubbleWrapper; | 44 class WebNotificationBubbleWrapper; |
| 44 class WebNotificationIcon; | 45 class WebNotificationButton; |
| 46 class WebNotificationImage; |
| 47 class WebNotificationLabel; |
| 45 class WmWindow; | 48 class WmWindow; |
| 46 | 49 |
| 47 class ASH_EXPORT WebNotificationTray | 50 class ASH_EXPORT WebNotificationTray |
| 48 : public TrayBackgroundView, | 51 : public TrayBackgroundView, |
| 49 public views::TrayBubbleView::Delegate, | 52 public views::TrayBubbleView::Delegate, |
| 50 public message_center::MessageCenterTrayDelegate, | 53 public message_center::MessageCenterTrayDelegate, |
| 51 public base::SupportsWeakPtr<WebNotificationTray>, | 54 public base::SupportsWeakPtr<WebNotificationTray>, |
| 52 public ui::SimpleMenuModel::Delegate { | 55 public ui::SimpleMenuModel::Delegate { |
| 53 public: | 56 public: |
| 54 WebNotificationTray(WmShelf* shelf, | 57 WebNotificationTray(WmShelf* shelf, |
| 55 WmWindow* status_area_window, | 58 WmWindow* status_area_window, |
| 56 SystemTray* system_tray); | 59 SystemTray* system_tray); |
| 57 ~WebNotificationTray() override; | 60 ~WebNotificationTray() override; |
| 58 | 61 |
| 62 static void DisableAnimationsForTest(bool disable); |
| 63 |
| 59 // Sets the height of the system tray bubble (or legacy notification bubble) | 64 // Sets the height of the system tray bubble (or legacy notification bubble) |
| 60 // from the edge of the work area so that the web notification popups don't | 65 // from the edge of the work area so that the web notification popups don't |
| 61 // overlap with the tray. Pass 0 if no bubble is shown. | 66 // overlap with the tray. Pass 0 if no bubble is shown. |
| 62 void SetTrayBubbleHeight(int height); | 67 void SetTrayBubbleHeight(int height); |
| 63 | 68 |
| 64 // Returns the current tray bubble height or 0 if there is no bubble. | 69 // Returns the current tray bubble height or 0 if there is no bubble. |
| 65 int tray_bubble_height_for_test() const; | 70 int tray_bubble_height_for_test() const; |
| 66 | 71 |
| 67 // Returns true if it should block the auto hide behavior of the shelf. | 72 // Returns true if it should block the auto hide behavior of the shelf. |
| 68 bool ShouldBlockShelfAutoHide() const; | 73 bool ShouldBlockShelfAutoHide() const; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Overridden from MessageCenterTrayDelegate. | 111 // Overridden from MessageCenterTrayDelegate. |
| 107 void OnMessageCenterTrayChanged() override; | 112 void OnMessageCenterTrayChanged() override; |
| 108 bool ShowMessageCenter() override; | 113 bool ShowMessageCenter() override; |
| 109 void HideMessageCenter() override; | 114 void HideMessageCenter() override; |
| 110 bool ShowPopups() override; | 115 bool ShowPopups() override; |
| 111 void HidePopups() override; | 116 void HidePopups() override; |
| 112 bool ShowNotifierSettings() override; | 117 bool ShowNotifierSettings() override; |
| 113 bool IsContextMenuEnabled() const override; | 118 bool IsContextMenuEnabled() const override; |
| 114 message_center::MessageCenterTray* GetMessageCenterTray() override; | 119 message_center::MessageCenterTray* GetMessageCenterTray() override; |
| 115 | 120 |
| 116 // Overridden from SimpleMenuModel::Delegate. | 121 // Overridden from ui::SimpleMenuModel::Delegate. |
| 117 bool IsCommandIdChecked(int command_id) const override; | 122 bool IsCommandIdChecked(int command_id) const override; |
| 118 bool IsCommandIdEnabled(int command_id) const override; | 123 bool IsCommandIdEnabled(int command_id) const override; |
| 119 void ExecuteCommand(int command_id, int event_flags) override; | 124 void ExecuteCommand(int command_id, int event_flags) override; |
| 120 | 125 |
| 121 message_center::MessageCenter* message_center() const; | 126 message_center::MessageCenter* message_center() const; |
| 122 | 127 |
| 123 private: | 128 private: |
| 124 friend class WebNotificationTrayTest; | 129 friend class WebNotificationTrayTest; |
| 125 | 130 |
| 126 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); | 131 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 167 |
| 163 // Testing accessors. | 168 // Testing accessors. |
| 164 bool IsPopupVisible() const; | 169 bool IsPopupVisible() const; |
| 165 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | 170 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); |
| 166 | 171 |
| 167 WmWindow* status_area_window_; | 172 WmWindow* status_area_window_; |
| 168 SystemTray* system_tray_; | 173 SystemTray* system_tray_; |
| 169 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; | 174 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; |
| 170 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; | 175 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; |
| 171 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; | 176 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; |
| 172 WebNotificationIcon* icon_; | 177 std::unique_ptr<WebNotificationImage> bell_icon_; |
| 178 std::unique_ptr<WebNotificationLabel> counter_; |
| 179 |
| 180 scoped_refptr<gfx::AnimationContainer> animation_container_ = |
| 181 new gfx::AnimationContainer(); |
| 182 |
| 183 std::unordered_map<std::string, WebNotificationImage*> visible_small_icons_; |
| 173 | 184 |
| 174 bool show_message_center_on_unlock_; | 185 bool show_message_center_on_unlock_; |
| 175 | 186 |
| 176 bool should_update_tray_content_; | 187 bool should_update_tray_content_; |
| 177 | 188 |
| 178 // True when the shelf auto hide behavior has to be blocked. Previously | 189 // True when the shelf auto hide behavior has to be blocked. Previously |
| 179 // this was done by checking |message_center_bubble_| but actually | 190 // this was done by checking |message_center_bubble_| but actually |
| 180 // the check can be called when creating this object, so it would cause | 191 // the check can be called when creating this object, so it would cause |
| 181 // flickers of the shelf from hidden to shown. See: crbug.com/181213 | 192 // flickers of the shelf from hidden to shown. See: crbug.com/181213 |
| 182 bool should_block_shelf_auto_hide_; | 193 bool should_block_shelf_auto_hide_; |
| 183 | 194 |
| 184 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; | 195 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; |
| 185 | 196 |
| 186 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 197 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
| 187 }; | 198 }; |
| 188 | 199 |
| 189 } // namespace ash | 200 } // namespace ash |
| 190 | 201 |
| 191 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 202 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
| OLD | NEW |