| 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/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/app_list/app_list.h" | 9 #include "ash/app_list/app_list.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/desktop_background/desktop_background_controller.h" | 11 #include "ash/desktop_background/desktop_background_controller.h" |
| 12 #include "ash/desktop_background/desktop_background_resources.h" | 12 #include "ash/desktop_background/desktop_background_resources.h" |
| 13 #include "ash/desktop_background/desktop_background_view.h" | 13 #include "ash/desktop_background/desktop_background_view.h" |
| 14 #include "ash/drag_drop/drag_drop_controller.h" | 14 #include "ash/drag_drop/drag_drop_controller.h" |
| 15 #include "ash/focus_cycler.h" | 15 #include "ash/focus_cycler.h" |
| 16 #include "ash/ime/input_method_event_filter.h" | 16 #include "ash/ime/input_method_event_filter.h" |
| 17 #include "ash/launcher/launcher.h" | 17 #include "ash/launcher/launcher.h" |
| 18 #include "ash/monitor/multi_monitor_manager.h" | 18 #include "ash/monitor/multi_monitor_manager.h" |
| 19 #include "ash/monitor/monitor_controller.h" | 19 #include "ash/monitor/monitor_controller.h" |
| 20 #include "ash/screen_ash.h" | 20 #include "ash/screen_ash.h" |
| 21 #include "ash/shell_delegate.h" | 21 #include "ash/shell_delegate.h" |
| 22 #include "ash/shell_factory.h" | 22 #include "ash/shell_factory.h" |
| 23 #include "ash/shell_window_ids.h" | 23 #include "ash/shell_window_ids.h" |
| 24 #include "ash/system/audio/tray_volume.h" | 24 #include "ash/system/audio/tray_volume.h" |
| 25 #include "ash/system/bluetooth/tray_bluetooth.h" |
| 25 #include "ash/system/brightness/tray_brightness.h" | 26 #include "ash/system/brightness/tray_brightness.h" |
| 26 #include "ash/system/ime/tray_ime.h" | 27 #include "ash/system/ime/tray_ime.h" |
| 27 #include "ash/system/network/tray_network.h" | 28 #include "ash/system/network/tray_network.h" |
| 28 #include "ash/system/power/power_status_observer.h" | 29 #include "ash/system/power/power_status_observer.h" |
| 29 #include "ash/system/power/power_supply_status.h" | 30 #include "ash/system/power/power_supply_status.h" |
| 30 #include "ash/system/power/tray_power_date.h" | 31 #include "ash/system/power/tray_power_date.h" |
| 31 #include "ash/system/settings/tray_settings.h" | 32 #include "ash/system/settings/tray_settings.h" |
| 32 #include "ash/system/tray/system_tray_delegate.h" | 33 #include "ash/system/tray/system_tray_delegate.h" |
| 33 #include "ash/system/tray/system_tray.h" | 34 #include "ash/system/tray/system_tray.h" |
| 34 #include "ash/system/tray/tray_empty.h" | 35 #include "ash/system/tray/tray_empty.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 "OverlayContainer", | 227 "OverlayContainer", |
| 227 lock_screen_related_containers); | 228 lock_screen_related_containers); |
| 228 } | 229 } |
| 229 | 230 |
| 230 class DummySystemTrayDelegate : public SystemTrayDelegate { | 231 class DummySystemTrayDelegate : public SystemTrayDelegate { |
| 231 public: | 232 public: |
| 232 DummySystemTrayDelegate() | 233 DummySystemTrayDelegate() |
| 233 : muted_(false), | 234 : muted_(false), |
| 234 wifi_enabled_(true), | 235 wifi_enabled_(true), |
| 235 cellular_enabled_(true), | 236 cellular_enabled_(true), |
| 237 bluetooth_enabled_(true), |
| 236 volume_(0.5) { | 238 volume_(0.5) { |
| 237 } | 239 } |
| 238 | 240 |
| 239 virtual ~DummySystemTrayDelegate() {} | 241 virtual ~DummySystemTrayDelegate() {} |
| 240 | 242 |
| 241 private: | 243 private: |
| 242 | 244 |
| 243 // Overridden from SystemTrayDelegate: | 245 // Overridden from SystemTrayDelegate: |
| 244 virtual const std::string GetUserDisplayName() const OVERRIDE { | 246 virtual const std::string GetUserDisplayName() const OVERRIDE { |
| 245 return "Über tray Über tray Über tray Über tray"; | 247 return "Über tray Über tray Über tray Über tray"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 275 | 277 |
| 276 virtual void ShowSettings() OVERRIDE { | 278 virtual void ShowSettings() OVERRIDE { |
| 277 } | 279 } |
| 278 | 280 |
| 279 virtual void ShowDateSettings() OVERRIDE { | 281 virtual void ShowDateSettings() OVERRIDE { |
| 280 } | 282 } |
| 281 | 283 |
| 282 virtual void ShowNetworkSettings() OVERRIDE { | 284 virtual void ShowNetworkSettings() OVERRIDE { |
| 283 } | 285 } |
| 284 | 286 |
| 287 virtual void ShowBluetoothSettings() OVERRIDE { |
| 288 } |
| 289 |
| 285 virtual void ShowHelp() OVERRIDE { | 290 virtual void ShowHelp() OVERRIDE { |
| 286 } | 291 } |
| 287 | 292 |
| 288 virtual bool IsAudioMuted() const OVERRIDE { | 293 virtual bool IsAudioMuted() const OVERRIDE { |
| 289 return muted_; | 294 return muted_; |
| 290 } | 295 } |
| 291 | 296 |
| 292 virtual void SetAudioMuted(bool muted) OVERRIDE { | 297 virtual void SetAudioMuted(bool muted) OVERRIDE { |
| 293 muted_ = muted; | 298 muted_ = muted; |
| 294 } | 299 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 310 } | 315 } |
| 311 | 316 |
| 312 virtual void ShutDown() OVERRIDE {} | 317 virtual void ShutDown() OVERRIDE {} |
| 313 | 318 |
| 314 virtual void SignOut() OVERRIDE { | 319 virtual void SignOut() OVERRIDE { |
| 315 MessageLoop::current()->Quit(); | 320 MessageLoop::current()->Quit(); |
| 316 } | 321 } |
| 317 | 322 |
| 318 virtual void RequestLockScreen() OVERRIDE {} | 323 virtual void RequestLockScreen() OVERRIDE {} |
| 319 | 324 |
| 320 virtual IMEInfoList GetAvailableIMEList() { | 325 virtual void GetAvailableBluetoothDevices( |
| 321 return IMEInfoList(); | 326 BluetoothDeviceList* list) OVERRIDE { |
| 327 } |
| 328 |
| 329 virtual void GetAvailableIMEList(IMEInfoList* list) { |
| 322 } | 330 } |
| 323 | 331 |
| 324 virtual NetworkIconInfo GetMostRelevantNetworkIcon(bool large) OVERRIDE { | 332 virtual NetworkIconInfo GetMostRelevantNetworkIcon(bool large) OVERRIDE { |
| 325 return NetworkIconInfo(); | 333 return NetworkIconInfo(); |
| 326 } | 334 } |
| 327 | 335 |
| 328 virtual void GetAvailableNetworks( | 336 virtual void GetAvailableNetworks( |
| 329 std::vector<NetworkIconInfo>* list) OVERRIDE { | 337 std::vector<NetworkIconInfo>* list) OVERRIDE { |
| 330 } | 338 } |
| 331 | 339 |
| 332 virtual void ConnectToNetwork(const std::string& network_id) OVERRIDE { | 340 virtual void ConnectToNetwork(const std::string& network_id) OVERRIDE { |
| 333 } | 341 } |
| 334 | 342 |
| 343 virtual void AddBluetoothDevice() OVERRIDE { |
| 344 } |
| 345 |
| 335 virtual void ToggleAirplaneMode() OVERRIDE { | 346 virtual void ToggleAirplaneMode() OVERRIDE { |
| 336 } | 347 } |
| 337 | 348 |
| 338 virtual void ToggleWifi() OVERRIDE { | 349 virtual void ToggleWifi() OVERRIDE { |
| 339 wifi_enabled_ = !wifi_enabled_; | 350 wifi_enabled_ = !wifi_enabled_; |
| 340 ash::NetworkObserver* observer = | 351 ash::NetworkObserver* observer = |
| 341 ash::Shell::GetInstance()->tray()->network_observer(); | 352 ash::Shell::GetInstance()->tray()->network_observer(); |
| 342 if (observer) { | 353 if (observer) { |
| 343 ash::NetworkIconInfo info; | 354 ash::NetworkIconInfo info; |
| 344 observer->OnNetworkRefresh(info); | 355 observer->OnNetworkRefresh(info); |
| 345 } | 356 } |
| 346 } | 357 } |
| 347 | 358 |
| 348 virtual void ToggleCellular() OVERRIDE { | 359 virtual void ToggleCellular() OVERRIDE { |
| 349 cellular_enabled_ = !cellular_enabled_; | 360 cellular_enabled_ = !cellular_enabled_; |
| 350 ash::NetworkObserver* observer = | 361 ash::NetworkObserver* observer = |
| 351 ash::Shell::GetInstance()->tray()->network_observer(); | 362 ash::Shell::GetInstance()->tray()->network_observer(); |
| 352 if (observer) { | 363 if (observer) { |
| 353 ash::NetworkIconInfo info; | 364 ash::NetworkIconInfo info; |
| 354 observer->OnNetworkRefresh(info); | 365 observer->OnNetworkRefresh(info); |
| 355 } | 366 } |
| 356 } | 367 } |
| 357 | 368 |
| 369 virtual void ToggleBluetooth() OVERRIDE { |
| 370 bluetooth_enabled_ = !bluetooth_enabled_; |
| 371 ash::BluetoothObserver* observer = |
| 372 ash::Shell::GetInstance()->tray()->bluetooth_observer(); |
| 373 if (observer) |
| 374 observer->OnBluetoothRefresh(); |
| 375 } |
| 376 |
| 358 virtual bool GetWifiAvailable() OVERRIDE { | 377 virtual bool GetWifiAvailable() OVERRIDE { |
| 359 return true; | 378 return true; |
| 360 } | 379 } |
| 361 | 380 |
| 362 virtual bool GetCellularAvailable() OVERRIDE { | 381 virtual bool GetCellularAvailable() OVERRIDE { |
| 363 return true; | 382 return true; |
| 364 } | 383 } |
| 365 | 384 |
| 385 virtual bool GetBluetoothAvailable() OVERRIDE { |
| 386 return true; |
| 387 } |
| 388 |
| 366 virtual bool GetWifiEnabled() OVERRIDE { | 389 virtual bool GetWifiEnabled() OVERRIDE { |
| 367 return wifi_enabled_; | 390 return wifi_enabled_; |
| 368 } | 391 } |
| 369 | 392 |
| 370 virtual bool GetCellularEnabled() OVERRIDE { | 393 virtual bool GetCellularEnabled() OVERRIDE { |
| 371 return cellular_enabled_; | 394 return cellular_enabled_; |
| 372 } | 395 } |
| 373 | 396 |
| 397 virtual bool GetBluetoothEnabled() OVERRIDE { |
| 398 return bluetooth_enabled_; |
| 399 } |
| 400 |
| 374 virtual void ChangeProxySettings() OVERRIDE { | 401 virtual void ChangeProxySettings() OVERRIDE { |
| 375 } | 402 } |
| 376 | 403 |
| 377 bool muted_; | 404 bool muted_; |
| 378 bool wifi_enabled_; | 405 bool wifi_enabled_; |
| 379 bool cellular_enabled_; | 406 bool cellular_enabled_; |
| 407 bool bluetooth_enabled_; |
| 380 float volume_; | 408 float volume_; |
| 381 SkBitmap null_image_; | 409 SkBitmap null_image_; |
| 382 | 410 |
| 383 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); | 411 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); |
| 384 }; | 412 }; |
| 385 | 413 |
| 386 } // namespace | 414 } // namespace |
| 387 | 415 |
| 388 // static | 416 // static |
| 389 Shell* Shell::instance_ = NULL; | 417 Shell* Shell::instance_ = NULL; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 status_widget_->GetContentsView()->RemoveAllChildViews(false); | 589 status_widget_->GetContentsView()->RemoveAllChildViews(false); |
| 562 status_widget_->GetContentsView()->AddChildView(tray_.get()); | 590 status_widget_->GetContentsView()->AddChildView(tray_.get()); |
| 563 } | 591 } |
| 564 | 592 |
| 565 if (delegate_.get()) | 593 if (delegate_.get()) |
| 566 tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); | 594 tray_delegate_.reset(delegate_->CreateSystemTrayDelegate(tray_.get())); |
| 567 if (!tray_delegate_.get()) | 595 if (!tray_delegate_.get()) |
| 568 tray_delegate_.reset(new DummySystemTrayDelegate()); | 596 tray_delegate_.reset(new DummySystemTrayDelegate()); |
| 569 | 597 |
| 570 internal::TrayVolume* tray_volume = new internal::TrayVolume(); | 598 internal::TrayVolume* tray_volume = new internal::TrayVolume(); |
| 599 internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth(); |
| 571 internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); | 600 internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); |
| 572 internal::TrayPowerDate* tray_power_date = new internal::TrayPowerDate(); | 601 internal::TrayPowerDate* tray_power_date = new internal::TrayPowerDate(); |
| 573 internal::TrayNetwork* tray_network = new internal::TrayNetwork; | 602 internal::TrayNetwork* tray_network = new internal::TrayNetwork; |
| 574 internal::TrayUser* tray_user = new internal::TrayUser; | 603 internal::TrayUser* tray_user = new internal::TrayUser; |
| 575 internal::TrayAccessibility* tray_accessibility = | 604 internal::TrayAccessibility* tray_accessibility = |
| 576 new internal::TrayAccessibility; | 605 new internal::TrayAccessibility; |
| 577 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; | 606 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; |
| 578 internal::TrayIME* tray_ime = new internal::TrayIME; | 607 internal::TrayIME* tray_ime = new internal::TrayIME; |
| 579 | 608 |
| 580 tray_->accessibility_observer_ = tray_accessibility; | 609 tray_->accessibility_observer_ = tray_accessibility; |
| 581 tray_->audio_observer_ = tray_volume; | 610 tray_->audio_observer_ = tray_volume; |
| 611 tray_->bluetooth_observer_ = tray_bluetooth; |
| 582 tray_->brightness_observer_ = tray_brightness; | 612 tray_->brightness_observer_ = tray_brightness; |
| 583 tray_->caps_lock_observer_ = tray_caps_lock; | 613 tray_->caps_lock_observer_ = tray_caps_lock; |
| 584 tray_->clock_observer_ = tray_power_date; | 614 tray_->clock_observer_ = tray_power_date; |
| 585 tray_->ime_observer_ = tray_ime; | 615 tray_->ime_observer_ = tray_ime; |
| 586 tray_->network_observer_ = tray_network; | 616 tray_->network_observer_ = tray_network; |
| 587 tray_->power_status_observer_ = tray_power_date; | 617 tray_->power_status_observer_ = tray_power_date; |
| 588 tray_->update_observer_ = tray_user; | 618 tray_->update_observer_ = tray_user; |
| 589 tray_->user_observer_ = tray_user; | 619 tray_->user_observer_ = tray_user; |
| 590 | 620 |
| 591 tray_->AddTrayItem(tray_user); | 621 tray_->AddTrayItem(tray_user); |
| 592 tray_->AddTrayItem(new internal::TrayEmpty()); | 622 tray_->AddTrayItem(new internal::TrayEmpty()); |
| 593 tray_->AddTrayItem(tray_power_date); | 623 tray_->AddTrayItem(tray_power_date); |
| 594 tray_->AddTrayItem(tray_network); | 624 tray_->AddTrayItem(tray_network); |
| 625 tray_->AddTrayItem(tray_bluetooth); |
| 595 tray_->AddTrayItem(tray_ime); | 626 tray_->AddTrayItem(tray_ime); |
| 596 tray_->AddTrayItem(tray_volume); | 627 tray_->AddTrayItem(tray_volume); |
| 597 tray_->AddTrayItem(tray_brightness); | 628 tray_->AddTrayItem(tray_brightness); |
| 598 tray_->AddTrayItem(new internal::TraySettings()); | 629 tray_->AddTrayItem(new internal::TraySettings()); |
| 599 tray_->AddTrayItem(tray_accessibility); | 630 tray_->AddTrayItem(tray_accessibility); |
| 600 tray_->AddTrayItem(tray_caps_lock); | 631 tray_->AddTrayItem(tray_caps_lock); |
| 601 } | 632 } |
| 602 if (!status_widget_) | 633 if (!status_widget_) |
| 603 status_widget_ = internal::CreateStatusArea(tray_.get()); | 634 status_widget_ = internal::CreateStatusArea(tray_.get()); |
| 604 | 635 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 // Create the desktop background image. | 791 // Create the desktop background image. |
| 761 desktop_background_controller_->SetDefaultDesktopBackgroundImage(); | 792 desktop_background_controller_->SetDefaultDesktopBackgroundImage(); |
| 762 } | 793 } |
| 763 | 794 |
| 764 void Shell::DisableWorkspaceGridLayout() { | 795 void Shell::DisableWorkspaceGridLayout() { |
| 765 if (workspace_controller_.get()) | 796 if (workspace_controller_.get()) |
| 766 workspace_controller_->workspace_manager()->set_grid_size(0); | 797 workspace_controller_->workspace_manager()->set_grid_size(0); |
| 767 } | 798 } |
| 768 | 799 |
| 769 } // namespace ash | 800 } // namespace ash |
| OLD | NEW |