| 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 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ash/common/devtools/ash_devtools_css_agent.h" | 22 #include "ash/common/devtools/ash_devtools_css_agent.h" |
| 23 #include "ash/common/devtools/ash_devtools_dom_agent.h" | 23 #include "ash/common/devtools/ash_devtools_dom_agent.h" |
| 24 #include "ash/common/focus_cycler.h" | 24 #include "ash/common/focus_cycler.h" |
| 25 #include "ash/common/frame/custom_frame_view_ash.h" | 25 #include "ash/common/frame/custom_frame_view_ash.h" |
| 26 #include "ash/common/gpu_support.h" | 26 #include "ash/common/gpu_support.h" |
| 27 #include "ash/common/keyboard/keyboard_ui.h" | 27 #include "ash/common/keyboard/keyboard_ui.h" |
| 28 #include "ash/common/login_status.h" | 28 #include "ash/common/login_status.h" |
| 29 #include "ash/common/media_controller.h" | 29 #include "ash/common/media_controller.h" |
| 30 #include "ash/common/new_window_controller.h" | 30 #include "ash/common/new_window_controller.h" |
| 31 #include "ash/common/palette_delegate.h" | 31 #include "ash/common/palette_delegate.h" |
| 32 #include "ash/common/session/session_controller.h" |
| 32 #include "ash/common/session/session_state_delegate.h" | 33 #include "ash/common/session/session_state_delegate.h" |
| 34 #include "ash/common/shelf/shelf_controller.h" |
| 35 #include "ash/common/shelf/shelf_delegate.h" |
| 36 #include "ash/common/shelf/shelf_model.h" |
| 37 #include "ash/common/shelf/shelf_window_watcher.h" |
| 33 #include "ash/common/shelf/wm_shelf.h" | 38 #include "ash/common/shelf/wm_shelf.h" |
| 34 #include "ash/common/shell_delegate.h" | 39 #include "ash/common/shell_delegate.h" |
| 35 #include "ash/common/shell_observer.h" | 40 #include "ash/common/shell_observer.h" |
| 36 #include "ash/common/system/brightness_control_delegate.h" | 41 #include "ash/common/system/brightness_control_delegate.h" |
| 37 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_controller
.h" | 42 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_controller
.h" |
| 38 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" | 43 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" |
| 39 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" | 44 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" |
| 40 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" | 45 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" |
| 41 #include "ash/common/system/chromeos/network/sms_observer.h" | 46 #include "ash/common/system/chromeos/network/sms_observer.h" |
| 42 #include "ash/common/system/chromeos/power/power_status.h" | 47 #include "ash/common/system/chromeos/power/power_status.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 keyboard::KeyboardController::ResetInstance(nullptr); | 369 keyboard::KeyboardController::ResetInstance(nullptr); |
| 365 } | 370 } |
| 366 | 371 |
| 367 bool Shell::ShouldSaveDisplaySettings() { | 372 bool Shell::ShouldSaveDisplaySettings() { |
| 368 DCHECK(!wm_shell_->IsRunningInMash()); | 373 DCHECK(!wm_shell_->IsRunningInMash()); |
| 369 return !( | 374 return !( |
| 370 screen_orientation_controller_->ignore_display_configuration_updates() || | 375 screen_orientation_controller_->ignore_display_configuration_updates() || |
| 371 resolution_notification_controller_->DoesNotificationTimeout()); | 376 resolution_notification_controller_->DoesNotificationTimeout()); |
| 372 } | 377 } |
| 373 | 378 |
| 379 ShelfModel* Shell::shelf_model() { |
| 380 return shelf_controller_->model(); |
| 381 } |
| 382 |
| 374 aura::client::ActivationClient* Shell::activation_client() { | 383 aura::client::ActivationClient* Shell::activation_client() { |
| 375 return focus_controller_.get(); | 384 return focus_controller_.get(); |
| 376 } | 385 } |
| 377 | 386 |
| 378 void Shell::UpdateShelfVisibility() { | 387 void Shell::UpdateShelfVisibility() { |
| 379 for (WmWindow* root : wm_shell_->GetAllRootWindows()) | 388 for (WmWindow* root : wm_shell_->GetAllRootWindows()) |
| 380 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); | 389 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); |
| 381 } | 390 } |
| 382 | 391 |
| 383 WebNotificationTray* Shell::GetWebNotificationTray() { | 392 WebNotificationTray* Shell::GetWebNotificationTray() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 400 | 409 |
| 401 is_touch_hud_projection_enabled_ = enabled; | 410 is_touch_hud_projection_enabled_ = enabled; |
| 402 for (auto& observer : shell_observers_) | 411 for (auto& observer : shell_observers_) |
| 403 observer.OnTouchHudProjectionToggled(enabled); | 412 observer.OnTouchHudProjectionToggled(enabled); |
| 404 } | 413 } |
| 405 | 414 |
| 406 FirstRunHelper* Shell::CreateFirstRunHelper() { | 415 FirstRunHelper* Shell::CreateFirstRunHelper() { |
| 407 return new FirstRunHelperImpl; | 416 return new FirstRunHelperImpl; |
| 408 } | 417 } |
| 409 | 418 |
| 419 void Shell::CreateShelfView() { |
| 420 // Must occur after SessionController creation and user login. |
| 421 DCHECK(session_controller()); |
| 422 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); |
| 423 CreateShelfDelegate(); |
| 424 |
| 425 for (WmWindow* root_window : wm_shell_->GetAllRootWindows()) |
| 426 root_window->GetRootWindowController()->CreateShelfView(); |
| 427 } |
| 428 |
| 410 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { | 429 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { |
| 411 window_tree_host_manager_->cursor_window_controller() | 430 window_tree_host_manager_->cursor_window_controller() |
| 412 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); | 431 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); |
| 413 } | 432 } |
| 414 | 433 |
| 415 void Shell::SetCursorCompositingEnabled(bool enabled) { | 434 void Shell::SetCursorCompositingEnabled(bool enabled) { |
| 416 window_tree_host_manager_->cursor_window_controller() | 435 window_tree_host_manager_->cursor_window_controller() |
| 417 ->SetCursorCompositingEnabled(enabled); | 436 ->SetCursorCompositingEnabled(enabled); |
| 418 native_cursor_manager_->SetNativeCursorEnabled(!enabled); | 437 native_cursor_manager_->SetNativeCursorEnabled(!enabled); |
| 419 } | 438 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 449 } | 468 } |
| 450 | 469 |
| 451 bool Shell::IsAppListVisible() const { | 470 bool Shell::IsAppListVisible() const { |
| 452 return app_list_->IsVisible(); | 471 return app_list_->IsVisible(); |
| 453 } | 472 } |
| 454 | 473 |
| 455 bool Shell::GetAppListTargetVisibility() const { | 474 bool Shell::GetAppListTargetVisibility() const { |
| 456 return app_list_->GetTargetVisibility(); | 475 return app_list_->GetTargetVisibility(); |
| 457 } | 476 } |
| 458 | 477 |
| 478 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { |
| 479 for (WmWindow* root_window : wm_shell_->GetAllRootWindows()) { |
| 480 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( |
| 481 status); |
| 482 } |
| 483 } |
| 484 |
| 459 void Shell::NotifyMaximizeModeStarted() { | 485 void Shell::NotifyMaximizeModeStarted() { |
| 460 for (auto& observer : shell_observers_) | 486 for (auto& observer : shell_observers_) |
| 461 observer.OnMaximizeModeStarted(); | 487 observer.OnMaximizeModeStarted(); |
| 462 } | 488 } |
| 463 | 489 |
| 464 void Shell::NotifyMaximizeModeEnding() { | 490 void Shell::NotifyMaximizeModeEnding() { |
| 465 for (auto& observer : shell_observers_) | 491 for (auto& observer : shell_observers_) |
| 466 observer.OnMaximizeModeEnding(); | 492 observer.OnMaximizeModeEnding(); |
| 467 } | 493 } |
| 468 | 494 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 base::MakeUnique<system::BrightnessControllerChromeos>()), | 549 base::MakeUnique<system::BrightnessControllerChromeos>()), |
| 524 cast_config_(base::MakeUnique<CastConfigController>()), | 550 cast_config_(base::MakeUnique<CastConfigController>()), |
| 525 focus_cycler_(base::MakeUnique<FocusCycler>()), | 551 focus_cycler_(base::MakeUnique<FocusCycler>()), |
| 526 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), | 552 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), |
| 527 keyboard_brightness_control_delegate_( | 553 keyboard_brightness_control_delegate_( |
| 528 base::MakeUnique<KeyboardBrightnessController>()), | 554 base::MakeUnique<KeyboardBrightnessController>()), |
| 529 locale_notification_controller_( | 555 locale_notification_controller_( |
| 530 base::MakeUnique<LocaleNotificationController>()), | 556 base::MakeUnique<LocaleNotificationController>()), |
| 531 media_controller_(base::MakeUnique<MediaController>()), | 557 media_controller_(base::MakeUnique<MediaController>()), |
| 532 new_window_controller_(base::MakeUnique<NewWindowController>()), | 558 new_window_controller_(base::MakeUnique<NewWindowController>()), |
| 559 session_controller_(base::MakeUnique<SessionController>()), |
| 560 shelf_controller_(base::MakeUnique<ShelfController>()), |
| 533 shell_delegate_(std::move(shell_delegate)), | 561 shell_delegate_(std::move(shell_delegate)), |
| 534 system_tray_controller_(base::MakeUnique<SystemTrayController>()), | 562 system_tray_controller_(base::MakeUnique<SystemTrayController>()), |
| 535 app_list_(base::MakeUnique<app_list::AppList>()), | 563 app_list_(base::MakeUnique<app_list::AppList>()), |
| 536 link_handler_model_factory_(nullptr), | 564 link_handler_model_factory_(nullptr), |
| 537 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), | 565 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), |
| 538 display_configurator_(new display::DisplayConfigurator()), | 566 display_configurator_(new display::DisplayConfigurator()), |
| 539 native_cursor_manager_(nullptr), | 567 native_cursor_manager_(nullptr), |
| 540 simulate_modal_window_open_for_testing_(false), | 568 simulate_modal_window_open_for_testing_(false), |
| 541 is_touch_hud_projection_enabled_(false) { | 569 is_touch_hud_projection_enabled_(false) { |
| 542 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 570 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
| 543 // state on WmShellAura. http://crbug.com/671246. | 571 // state on WmShellAura. http://crbug.com/671246. |
| 544 | 572 |
| 545 if (!wm_shell_->IsRunningInMash()) { | 573 if (!wm_shell_->IsRunningInMash()) { |
| 546 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | 574 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); |
| 547 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 575 display_manager_.reset(ScreenAsh::CreateDisplayManager()); |
| 548 window_tree_host_manager_.reset(new WindowTreeHostManager); | 576 window_tree_host_manager_.reset(new WindowTreeHostManager); |
| 549 user_metrics_recorder_.reset(new UserMetricsRecorder); | 577 user_metrics_recorder_.reset(new UserMetricsRecorder); |
| 550 } | 578 } |
| 551 | 579 |
| 552 PowerStatus::Initialize(); | 580 PowerStatus::Initialize(); |
| 581 |
| 582 session_controller_->AddSessionStateObserver(this); |
| 553 } | 583 } |
| 554 | 584 |
| 555 Shell::~Shell() { | 585 Shell::~Shell() { |
| 556 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); | 586 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); |
| 557 | 587 |
| 558 const bool is_mash = wm_shell_->IsRunningInMash(); | 588 const bool is_mash = wm_shell_->IsRunningInMash(); |
| 559 | 589 |
| 560 if (!is_mash) | 590 if (!is_mash) |
| 561 user_metrics_recorder_->OnShellShuttingDown(); | 591 user_metrics_recorder_->OnShellShuttingDown(); |
| 562 | 592 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // AppListDelegateImpl depends upon AppList. | 711 // AppListDelegateImpl depends upon AppList. |
| 682 app_list_delegate_impl_.reset(); | 712 app_list_delegate_impl_.reset(); |
| 683 | 713 |
| 684 // These members access Shell in their destructors. | 714 // These members access Shell in their destructors. |
| 685 wallpaper_controller_.reset(); | 715 wallpaper_controller_.reset(); |
| 686 accessibility_delegate_.reset(); | 716 accessibility_delegate_.reset(); |
| 687 | 717 |
| 688 // Balances the Install() in Initialize(). | 718 // Balances the Install() in Initialize(). |
| 689 views::FocusManagerFactory::Install(nullptr); | 719 views::FocusManagerFactory::Install(nullptr); |
| 690 | 720 |
| 721 // ShelfWindowWatcher has window observers and a pointer to the shelf model. |
| 722 shelf_window_watcher_.reset(); |
| 723 |
| 724 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC |
| 725 // shelf items in Chrome) so explicitly shutdown early. |
| 726 shelf_model()->DestroyItemDelegates(); |
| 727 |
| 728 // Must be destroyed before FocusController. |
| 729 shelf_delegate_.reset(); |
| 730 |
| 731 // Removes itself as an observer of |pref_store_|. |
| 732 shelf_controller_.reset(); |
| 733 |
| 691 wm_shell_->Shutdown(); | 734 wm_shell_->Shutdown(); |
| 735 |
| 692 // Depends on |focus_controller_|, so must be destroyed before. | 736 // Depends on |focus_controller_|, so must be destroyed before. |
| 693 window_tree_host_manager_.reset(); | 737 window_tree_host_manager_.reset(); |
| 694 focus_controller_->RemoveObserver(this); | 738 focus_controller_->RemoveObserver(this); |
| 695 focus_controller_.reset(); | 739 focus_controller_.reset(); |
| 696 screen_position_controller_.reset(); | 740 screen_position_controller_.reset(); |
| 697 | 741 |
| 698 display_color_manager_.reset(); | 742 display_color_manager_.reset(); |
| 699 if (display_change_observer_) | 743 if (display_change_observer_) |
| 700 display_configurator_->RemoveObserver(display_change_observer_.get()); | 744 display_configurator_->RemoveObserver(display_change_observer_.get()); |
| 701 if (display_error_observer_) | 745 if (display_error_observer_) |
| 702 display_configurator_->RemoveObserver(display_error_observer_.get()); | 746 display_configurator_->RemoveObserver(display_error_observer_.get()); |
| 703 if (projecting_observer_) { | 747 if (projecting_observer_) { |
| 704 display_configurator_->RemoveObserver(projecting_observer_.get()); | 748 display_configurator_->RemoveObserver(projecting_observer_.get()); |
| 705 RemoveShellObserver(projecting_observer_.get()); | 749 RemoveShellObserver(projecting_observer_.get()); |
| 706 } | 750 } |
| 707 display_change_observer_.reset(); | 751 display_change_observer_.reset(); |
| 708 shutdown_observer_.reset(); | 752 shutdown_observer_.reset(); |
| 709 | 753 |
| 710 PowerStatus::Shutdown(); | 754 PowerStatus::Shutdown(); |
| 711 | 755 |
| 712 // Ensure that DBusThreadManager outlives this Shell. | 756 // Ensure that DBusThreadManager outlives this Shell. |
| 713 DCHECK(chromeos::DBusThreadManager::IsInitialized()); | 757 DCHECK(chromeos::DBusThreadManager::IsInitialized()); |
| 714 | 758 |
| 715 // Needs to happen right before |instance_| is reset. | 759 // Needs to happen right before |instance_| is reset. |
| 716 wm_shell_.reset(); | 760 wm_shell_.reset(); |
| 761 session_controller_->RemoveSessionStateObserver(this); |
| 717 wallpaper_delegate_.reset(); | 762 wallpaper_delegate_.reset(); |
| 718 pref_store_ = nullptr; | 763 pref_store_ = nullptr; |
| 719 shell_delegate_.reset(); | 764 shell_delegate_.reset(); |
| 720 | 765 |
| 721 DCHECK(instance_ == this); | 766 DCHECK(instance_ == this); |
| 722 instance_ = nullptr; | 767 instance_ = nullptr; |
| 723 } | 768 } |
| 724 | 769 |
| 725 void Shell::Init(const ShellInitParams& init_params) { | 770 void Shell::Init(const ShellInitParams& init_params) { |
| 726 const bool is_mash = wm_shell_->IsRunningInMash(); | 771 const bool is_mash = wm_shell_->IsRunningInMash(); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 controller->CloseChildWindows(); | 1148 controller->CloseChildWindows(); |
| 1104 } else { | 1149 } else { |
| 1105 while (!root_window->children().empty()) { | 1150 while (!root_window->children().empty()) { |
| 1106 aura::Window* child = root_window->children()[0]; | 1151 aura::Window* child = root_window->children()[0]; |
| 1107 delete child; | 1152 delete child; |
| 1108 } | 1153 } |
| 1109 } | 1154 } |
| 1110 } | 1155 } |
| 1111 } | 1156 } |
| 1112 | 1157 |
| 1158 void Shell::CreateShelfDelegate() { |
| 1159 // May be called multiple times as shelves are created and destroyed. |
| 1160 if (shelf_delegate_) |
| 1161 return; |
| 1162 // Must occur after SessionController creation and user login because |
| 1163 // Chrome's implementation of ShelfDelegate assumes it can get information |
| 1164 // about multi-profile login state. |
| 1165 DCHECK(session_controller()); |
| 1166 DCHECK_GT(session_controller()->NumberOfLoggedInUsers(), 0); |
| 1167 shelf_delegate_.reset(shell_delegate_->CreateShelfDelegate(shelf_model())); |
| 1168 shelf_window_watcher_ = base::MakeUnique<ShelfWindowWatcher>(shelf_model()); |
| 1169 } |
| 1170 |
| 1113 bool Shell::CanWindowReceiveEvents(aura::Window* window) { | 1171 bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 1114 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 1172 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 1115 for (RootWindowController* controller : controllers) { | 1173 for (RootWindowController* controller : controllers) { |
| 1116 if (controller->CanWindowReceiveEvents(window)) | 1174 if (controller->CanWindowReceiveEvents(window)) |
| 1117 return true; | 1175 return true; |
| 1118 } | 1176 } |
| 1119 return false; | 1177 return false; |
| 1120 } | 1178 } |
| 1121 | 1179 |
| 1122 //////////////////////////////////////////////////////////////////////////////// | 1180 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1141 | 1199 |
| 1142 void Shell::OnWindowActivated( | 1200 void Shell::OnWindowActivated( |
| 1143 aura::client::ActivationChangeObserver::ActivationReason reason, | 1201 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 1144 aura::Window* gained_active, | 1202 aura::Window* gained_active, |
| 1145 aura::Window* lost_active) { | 1203 aura::Window* lost_active) { |
| 1146 WmWindow* gained_active_wm = WmWindow::Get(gained_active); | 1204 WmWindow* gained_active_wm = WmWindow::Get(gained_active); |
| 1147 if (gained_active_wm) | 1205 if (gained_active_wm) |
| 1148 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); | 1206 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); |
| 1149 } | 1207 } |
| 1150 | 1208 |
| 1209 void Shell::SessionStateChanged(session_manager::SessionState state) { |
| 1210 // Create the shelf when a session becomes active. It's safe to do this |
| 1211 // multiple times (e.g. initial login vs. multiprofile add session). |
| 1212 if (state == session_manager::SessionState::ACTIVE) { |
| 1213 CreateShelfView(); |
| 1214 |
| 1215 if (!wm_shell_->IsRunningInMash()) { |
| 1216 // Recreate the keyboard after initial login and after multiprofile login. |
| 1217 CreateKeyboard(); |
| 1218 } |
| 1219 } |
| 1220 |
| 1221 // Only trigger an update in mash because with classic ash chrome calls |
| 1222 // UpdateAfterLoginStatusChange() directly. |
| 1223 if (wm_shell_->IsRunningInMash()) { |
| 1224 // TODO(jamescook): Should this call Shell::OnLoginStatusChanged() too? |
| 1225 UpdateAfterLoginStatusChange(session_controller_->GetLoginStatus()); |
| 1226 } |
| 1227 } |
| 1228 |
| 1151 } // namespace ash | 1229 } // namespace ash |
| OLD | NEW |