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 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
21 | 22 |
22 // Status area tray for showing browser and app notifications. This hosts | 23 // Status area tray for showing browser and app notifications. This hosts |
23 // a MessageCenter class which manages the notification list. This class | 24 // a MessageCenter class which manages the notification list. This class |
24 // contains the Ash specific tray implementation. | 25 // contains the Ash specific tray implementation. |
25 // | 26 // |
26 // Note: These are not related to system notifications (i.e NotificationView | 27 // Note: These are not related to system notifications (i.e NotificationView |
(...skipping 10 matching lines...) Expand all Loading... | |
37 class MessageCenter; | 38 class MessageCenter; |
38 class MessageCenterBubble; | 39 class MessageCenterBubble; |
39 class MessagePopupCollection; | 40 class MessagePopupCollection; |
40 } | 41 } |
41 | 42 |
42 namespace ash { | 43 namespace ash { |
43 class AshPopupAlignmentDelegate; | 44 class AshPopupAlignmentDelegate; |
44 class SystemTray; | 45 class SystemTray; |
45 class WebNotificationBubbleWrapper; | 46 class WebNotificationBubbleWrapper; |
46 class WebNotificationButton; | 47 class WebNotificationButton; |
48 class WebNotificationImage; | |
49 class WebNotificationLabel; | |
47 class WmWindow; | 50 class WmWindow; |
48 | 51 |
49 class ASH_EXPORT WebNotificationTray | 52 class ASH_EXPORT WebNotificationTray |
50 : public TrayBackgroundView, | 53 : public TrayBackgroundView, |
51 public views::TrayBubbleView::Delegate, | 54 public views::TrayBubbleView::Delegate, |
52 public message_center::MessageCenterTrayDelegate, | 55 public message_center::MessageCenterTrayDelegate, |
53 public views::ButtonListener, | |
54 public base::SupportsWeakPtr<WebNotificationTray>, | 56 public base::SupportsWeakPtr<WebNotificationTray>, |
55 public ui::SimpleMenuModel::Delegate { | 57 public ui::SimpleMenuModel::Delegate { |
56 public: | 58 public: |
57 WebNotificationTray(WmShelf* shelf, | 59 WebNotificationTray(WmShelf* shelf, |
58 WmWindow* status_area_window, | 60 WmWindow* status_area_window, |
59 SystemTray* system_tray); | 61 SystemTray* system_tray); |
60 ~WebNotificationTray() override; | 62 ~WebNotificationTray() override; |
61 | 63 |
62 // 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) |
63 // 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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 base::string16 GetAccessibleNameForBubble() override; | 101 base::string16 GetAccessibleNameForBubble() override; |
100 gfx::Rect GetAnchorRect(views::Widget* anchor_widget, | 102 gfx::Rect GetAnchorRect(views::Widget* anchor_widget, |
101 AnchorType anchor_type, | 103 AnchorType anchor_type, |
102 AnchorAlignment anchor_alignment) const override; | 104 AnchorAlignment anchor_alignment) const override; |
103 void OnBeforeBubbleWidgetInit( | 105 void OnBeforeBubbleWidgetInit( |
104 views::Widget* anchor_widget, | 106 views::Widget* anchor_widget, |
105 views::Widget* bubble_widget, | 107 views::Widget* bubble_widget, |
106 views::Widget::InitParams* params) const override; | 108 views::Widget::InitParams* params) const override; |
107 void HideBubble(const views::TrayBubbleView* bubble_view) override; | 109 void HideBubble(const views::TrayBubbleView* bubble_view) override; |
108 | 110 |
109 // Overridden from ButtonListener. | |
110 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
111 | |
112 // Overridden from MessageCenterTrayDelegate. | 111 // Overridden from MessageCenterTrayDelegate. |
113 void OnMessageCenterTrayChanged() override; | 112 void OnMessageCenterTrayChanged() override; |
114 bool ShowMessageCenter() override; | 113 bool ShowMessageCenter() override; |
115 void HideMessageCenter() override; | 114 void HideMessageCenter() override; |
116 bool ShowPopups() override; | 115 bool ShowPopups() override; |
117 void HidePopups() override; | 116 void HidePopups() override; |
118 bool ShowNotifierSettings() override; | 117 bool ShowNotifierSettings() override; |
119 bool IsContextMenuEnabled() const override; | 118 bool IsContextMenuEnabled() const override; |
120 message_center::MessageCenterTray* GetMessageCenterTray() override; | 119 message_center::MessageCenterTray* GetMessageCenterTray() override; |
121 | 120 |
122 // Overridden from SimpleMenuModel::Delegate. | 121 // Overridden from ui::SimpleMenuModel::Delegate. |
123 bool IsCommandIdChecked(int command_id) const override; | 122 bool IsCommandIdChecked(int command_id) const override; |
124 bool IsCommandIdEnabled(int command_id) const override; | 123 bool IsCommandIdEnabled(int command_id) const override; |
125 void ExecuteCommand(int command_id, int event_flags) override; | 124 void ExecuteCommand(int command_id, int event_flags) override; |
126 | 125 |
127 message_center::MessageCenter* message_center() const; | 126 message_center::MessageCenter* message_center() const; |
128 | 127 |
129 private: | 128 private: |
130 friend class WebNotificationTrayTest; | 129 friend class WebNotificationTrayTest; |
131 | 130 |
132 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... | |
168 | 167 |
169 // Testing accessors. | 168 // Testing accessors. |
170 bool IsPopupVisible() const; | 169 bool IsPopupVisible() const; |
171 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); | 170 message_center::MessageCenterBubble* GetMessageCenterBubbleForTest(); |
172 | 171 |
173 WmWindow* status_area_window_; | 172 WmWindow* status_area_window_; |
174 SystemTray* system_tray_; | 173 SystemTray* system_tray_; |
175 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; | 174 std::unique_ptr<message_center::MessageCenterTray> message_center_tray_; |
176 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; | 175 std::unique_ptr<WebNotificationBubbleWrapper> message_center_bubble_; |
177 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; | 176 std::unique_ptr<message_center::MessagePopupCollection> popup_collection_; |
178 WebNotificationButton* button_; | 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::map<std::string, WebNotificationImage*> visible_small_icons_; | |
oshima
2016/08/04 18:15:21
is order important? if not, unordered_map
yoshiki
2016/08/05 13:30:48
Let me use unordered_map.
| |
179 | 184 |
180 bool show_message_center_on_unlock_; | 185 bool show_message_center_on_unlock_; |
181 | 186 |
182 bool should_update_tray_content_; | 187 bool should_update_tray_content_; |
183 | 188 |
184 // 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 |
185 // this was done by checking |message_center_bubble_| but actually | 190 // this was done by checking |message_center_bubble_| but actually |
186 // 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 |
187 // 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 |
188 bool should_block_shelf_auto_hide_; | 193 bool should_block_shelf_auto_hide_; |
189 | 194 |
190 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; | 195 std::unique_ptr<AshPopupAlignmentDelegate> popup_alignment_delegate_; |
191 | 196 |
192 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); | 197 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray); |
193 }; | 198 }; |
194 | 199 |
195 } // namespace ash | 200 } // namespace ash |
196 | 201 |
197 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ | 202 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_ |
OLD | NEW |