Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: ash/system/tray/system_tray.h

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

Powered by Google App Engine
This is Rietveld 408576698