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_TRAY_SYSTEM_TRAY_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/system/power/power_supply_status.h" | 9 #include "ash/system/power/power_supply_status.h" |
10 #include "ash/system/tray/tray_background_view.h" | 10 #include "ash/system/tray/tray_background_view.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 class SmsObserver; | 34 class SmsObserver; |
35 class PowerStatusObserver; | 35 class PowerStatusObserver; |
36 class UpdateObserver; | 36 class UpdateObserver; |
37 class UserObserver; | 37 class UserObserver; |
38 | 38 |
39 class SystemTrayItem; | 39 class SystemTrayItem; |
40 | 40 |
41 namespace internal { | 41 namespace internal { |
42 class SystemTrayBubble; | 42 class SystemTrayBubble; |
43 class SystemTrayContainer; | 43 class SystemTrayContainer; |
44 class SystemTrayLayerAnimationObserver; | |
45 } | 44 } |
46 | 45 |
47 // There are different methods for creating bubble views. | 46 // There are different methods for creating bubble views. |
48 enum BubbleCreationType { | 47 enum BubbleCreationType { |
49 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. | 48 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. |
50 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. | 49 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. |
51 }; | 50 }; |
52 | 51 |
53 class ASH_EXPORT SystemTray : public internal::TrayBackgroundView { | 52 class ASH_EXPORT SystemTray : public internal::TrayBackgroundView { |
54 public: | 53 public: |
55 explicit SystemTray(internal::StatusAreaWidget* status_area_widget); | 54 explicit SystemTray(internal::StatusAreaWidget* status_area_widget); |
56 virtual ~SystemTray(); | 55 virtual ~SystemTray(); |
57 | 56 |
58 // Called after the tray has been added to the widget containing it. | |
59 void Initialize(); | |
60 | |
61 // Creates the default set of items for the sytem tray. | 57 // Creates the default set of items for the sytem tray. |
62 void CreateItems(); | 58 void CreateItems(); |
63 | 59 |
64 // Adds a new item in the tray. | 60 // Adds a new item in the tray. |
65 void AddTrayItem(SystemTrayItem* item); | 61 void AddTrayItem(SystemTrayItem* item); |
66 | 62 |
67 // Removes an existing tray item. | 63 // Removes an existing tray item. |
68 void RemoveTrayItem(SystemTrayItem* item); | 64 void RemoveTrayItem(SystemTrayItem* item); |
69 | 65 |
70 // Shows the default view of all items. | 66 // Shows the default view of all items. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 UserObserver* user_observer() const { | 145 UserObserver* user_observer() const { |
150 return user_observer_; | 146 return user_observer_; |
151 } | 147 } |
152 | 148 |
153 // Accessors for testing. | 149 // Accessors for testing. |
154 | 150 |
155 // Returns true if the bubble exists. | 151 // Returns true if the bubble exists. |
156 bool CloseBubbleForTest() const; | 152 bool CloseBubbleForTest() const; |
157 | 153 |
158 // Overridden from TrayBackgroundView. | 154 // Overridden from TrayBackgroundView. |
| 155 virtual void Initialize() OVERRIDE; |
159 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | 156 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; |
| 157 virtual void AnchorUpdated() OVERRIDE; |
160 | 158 |
161 private: | 159 private: |
162 friend class internal::SystemTrayLayerAnimationObserver; | |
163 friend class internal::SystemTrayBubble; | 160 friend class internal::SystemTrayBubble; |
164 | 161 |
165 // Resets |bubble_| and clears any related state. | 162 // Resets |bubble_| and clears any related state. |
166 void DestroyBubble(); | 163 void DestroyBubble(); |
167 | 164 |
168 // Called when the widget associated with |bubble| closes. |bubble| should | 165 // Called when the widget associated with |bubble| closes. |bubble| should |
169 // always == |bubble_|. This triggers destroying |bubble_| and hiding the | 166 // always == |bubble_|. This triggers destroying |bubble_| and hiding the |
170 // launcher if necessary. | 167 // launcher if necessary. |
171 void RemoveBubble(internal::SystemTrayBubble* bubble); | 168 void RemoveBubble(internal::SystemTrayBubble* bubble); |
172 | 169 |
(...skipping 11 matching lines...) Expand all Loading... |
184 void ShowItems(const std::vector<SystemTrayItem*>& items, | 181 void ShowItems(const std::vector<SystemTrayItem*>& items, |
185 bool details, | 182 bool details, |
186 bool activate, | 183 bool activate, |
187 BubbleCreationType creation_type, | 184 BubbleCreationType creation_type, |
188 int x_offset); | 185 int x_offset); |
189 | 186 |
190 // Constructs or re-constructs |notification_bubble_| and populates it with | 187 // Constructs or re-constructs |notification_bubble_| and populates it with |
191 // |notification_items_|, or destroys it if there are no notification items. | 188 // |notification_items_|, or destroys it if there are no notification items. |
192 void UpdateNotificationBubble(); | 189 void UpdateNotificationBubble(); |
193 | 190 |
194 // Called when the anchor (tray or bubble) may have moved or changed. | |
195 void UpdateNotificationAnchor(); | |
196 | |
197 // Overridden from internal::ActionableView. | 191 // Overridden from internal::ActionableView. |
198 virtual bool PerformAction(const ui::Event& event) OVERRIDE; | 192 virtual bool PerformAction(const ui::Event& event) OVERRIDE; |
199 | 193 |
200 // Overridden from views::View. | 194 // Overridden from views::View. |
201 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 195 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
202 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 196 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
203 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | |
204 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 197 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
205 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | |
206 | 198 |
207 // Owned items. | 199 // Owned items. |
208 ScopedVector<SystemTrayItem> items_; | 200 ScopedVector<SystemTrayItem> items_; |
209 | 201 |
210 // Pointers to members of |items_|. | 202 // Pointers to members of |items_|. |
211 SystemTrayItem* detailed_item_; | 203 SystemTrayItem* detailed_item_; |
212 std::vector<SystemTrayItem*> notification_items_; | 204 std::vector<SystemTrayItem*> notification_items_; |
213 | 205 |
214 // Mappings of system tray item and it's view in the tray. | 206 // Mappings of system tray item and it's view in the tray. |
215 std::map<SystemTrayItem*, views::View*> tray_item_map_; | 207 std::map<SystemTrayItem*, views::View*> tray_item_map_; |
(...skipping 16 matching lines...) Expand all Loading... |
232 | 224 |
233 // Bubble for default and detailed views. | 225 // Bubble for default and detailed views. |
234 scoped_ptr<internal::SystemTrayBubble> bubble_; | 226 scoped_ptr<internal::SystemTrayBubble> bubble_; |
235 | 227 |
236 // Bubble for notifications. | 228 // Bubble for notifications. |
237 scoped_ptr<internal::SystemTrayBubble> notification_bubble_; | 229 scoped_ptr<internal::SystemTrayBubble> notification_bubble_; |
238 | 230 |
239 // See description agove getter. | 231 // See description agove getter. |
240 bool should_show_launcher_; | 232 bool should_show_launcher_; |
241 | 233 |
242 scoped_ptr<internal::SystemTrayLayerAnimationObserver> | |
243 layer_animation_observer_; | |
244 | |
245 // Keep track of the default view height so that when we create detailed | 234 // Keep track of the default view height so that when we create detailed |
246 // views directly (e.g. from a notification) we know what height to use. | 235 // views directly (e.g. from a notification) we know what height to use. |
247 int default_bubble_height_; | 236 int default_bubble_height_; |
248 | 237 |
249 // Set to true when system notifications should be hidden (e.g. web | 238 // Set to true when system notifications should be hidden (e.g. web |
250 // notification bubble is visible). | 239 // notification bubble is visible). |
251 bool hide_notifications_; | 240 bool hide_notifications_; |
252 | 241 |
253 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 242 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
254 }; | 243 }; |
255 | 244 |
256 } // namespace ash | 245 } // namespace ash |
257 | 246 |
258 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 247 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
OLD | NEW |