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/system_tray_bubble.h" | 10 #include "ash/system/tray/system_tray_bubble.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 class AudioObserver; | 27 class AudioObserver; |
28 class BluetoothObserver; | 28 class BluetoothObserver; |
29 class BrightnessObserver; | 29 class BrightnessObserver; |
30 class CapsLockObserver; | 30 class CapsLockObserver; |
31 class ClockObserver; | 31 class ClockObserver; |
32 class DriveObserver; | 32 class DriveObserver; |
33 class IMEObserver; | 33 class IMEObserver; |
34 class LocaleObserver; | 34 class LocaleObserver; |
35 class LogoutButtonObserver; | 35 class LogoutButtonObserver; |
36 class PowerStatusObserver; | 36 class PowerStatusObserver; |
37 class SystemTrayDelegate; | |
37 class UpdateObserver; | 38 class UpdateObserver; |
38 class UserObserver; | 39 class UserObserver; |
39 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
40 class NetworkObserver; | 41 class NetworkObserver; |
41 class SmsObserver; | 42 class SmsObserver; |
42 #endif | 43 #endif |
43 | 44 |
44 class SystemTrayItem; | 45 class SystemTrayItem; |
45 | 46 |
46 namespace internal { | 47 namespace internal { |
47 class SystemBubbleWrapper; | 48 class SystemBubbleWrapper; |
48 class SystemTrayContainer; | 49 class SystemTrayContainer; |
49 class TrayGestureHandler; | 50 class TrayGestureHandler; |
50 } | 51 } |
51 | 52 |
52 // There are different methods for creating bubble views. | 53 // There are different methods for creating bubble views. |
53 enum BubbleCreationType { | 54 enum BubbleCreationType { |
54 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. | 55 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. |
55 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. | 56 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. |
56 }; | 57 }; |
57 | 58 |
58 class ASH_EXPORT SystemTray : public internal::TrayBackgroundView, | 59 class ASH_EXPORT SystemTray : public internal::TrayBackgroundView, |
59 public views::TrayBubbleView::Delegate { | 60 public views::TrayBubbleView::Delegate { |
60 public: | 61 public: |
61 explicit SystemTray(internal::StatusAreaWidget* status_area_widget); | 62 explicit SystemTray(internal::StatusAreaWidget* status_area_widget); |
62 virtual ~SystemTray(); | 63 virtual ~SystemTray(); |
63 | 64 |
64 // Creates the default set of items for the sytem tray. | 65 // Calls TrayBackgroundView::Initialize() |
sadrul
2012/11/13 20:54:50
" .. and creates the default set of items ..."
stevenjb
2012/11/13 21:19:53
Done.
| |
65 void CreateItems(); | 66 void InitializeTrayItems(SystemTrayDelegate* delegate); |
66 | 67 |
67 // Adds a new item in the tray. | 68 // Adds a new item in the tray. |
68 void AddTrayItem(SystemTrayItem* item); | 69 void AddTrayItem(SystemTrayItem* item); |
69 | 70 |
70 // Removes an existing tray item. | 71 // Removes an existing tray item. |
71 void RemoveTrayItem(SystemTrayItem* item); | 72 void RemoveTrayItem(SystemTrayItem* item); |
72 | 73 |
73 // Shows the default view of all items. | 74 // Shows the default view of all items. |
74 void ShowDefaultView(BubbleCreationType creation_type); | 75 void ShowDefaultView(BubbleCreationType creation_type); |
75 | 76 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 112 |
112 // Returns a pointer to the system bubble or NULL if none. | 113 // Returns a pointer to the system bubble or NULL if none. |
113 internal::SystemTrayBubble* GetSystemBubble(); | 114 internal::SystemTrayBubble* GetSystemBubble(); |
114 | 115 |
115 // Returns true if any bubble is visible. | 116 // Returns true if any bubble is visible. |
116 bool IsAnyBubbleVisible() const; | 117 bool IsAnyBubbleVisible() const; |
117 | 118 |
118 // Returns true if the mouse is inside the notification bubble. | 119 // Returns true if the mouse is inside the notification bubble. |
119 bool IsMouseInNotificationBubble() const; | 120 bool IsMouseInNotificationBubble() const; |
120 | 121 |
121 AccessibilityObserver* accessibility_observer() { | |
122 return accessibility_observer_; | |
123 } | |
124 AudioObserver* audio_observer() { | |
125 return audio_observer_; | |
126 } | |
127 BluetoothObserver* bluetooth_observer() { | |
128 return bluetooth_observer_; | |
129 } | |
130 BrightnessObserver* brightness_observer() { | |
131 return brightness_observer_; | |
132 } | |
133 CapsLockObserver* caps_lock_observer() { | |
134 return caps_lock_observer_; | |
135 } | |
136 ClockObserver* clock_observer() { | |
137 return clock_observer_; | |
138 } | |
139 DriveObserver* drive_observer() { | |
140 return drive_observer_; | |
141 } | |
142 IMEObserver* ime_observer() { | |
143 return ime_observer_; | |
144 } | |
145 LocaleObserver* locale_observer() { | |
146 return locale_observer_; | |
147 } | |
148 LogoutButtonObserver* logout_button_observer() { | |
149 return logout_button_observer_; | |
150 } | |
151 #if defined(OS_CHROMEOS) | |
152 NetworkObserver* network_observer() { | |
153 return network_observer_; | |
154 } | |
155 NetworkObserver* vpn_observer() { | |
156 return vpn_observer_; | |
157 } | |
158 SmsObserver* sms_observer() { | |
159 return sms_observer_; | |
160 } | |
161 #endif | |
162 ObserverList<PowerStatusObserver>& power_status_observers() { | |
163 return power_status_observers_; | |
164 } | |
165 UpdateObserver* update_observer() { | |
166 return update_observer_; | |
167 } | |
168 UserObserver* user_observer() { | |
169 return user_observer_; | |
170 } | |
171 | |
172 // Accessors for testing. | 122 // Accessors for testing. |
173 | 123 |
174 // Returns true if the bubble exists. | 124 // Returns true if the bubble exists. |
175 bool CloseBubbleForTest() const; | 125 bool CloseBubbleForTest() const; |
176 | 126 |
177 // Overridden from TrayBackgroundView. | 127 // Overridden from TrayBackgroundView. |
178 virtual void Initialize() OVERRIDE; | |
179 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; | 128 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; |
180 virtual void AnchorUpdated() OVERRIDE; | 129 virtual void AnchorUpdated() OVERRIDE; |
181 virtual string16 GetAccessibleNameForTray() OVERRIDE; | 130 virtual string16 GetAccessibleNameForTray() OVERRIDE; |
182 virtual void HideBubbleWithView( | 131 virtual void HideBubbleWithView( |
183 const views::TrayBubbleView* bubble_view) OVERRIDE; | 132 const views::TrayBubbleView* bubble_view) OVERRIDE; |
184 virtual bool ClickedOutsideBubble() OVERRIDE; | 133 virtual bool ClickedOutsideBubble() OVERRIDE; |
185 | 134 |
186 // Overridden from message_center::TrayBubbleView::Delegate. | 135 // Overridden from message_center::TrayBubbleView::Delegate. |
187 virtual void BubbleViewDestroyed() OVERRIDE; | 136 virtual void BubbleViewDestroyed() OVERRIDE; |
188 virtual void OnMouseEnteredView() OVERRIDE; | 137 virtual void OnMouseEnteredView() OVERRIDE; |
189 virtual void OnMouseExitedView() OVERRIDE; | 138 virtual void OnMouseExitedView() OVERRIDE; |
190 virtual string16 GetAccessibleNameForBubble() OVERRIDE; | 139 virtual string16 GetAccessibleNameForBubble() OVERRIDE; |
191 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, | 140 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, |
192 AnchorType anchor_type, | 141 AnchorType anchor_type, |
193 AnchorAlignment anchor_alignment) OVERRIDE; | 142 AnchorAlignment anchor_alignment) OVERRIDE; |
194 virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; | 143 virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; |
195 | 144 |
196 private: | 145 private: |
146 // Creates the default set of items for the sytem tray. | |
147 void CreateItems(SystemTrayDelegate* delegate); | |
148 | |
197 // Returns true if the system_bubble_ exists and is of type |type|. | 149 // Returns true if the system_bubble_ exists and is of type |type|. |
198 bool HasSystemBubbleType(internal::SystemTrayBubble::BubbleType type); | 150 bool HasSystemBubbleType(internal::SystemTrayBubble::BubbleType type); |
199 | 151 |
200 // Resets |system_bubble_| and clears any related state. | 152 // Resets |system_bubble_| and clears any related state. |
201 void DestroySystemBubble(); | 153 void DestroySystemBubble(); |
202 | 154 |
203 // Resets |notification_bubble_| and clears any related state. | 155 // Resets |notification_bubble_| and clears any related state. |
204 void DestroyNotificationBubble(); | 156 void DestroyNotificationBubble(); |
205 | 157 |
206 // Calculates the x-offset for the item in the tray. Returns -1 if its tray | 158 // Calculates the x-offset for the item in the tray. Returns -1 if its tray |
(...skipping 23 matching lines...) Expand all Loading... | |
230 // Owned items. | 182 // Owned items. |
231 ScopedVector<SystemTrayItem> items_; | 183 ScopedVector<SystemTrayItem> items_; |
232 | 184 |
233 // Pointers to members of |items_|. | 185 // Pointers to members of |items_|. |
234 SystemTrayItem* detailed_item_; | 186 SystemTrayItem* detailed_item_; |
235 std::vector<SystemTrayItem*> notification_items_; | 187 std::vector<SystemTrayItem*> notification_items_; |
236 | 188 |
237 // Mappings of system tray item and it's view in the tray. | 189 // Mappings of system tray item and it's view in the tray. |
238 std::map<SystemTrayItem*, views::View*> tray_item_map_; | 190 std::map<SystemTrayItem*, views::View*> tray_item_map_; |
239 | 191 |
240 // These observers are not owned by the tray. | |
241 AccessibilityObserver* accessibility_observer_; | |
242 AudioObserver* audio_observer_; | |
243 BluetoothObserver* bluetooth_observer_; | |
244 BrightnessObserver* brightness_observer_; | |
245 CapsLockObserver* caps_lock_observer_; | |
246 ClockObserver* clock_observer_; | |
247 DriveObserver* drive_observer_; | |
248 IMEObserver* ime_observer_; | |
249 LocaleObserver* locale_observer_; | |
250 LogoutButtonObserver* logout_button_observer_; | |
251 #if defined(OS_CHROMEOS) | |
252 NetworkObserver* network_observer_; | |
253 NetworkObserver* vpn_observer_; | |
254 SmsObserver* sms_observer_; | |
255 #endif | |
256 ObserverList<PowerStatusObserver> power_status_observers_; | |
257 UpdateObserver* update_observer_; | |
258 UserObserver* user_observer_; | |
259 | |
260 // Bubble for default and detailed views. | 192 // Bubble for default and detailed views. |
261 scoped_ptr<internal::SystemBubbleWrapper> system_bubble_; | 193 scoped_ptr<internal::SystemBubbleWrapper> system_bubble_; |
262 | 194 |
263 // Bubble for notifications. | 195 // Bubble for notifications. |
264 scoped_ptr<internal::SystemBubbleWrapper> notification_bubble_; | 196 scoped_ptr<internal::SystemBubbleWrapper> notification_bubble_; |
265 | 197 |
266 // Keep track of the default view height so that when we create detailed | 198 // Keep track of the default view height so that when we create detailed |
267 // views directly (e.g. from a notification) we know what height to use. | 199 // views directly (e.g. from a notification) we know what height to use. |
268 int default_bubble_height_; | 200 int default_bubble_height_; |
269 | 201 |
270 // Set to true when system notifications should be hidden (e.g. web | 202 // Set to true when system notifications should be hidden (e.g. web |
271 // notification bubble is visible). | 203 // notification bubble is visible). |
272 bool hide_notifications_; | 204 bool hide_notifications_; |
273 | 205 |
274 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 206 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
275 }; | 207 }; |
276 | 208 |
277 } // namespace ash | 209 } // namespace ash |
278 | 210 |
279 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 211 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
OLD | NEW |