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

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: Add comment. 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
« no previous file with comments | « ash/system/status_area_widget.cc ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 16 matching lines...) Expand all
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(), creates the tray items, and
65 void CreateItems(); 66 // adds them to SystemTrayNotifier.
67 void InitializeTrayItems(SystemTrayDelegate* delegate);
66 68
67 // Adds a new item in the tray. 69 // Adds a new item in the tray.
68 void AddTrayItem(SystemTrayItem* item); 70 void AddTrayItem(SystemTrayItem* item);
69 71
70 // Removes an existing tray item. 72 // Removes an existing tray item.
71 void RemoveTrayItem(SystemTrayItem* item); 73 void RemoveTrayItem(SystemTrayItem* item);
72 74
73 // Shows the default view of all items. 75 // Shows the default view of all items.
74 void ShowDefaultView(BubbleCreationType creation_type); 76 void ShowDefaultView(BubbleCreationType creation_type);
75 77
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 113
112 // Returns a pointer to the system bubble or NULL if none. 114 // Returns a pointer to the system bubble or NULL if none.
113 internal::SystemTrayBubble* GetSystemBubble(); 115 internal::SystemTrayBubble* GetSystemBubble();
114 116
115 // Returns true if any bubble is visible. 117 // Returns true if any bubble is visible.
116 bool IsAnyBubbleVisible() const; 118 bool IsAnyBubbleVisible() const;
117 119
118 // Returns true if the mouse is inside the notification bubble. 120 // Returns true if the mouse is inside the notification bubble.
119 bool IsMouseInNotificationBubble() const; 121 bool IsMouseInNotificationBubble() const;
120 122
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. 123 // Accessors for testing.
173 124
174 // Returns true if the bubble exists. 125 // Returns true if the bubble exists.
175 bool CloseBubbleForTest() const; 126 bool CloseBubbleForTest() const;
176 127
177 // Overridden from TrayBackgroundView. 128 // Overridden from TrayBackgroundView.
178 virtual void Initialize() OVERRIDE;
179 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE; 129 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
180 virtual void AnchorUpdated() OVERRIDE; 130 virtual void AnchorUpdated() OVERRIDE;
181 virtual string16 GetAccessibleNameForTray() OVERRIDE; 131 virtual string16 GetAccessibleNameForTray() OVERRIDE;
182 virtual void HideBubbleWithView( 132 virtual void HideBubbleWithView(
183 const views::TrayBubbleView* bubble_view) OVERRIDE; 133 const views::TrayBubbleView* bubble_view) OVERRIDE;
184 virtual bool ClickedOutsideBubble() OVERRIDE; 134 virtual bool ClickedOutsideBubble() OVERRIDE;
185 135
186 // Overridden from message_center::TrayBubbleView::Delegate. 136 // Overridden from message_center::TrayBubbleView::Delegate.
187 virtual void BubbleViewDestroyed() OVERRIDE; 137 virtual void BubbleViewDestroyed() OVERRIDE;
188 virtual void OnMouseEnteredView() OVERRIDE; 138 virtual void OnMouseEnteredView() OVERRIDE;
189 virtual void OnMouseExitedView() OVERRIDE; 139 virtual void OnMouseExitedView() OVERRIDE;
190 virtual string16 GetAccessibleNameForBubble() OVERRIDE; 140 virtual string16 GetAccessibleNameForBubble() OVERRIDE;
191 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, 141 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget,
192 AnchorType anchor_type, 142 AnchorType anchor_type,
193 AnchorAlignment anchor_alignment) OVERRIDE; 143 AnchorAlignment anchor_alignment) OVERRIDE;
194 virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE; 144 virtual void HideBubble(const views::TrayBubbleView* bubble_view) OVERRIDE;
195 145
196 private: 146 private:
147 // Creates the default set of items for the sytem tray.
148 void CreateItems(SystemTrayDelegate* delegate);
149
197 // Returns true if the system_bubble_ exists and is of type |type|. 150 // Returns true if the system_bubble_ exists and is of type |type|.
198 bool HasSystemBubbleType(internal::SystemTrayBubble::BubbleType type); 151 bool HasSystemBubbleType(internal::SystemTrayBubble::BubbleType type);
199 152
200 // Resets |system_bubble_| and clears any related state. 153 // Resets |system_bubble_| and clears any related state.
201 void DestroySystemBubble(); 154 void DestroySystemBubble();
202 155
203 // Resets |notification_bubble_| and clears any related state. 156 // Resets |notification_bubble_| and clears any related state.
204 void DestroyNotificationBubble(); 157 void DestroyNotificationBubble();
205 158
206 // Calculates the x-offset for the item in the tray. Returns -1 if its tray 159 // Calculates the x-offset for the item in the tray. Returns -1 if its tray
(...skipping 23 matching lines...) Expand all
230 // Owned items. 183 // Owned items.
231 ScopedVector<SystemTrayItem> items_; 184 ScopedVector<SystemTrayItem> items_;
232 185
233 // Pointers to members of |items_|. 186 // Pointers to members of |items_|.
234 SystemTrayItem* detailed_item_; 187 SystemTrayItem* detailed_item_;
235 std::vector<SystemTrayItem*> notification_items_; 188 std::vector<SystemTrayItem*> notification_items_;
236 189
237 // Mappings of system tray item and it's view in the tray. 190 // Mappings of system tray item and it's view in the tray.
238 std::map<SystemTrayItem*, views::View*> tray_item_map_; 191 std::map<SystemTrayItem*, views::View*> tray_item_map_;
239 192
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. 193 // Bubble for default and detailed views.
261 scoped_ptr<internal::SystemBubbleWrapper> system_bubble_; 194 scoped_ptr<internal::SystemBubbleWrapper> system_bubble_;
262 195
263 // Bubble for notifications. 196 // Bubble for notifications.
264 scoped_ptr<internal::SystemBubbleWrapper> notification_bubble_; 197 scoped_ptr<internal::SystemBubbleWrapper> notification_bubble_;
265 198
266 // Keep track of the default view height so that when we create detailed 199 // 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. 200 // views directly (e.g. from a notification) we know what height to use.
268 int default_bubble_height_; 201 int default_bubble_height_;
269 202
270 // Set to true when system notifications should be hidden (e.g. web 203 // Set to true when system notifications should be hidden (e.g. web
271 // notification bubble is visible). 204 // notification bubble is visible).
272 bool hide_notifications_; 205 bool hide_notifications_;
273 206
274 DISALLOW_COPY_AND_ASSIGN(SystemTray); 207 DISALLOW_COPY_AND_ASSIGN(SystemTray);
275 }; 208 };
276 209
277 } // namespace ash 210 } // namespace ash
278 211
279 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ 212 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_
OLDNEW
« no previous file with comments | « ash/system/status_area_widget.cc ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698