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