Chromium Code Reviews| 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 | 
| 11 #include "ash/accelerators/accelerator_controller.h" | 11 #include "ash/accelerators/accelerator_controller.h" | 
| 12 #include "ash/accelerators/accelerator_delegate.h" | 12 #include "ash/accelerators/accelerator_delegate.h" | 
| 13 #include "ash/accelerators/ash_focus_manager_factory.h" | 13 #include "ash/accelerators/ash_focus_manager_factory.h" | 
| 14 #include "ash/accelerators/magnifier_key_scroller.h" | 14 #include "ash/accelerators/magnifier_key_scroller.h" | 
| 15 #include "ash/accelerators/spoken_feedback_toggler.h" | 15 #include "ash/accelerators/spoken_feedback_toggler.h" | 
| 16 #include "ash/accessibility_delegate.h" | 16 #include "ash/accessibility_delegate.h" | 
| 17 #include "ash/app_list/app_list_delegate_impl.h" | |
| 18 #include "ash/ash_constants.h" | 17 #include "ash/ash_constants.h" | 
| 19 #include "ash/ash_switches.h" | 18 #include "ash/ash_switches.h" | 
| 20 #include "ash/aura/shell_port_classic.h" | 19 #include "ash/aura/shell_port_classic.h" | 
| 21 #include "ash/autoclick/autoclick_controller.h" | 20 #include "ash/autoclick/autoclick_controller.h" | 
| 22 #include "ash/cast_config_controller.h" | 21 #include "ash/cast_config_controller.h" | 
| 23 #include "ash/devtools/ash_devtools_css_agent.h" | 22 #include "ash/devtools/ash_devtools_css_agent.h" | 
| 24 #include "ash/devtools/ash_devtools_dom_agent.h" | 23 #include "ash/devtools/ash_devtools_dom_agent.h" | 
| 25 #include "ash/display/cursor_window_controller.h" | 24 #include "ash/display/cursor_window_controller.h" | 
| 26 #include "ash/display/display_color_manager_chromeos.h" | 25 #include "ash/display/display_color_manager_chromeos.h" | 
| 27 #include "ash/display/display_configuration_controller.h" | 26 #include "ash/display/display_configuration_controller.h" | 
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 return app_list_->GetTargetVisibility(); | 478 return app_list_->GetTargetVisibility(); | 
| 480 } | 479 } | 
| 481 | 480 | 
| 482 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { | 481 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { | 
| 483 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) { | 482 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) { | 
| 484 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( | 483 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( | 
| 485 status); | 484 status); | 
| 486 } | 485 } | 
| 487 } | 486 } | 
| 488 | 487 | 
| 488 void Shell::NotifyAppListVisibilityChanged(bool shown, | |
| 489 aura::Window* root_window) { | |
| 490 for (auto& observer : shell_observers_) | |
| 491 observer.OnAppListVisibilityChanged(shown, root_window); | |
| 492 } | |
| 493 | |
| 489 void Shell::NotifyMaximizeModeStarted() { | 494 void Shell::NotifyMaximizeModeStarted() { | 
| 490 for (auto& observer : shell_observers_) | 495 for (auto& observer : shell_observers_) | 
| 491 observer.OnMaximizeModeStarted(); | 496 observer.OnMaximizeModeStarted(); | 
| 492 } | 497 } | 
| 493 | 498 | 
| 494 void Shell::NotifyMaximizeModeEnding() { | 499 void Shell::NotifyMaximizeModeEnding() { | 
| 495 for (auto& observer : shell_observers_) | 500 for (auto& observer : shell_observers_) | 
| 496 observer.OnMaximizeModeEnding(); | 501 observer.OnMaximizeModeEnding(); | 
| 497 } | 502 } | 
| 498 | 503 | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 // state on ShellPortClassic. http://crbug.com/671246. | 594 // state on ShellPortClassic. http://crbug.com/671246. | 
| 590 | 595 | 
| 591 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | 596 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | 
| 592 | 597 | 
| 593 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. | 598 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. | 
| 594 if (shell_port_->GetAshConfig() != Config::MASH) { | 599 if (shell_port_->GetAshConfig() != Config::MASH) { | 
| 595 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 600 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 
| 596 window_tree_host_manager_.reset(new WindowTreeHostManager); | 601 window_tree_host_manager_.reset(new WindowTreeHostManager); | 
| 597 user_metrics_recorder_.reset(new UserMetricsRecorder); | 602 user_metrics_recorder_.reset(new UserMetricsRecorder); | 
| 598 } | 603 } | 
| 604 app_list()->set_delegate(this); | |
| 599 | 605 | 
| 600 PowerStatus::Initialize(); | 606 PowerStatus::Initialize(); | 
| 601 | 607 | 
| 602 session_controller_->AddObserver(this); | 608 session_controller_->AddObserver(this); | 
| 603 } | 609 } | 
| 604 | 610 | 
| 605 Shell::~Shell() { | 611 Shell::~Shell() { | 
| 606 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); | 612 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); | 
| 607 | 613 | 
| 608 const Config config = shell_port_->GetAshConfig(); | 614 const Config config = shell_port_->GetAshConfig(); | 
| 609 | 615 | 
| 610 if (config != Config::MASH) | 616 if (config != Config::MASH) | 
| 611 user_metrics_recorder_->OnShellShuttingDown(); | 617 user_metrics_recorder_->OnShellShuttingDown(); | 
| 612 | 618 | 
| 619 app_list()->set_delegate(nullptr); | |
| 
 
sky
2017/06/07 20:21:36
Document why this this is necessary. In particular
 
newcomer
2017/06/08 21:59:05
Done.
 
 | |
| 620 | |
| 613 shell_delegate_->PreShutdown(); | 621 shell_delegate_->PreShutdown(); | 
| 614 | 622 | 
| 615 // Remove the focus from any window. This will prevent overhead and side | 623 // Remove the focus from any window. This will prevent overhead and side | 
| 616 // effects (e.g. crashes) from changing focus during shutdown. | 624 // effects (e.g. crashes) from changing focus during shutdown. | 
| 617 // See bug crbug.com/134502. | 625 // See bug crbug.com/134502. | 
| 618 aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr); | 626 aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr); | 
| 619 | 627 | 
| 620 // Please keep in same order as in Init() because it's easy to miss one. | 628 // Please keep in same order as in Init() because it's easy to miss one. | 
| 621 if (window_modality_controller_) | 629 if (window_modality_controller_) | 
| 622 window_modality_controller_.reset(); | 630 window_modality_controller_.reset(); | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 laser_pointer_controller_.reset(); | 727 laser_pointer_controller_.reset(); | 
| 720 partial_magnification_controller_.reset(); | 728 partial_magnification_controller_.reset(); | 
| 721 | 729 | 
| 722 // This also deletes all RootWindows. Note that we invoke Shutdown() on | 730 // This also deletes all RootWindows. Note that we invoke Shutdown() on | 
| 723 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 731 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 
| 724 // destruction | 732 // destruction | 
| 725 // of its owned RootWindowControllers relies on the value. | 733 // of its owned RootWindowControllers relies on the value. | 
| 726 ScreenAsh::CreateScreenForShutdown(); | 734 ScreenAsh::CreateScreenForShutdown(); | 
| 727 display_configuration_controller_.reset(); | 735 display_configuration_controller_.reset(); | 
| 728 | 736 | 
| 729 // AppListDelegateImpl depends upon AppList. | |
| 730 app_list_delegate_impl_.reset(); | |
| 731 | |
| 732 // These members access Shell in their destructors. | 737 // These members access Shell in their destructors. | 
| 733 wallpaper_controller_.reset(); | 738 wallpaper_controller_.reset(); | 
| 734 accessibility_delegate_.reset(); | 739 accessibility_delegate_.reset(); | 
| 735 | 740 | 
| 736 // Balances the Install() in Initialize(). | 741 // Balances the Install() in Initialize(). | 
| 737 views::FocusManagerFactory::Install(nullptr); | 742 views::FocusManagerFactory::Install(nullptr); | 
| 738 | 743 | 
| 739 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 744 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 
| 740 shelf_window_watcher_.reset(); | 745 shelf_window_watcher_.reset(); | 
| 741 | 746 | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); | 834 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); | 
| 830 auto css_backend = | 835 auto css_backend = | 
| 831 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); | 836 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); | 
| 832 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( | 837 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( | 
| 833 "Ash", devtools_server_.get()); | 838 "Ash", devtools_server_.get()); | 
| 834 devtools_client->AddAgent(std::move(dom_backend)); | 839 devtools_client->AddAgent(std::move(dom_backend)); | 
| 835 devtools_client->AddAgent(std::move(css_backend)); | 840 devtools_client->AddAgent(std::move(css_backend)); | 
| 836 devtools_server_->AttachClient(std::move(devtools_client)); | 841 devtools_server_->AttachClient(std::move(devtools_client)); | 
| 837 } | 842 } | 
| 838 | 843 | 
| 839 if (config == Config::MASH) | |
| 840 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); | |
| 841 | |
| 842 // TODO(sky): move creation to ShellPort. | 844 // TODO(sky): move creation to ShellPort. | 
| 843 if (config != Config::MASH) | 845 if (config != Config::MASH) | 
| 844 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 846 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 
| 845 | 847 | 
| 846 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 848 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 
| 847 | 849 | 
| 848 if (config == Config::CLASSIC) { | 850 if (config == Config::CLASSIC) { | 
| 849 // TODO: needs to work in mus. http://crbug.com/705592. | 851 // TODO: needs to work in mus. http://crbug.com/705592. | 
| 850 native_cursor_manager_ = new AshNativeCursorManager; | 852 native_cursor_manager_ = new AshNativeCursorManager; | 
| 851 cursor_manager_.reset( | 853 cursor_manager_.reset( | 
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1211 } | 1213 } | 
| 1212 | 1214 | 
| 1213 void Shell::OnWindowActivated( | 1215 void Shell::OnWindowActivated( | 
| 1214 ::wm::ActivationChangeObserver::ActivationReason reason, | 1216 ::wm::ActivationChangeObserver::ActivationReason reason, | 
| 1215 aura::Window* gained_active, | 1217 aura::Window* gained_active, | 
| 1216 aura::Window* lost_active) { | 1218 aura::Window* lost_active) { | 
| 1217 if (gained_active) | 1219 if (gained_active) | 
| 1218 root_window_for_new_windows_ = gained_active->GetRootWindow(); | 1220 root_window_for_new_windows_ = gained_active->GetRootWindow(); | 
| 1219 } | 1221 } | 
| 1220 | 1222 | 
| 1223 void Shell::OnAppListVisibilityChanged(bool visible, int64_t display_id) { | |
| 1224 NotifyAppListVisibilityChanged( | |
| 1225 visible, ShellPort::Get()->GetRootWindowForDisplayId(display_id)); | |
| 1226 } | |
| 1227 | |
| 1221 void Shell::OnSessionStateChanged(session_manager::SessionState state) { | 1228 void Shell::OnSessionStateChanged(session_manager::SessionState state) { | 
| 1222 // Initialize the shelf when a session becomes active. It's safe to do this | 1229 // Initialize the shelf when a session becomes active. It's safe to do this | 
| 1223 // multiple times (e.g. initial login vs. multiprofile add session). | 1230 // multiple times (e.g. initial login vs. multiprofile add session). | 
| 1224 if (state == session_manager::SessionState::ACTIVE) { | 1231 if (state == session_manager::SessionState::ACTIVE) { | 
| 1225 InitializeShelf(); | 1232 InitializeShelf(); | 
| 1226 if (GetAshConfig() != Config::MASH) { | 1233 if (GetAshConfig() != Config::MASH) { | 
| 1227 // Recreate the keyboard after initial login and after multiprofile login. | 1234 // Recreate the keyboard after initial login and after multiprofile login. | 
| 1228 CreateKeyboard(); | 1235 CreateKeyboard(); | 
| 1229 } | 1236 } | 
| 1230 } | 1237 } | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 void Shell::OnPrefServiceInitialized( | 1272 void Shell::OnPrefServiceInitialized( | 
| 1266 std::unique_ptr<::PrefService> pref_service) { | 1273 std::unique_ptr<::PrefService> pref_service) { | 
| 1267 if (!instance_) | 1274 if (!instance_) | 
| 1268 return; | 1275 return; | 
| 1269 // |pref_service_| is null if can't connect to Chrome (as happens when | 1276 // |pref_service_| is null if can't connect to Chrome (as happens when | 
| 1270 // running mash outside of chrome --mash and chrome isn't built). | 1277 // running mash outside of chrome --mash and chrome isn't built). | 
| 1271 pref_service_ = std::move(pref_service); | 1278 pref_service_ = std::move(pref_service); | 
| 1272 } | 1279 } | 
| 1273 | 1280 | 
| 1274 } // namespace ash | 1281 } // namespace ash | 
| OLD | NEW |