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 #include "ash/system/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell/panel_window.h" | 8 #include "ash/shell/panel_window.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/system/audio/tray_volume.h" | 10 #include "ash/system/audio/tray_volume.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 internal::TrayNetwork* tray_network = new internal::TrayNetwork; | 174 internal::TrayNetwork* tray_network = new internal::TrayNetwork; |
175 internal::TraySms* tray_sms = new internal::TraySms(); | 175 internal::TraySms* tray_sms = new internal::TraySms(); |
176 internal::TrayUser* tray_user = new internal::TrayUser; | 176 internal::TrayUser* tray_user = new internal::TrayUser; |
177 internal::TrayAccessibility* tray_accessibility = | 177 internal::TrayAccessibility* tray_accessibility = |
178 new internal::TrayAccessibility; | 178 new internal::TrayAccessibility; |
179 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; | 179 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; |
180 internal::TrayDrive* tray_drive = new internal::TrayDrive; | 180 internal::TrayDrive* tray_drive = new internal::TrayDrive; |
181 internal::TrayIME* tray_ime = new internal::TrayIME; | 181 internal::TrayIME* tray_ime = new internal::TrayIME; |
182 internal::TrayLocale* tray_locale = new internal::TrayLocale; | 182 internal::TrayLocale* tray_locale = new internal::TrayLocale; |
183 internal::TrayUpdate* tray_update = new internal::TrayUpdate; | 183 internal::TrayUpdate* tray_update = new internal::TrayUpdate; |
184 internal::TraySettings* tray_settings = new internal::TraySettings(); | |
184 | 185 |
185 accessibility_observer_ = tray_accessibility; | 186 accessibility_observer_ = tray_accessibility; |
186 audio_observer_ = tray_volume; | 187 audio_observer_ = tray_volume; |
187 bluetooth_observer_ = tray_bluetooth; | 188 bluetooth_observer_ = tray_bluetooth; |
188 brightness_observer_ = tray_brightness; | 189 brightness_observer_ = tray_brightness; |
189 caps_lock_observer_ = tray_caps_lock; | 190 caps_lock_observer_ = tray_caps_lock; |
190 clock_observer_ = tray_date; | 191 clock_observer_ = tray_date; |
191 drive_observer_ = tray_drive; | 192 drive_observer_ = tray_drive; |
192 ime_observer_ = tray_ime; | 193 ime_observer_ = tray_ime; |
193 locale_observer_ = tray_locale; | 194 locale_observer_ = tray_locale; |
194 network_observer_ = tray_network; | 195 network_observer_ = tray_network; |
195 power_status_observer_ = tray_power; | 196 power_status_observer_ = tray_power; |
stevenjb
2012/06/07 01:31:18
Remove this?
sadrul
2012/06/07 15:14:35
A bit ugly, but a slightly different approach: mak
jennyz
2012/06/07 22:06:52
Done.
jennyz
2012/06/07 22:06:52
Done.
| |
197 power_status_observers_.push_back(tray_power); | |
198 power_status_observers_.push_back(tray_settings); | |
196 update_observer_ = tray_update; | 199 update_observer_ = tray_update; |
197 user_observer_ = tray_user; | 200 user_observer_ = tray_user; |
198 | 201 |
199 AddTrayItem(tray_user); | 202 AddTrayItem(tray_user); |
200 AddTrayItem(tray_power); | 203 AddTrayItem(tray_power); |
201 AddTrayItem(tray_network); | 204 AddTrayItem(tray_network); |
202 AddTrayItem(tray_bluetooth); | 205 AddTrayItem(tray_bluetooth); |
203 AddTrayItem(tray_sms); | 206 AddTrayItem(tray_sms); |
204 AddTrayItem(tray_drive); | 207 AddTrayItem(tray_drive); |
205 AddTrayItem(tray_ime); | 208 AddTrayItem(tray_ime); |
206 AddTrayItem(tray_locale); | 209 AddTrayItem(tray_locale); |
207 AddTrayItem(tray_volume); | 210 AddTrayItem(tray_volume); |
208 AddTrayItem(tray_brightness); | 211 AddTrayItem(tray_brightness); |
209 AddTrayItem(tray_update); | 212 AddTrayItem(tray_update); |
210 AddTrayItem(tray_accessibility); | 213 AddTrayItem(tray_accessibility); |
211 AddTrayItem(tray_caps_lock); | 214 AddTrayItem(tray_caps_lock); |
212 AddTrayItem(new internal::TraySettings()); | 215 AddTrayItem(tray_settings); |
213 AddTrayItem(tray_date); | 216 AddTrayItem(tray_date); |
214 SetVisible(ash::Shell::GetInstance()->tray_delegate()-> | 217 SetVisible(ash::Shell::GetInstance()->tray_delegate()-> |
215 GetTrayVisibilityOnStartup()); | 218 GetTrayVisibilityOnStartup()); |
216 } | 219 } |
217 | 220 |
218 void SystemTray::AddTrayItem(SystemTrayItem* item) { | 221 void SystemTray::AddTrayItem(SystemTrayItem* item) { |
219 items_.push_back(item); | 222 items_.push_back(item); |
220 | 223 |
221 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 224 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
222 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); | 225 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 } | 294 } |
292 | 295 |
293 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 296 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
294 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); | 297 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); |
295 it != items_.end(); | 298 it != items_.end(); |
296 ++it) { | 299 ++it) { |
297 (*it)->UpdateAfterShelfAlignmentChange(alignment); | 300 (*it)->UpdateAfterShelfAlignmentChange(alignment); |
298 } | 301 } |
299 } | 302 } |
300 | 303 |
304 void SystemTray::NotifyPowerStatusChange(const PowerSupplyStatus& power_status) | |
305 { | |
stevenjb
2012/06/07 01:31:18
nit: Put arg + { on second line
jennyz
2012/06/07 22:06:52
Done.
| |
306 for (std::vector<PowerStatusObserver*>::iterator it = | |
307 power_status_observers_.begin(); | |
308 it != power_status_observers_.end(); | |
309 ++it) { | |
310 (*it)->OnPowerStatusChanged(power_status); | |
311 } | |
312 } | |
313 | |
301 bool SystemTray::CloseBubbleForTest() const { | 314 bool SystemTray::CloseBubbleForTest() const { |
302 if (!bubble_.get()) | 315 if (!bubble_.get()) |
303 return false; | 316 return false; |
304 bubble_->Close(); | 317 bubble_->Close(); |
305 return true; | 318 return true; |
306 } | 319 } |
307 | 320 |
308 // Private methods. | 321 // Private methods. |
309 | 322 |
310 void SystemTray::DestroyBubble() { | 323 void SystemTray::DestroyBubble() { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 | 562 |
550 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { | 563 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { |
551 // The tray itself expands to the right and bottom edge of the screen to make | 564 // The tray itself expands to the right and bottom edge of the screen to make |
552 // sure clicking on the edges brings up the popup. However, the focus border | 565 // sure clicking on the edges brings up the popup. However, the focus border |
553 // should be only around the container. | 566 // should be only around the container. |
554 if (GetWidget() && GetWidget()->IsActive()) | 567 if (GetWidget() && GetWidget()->IsActive()) |
555 canvas->DrawFocusRect(tray_container_->bounds()); | 568 canvas->DrawFocusRect(tray_container_->bounds()); |
556 } | 569 } |
557 | 570 |
558 } // namespace ash | 571 } // namespace ash |
OLD | NEW |