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 19 matching lines...) Expand all Loading... | |
| 47 #include "ash/login_status.h" | 46 #include "ash/login_status.h" | 
| 48 #include "ash/magnifier/magnification_controller.h" | 47 #include "ash/magnifier/magnification_controller.h" | 
| 49 #include "ash/magnifier/partial_magnification_controller.h" | 48 #include "ash/magnifier/partial_magnification_controller.h" | 
| 50 #include "ash/media_controller.h" | 49 #include "ash/media_controller.h" | 
| 51 #include "ash/new_window_controller.h" | 50 #include "ash/new_window_controller.h" | 
| 52 #include "ash/palette_delegate.h" | 51 #include "ash/palette_delegate.h" | 
| 53 #include "ash/public/cpp/config.h" | 52 #include "ash/public/cpp/config.h" | 
| 54 #include "ash/public/cpp/shell_window_ids.h" | 53 #include "ash/public/cpp/shell_window_ids.h" | 
| 55 #include "ash/root_window_controller.h" | 54 #include "ash/root_window_controller.h" | 
| 56 #include "ash/session/session_controller.h" | 55 #include "ash/session/session_controller.h" | 
| 56 #include "ash/shelf/app_list_button.h" | |
| 57 #include "ash/shelf/shelf.h" | 57 #include "ash/shelf/shelf.h" | 
| 58 #include "ash/shelf/shelf_controller.h" | 58 #include "ash/shelf/shelf_controller.h" | 
| 59 #include "ash/shelf/shelf_model.h" | 59 #include "ash/shelf/shelf_model.h" | 
| 60 #include "ash/shelf/shelf_window_watcher.h" | 60 #include "ash/shelf/shelf_window_watcher.h" | 
| 61 #include "ash/shell_delegate.h" | 61 #include "ash/shell_delegate.h" | 
| 62 #include "ash/shell_init_params.h" | 62 #include "ash/shell_init_params.h" | 
| 63 #include "ash/shell_observer.h" | 63 #include "ash/shell_observer.h" | 
| 64 #include "ash/shell_port.h" | 64 #include "ash/shell_port.h" | 
| 65 #include "ash/shutdown_controller.h" | 65 #include "ash/shutdown_controller.h" | 
| 66 #include "ash/sticky_keys/sticky_keys_controller.h" | 66 #include "ash/sticky_keys/sticky_keys_controller.h" | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 #include "chromeos/chromeos_switches.h" | 129 #include "chromeos/chromeos_switches.h" | 
| 130 #include "chromeos/dbus/dbus_thread_manager.h" | 130 #include "chromeos/dbus/dbus_thread_manager.h" | 
| 131 #include "chromeos/system/devicemode.h" | 131 #include "chromeos/system/devicemode.h" | 
| 132 #include "components/prefs/pref_registry_simple.h" | 132 #include "components/prefs/pref_registry_simple.h" | 
| 133 #include "components/prefs/pref_service.h" | 133 #include "components/prefs/pref_service.h" | 
| 134 #include "components/ui_devtools/devtools_server.h" | 134 #include "components/ui_devtools/devtools_server.h" | 
| 135 #include "services/preferences/public/cpp/pref_service_factory.h" | 135 #include "services/preferences/public/cpp/pref_service_factory.h" | 
| 136 #include "services/preferences/public/interfaces/preferences.mojom.h" | 136 #include "services/preferences/public/interfaces/preferences.mojom.h" | 
| 137 #include "services/service_manager/public/cpp/connector.h" | 137 #include "services/service_manager/public/cpp/connector.h" | 
| 138 #include "services/ui/public/interfaces/constants.mojom.h" | 138 #include "services/ui/public/interfaces/constants.mojom.h" | 
| 139 #include "ui/app_list/app_list_features.h" | |
| 139 #include "ui/app_list/presenter/app_list.h" | 140 #include "ui/app_list/presenter/app_list.h" | 
| 141 #include "ui/app_list/presenter/app_list_delegate.h" | |
| 140 #include "ui/aura/client/aura_constants.h" | 142 #include "ui/aura/client/aura_constants.h" | 
| 141 #include "ui/aura/env.h" | 143 #include "ui/aura/env.h" | 
| 142 #include "ui/aura/layout_manager.h" | 144 #include "ui/aura/layout_manager.h" | 
| 143 #include "ui/aura/mus/focus_synchronizer.h" | 145 #include "ui/aura/mus/focus_synchronizer.h" | 
| 144 #include "ui/aura/mus/user_activity_forwarder.h" | 146 #include "ui/aura/mus/user_activity_forwarder.h" | 
| 145 #include "ui/aura/mus/window_tree_client.h" | 147 #include "ui/aura/mus/window_tree_client.h" | 
| 146 #include "ui/aura/window.h" | 148 #include "ui/aura/window.h" | 
| 147 #include "ui/aura/window_event_dispatcher.h" | 149 #include "ui/aura/window_event_dispatcher.h" | 
| 148 #include "ui/base/ui_base_switches.h" | 150 #include "ui/base/ui_base_switches.h" | 
| 149 #include "ui/base/user_activity/user_activity_detector.h" | 151 #include "ui/base/user_activity/user_activity_detector.h" | 
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 return app_list_->GetTargetVisibility(); | 481 return app_list_->GetTargetVisibility(); | 
| 480 } | 482 } | 
| 481 | 483 | 
| 482 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { | 484 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { | 
| 483 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) { | 485 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) { | 
| 484 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( | 486 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( | 
| 485 status); | 487 status); | 
| 486 } | 488 } | 
| 487 } | 489 } | 
| 488 | 490 | 
| 491 void Shell::NotifyAppListShownOrDismissed(bool shown, | |
| 492 aura::Window* root_window) { | |
| 493 for (auto& observer : shell_observers_) | |
| 494 observer.OnAppListShownOrDismissed(shown, root_window); | |
| 495 } | |
| 496 | |
| 489 void Shell::NotifyMaximizeModeStarted() { | 497 void Shell::NotifyMaximizeModeStarted() { | 
| 490 for (auto& observer : shell_observers_) | 498 for (auto& observer : shell_observers_) | 
| 491 observer.OnMaximizeModeStarted(); | 499 observer.OnMaximizeModeStarted(); | 
| 492 } | 500 } | 
| 493 | 501 | 
| 494 void Shell::NotifyMaximizeModeEnding() { | 502 void Shell::NotifyMaximizeModeEnding() { | 
| 495 for (auto& observer : shell_observers_) | 503 for (auto& observer : shell_observers_) | 
| 496 observer.OnMaximizeModeEnding(); | 504 observer.OnMaximizeModeEnding(); | 
| 497 } | 505 } | 
| 498 | 506 | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 596 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 
| 589 // state on ShellPortClassic. http://crbug.com/671246. | 597 // state on ShellPortClassic. http://crbug.com/671246. | 
| 590 | 598 | 
| 591 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | 599 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | 
| 592 | 600 | 
| 593 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. | 601 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. | 
| 594 if (shell_port_->GetAshConfig() != Config::MASH) { | 602 if (shell_port_->GetAshConfig() != Config::MASH) { | 
| 595 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 603 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 
| 596 window_tree_host_manager_.reset(new WindowTreeHostManager); | 604 window_tree_host_manager_.reset(new WindowTreeHostManager); | 
| 597 user_metrics_recorder_.reset(new UserMetricsRecorder); | 605 user_metrics_recorder_.reset(new UserMetricsRecorder); | 
| 606 } else { | |
| 607 app_list()->set_delegate(this); | |
| 
 
xiyuan
2017/06/06 15:51:04
If we unify the app list visibility change notific
 
newcomer
2017/06/06 16:42:29
Done.
 
 | |
| 598 } | 608 } | 
| 599 | 609 | 
| 600 PowerStatus::Initialize(); | 610 PowerStatus::Initialize(); | 
| 601 | 611 | 
| 602 session_controller_->AddObserver(this); | 612 session_controller_->AddObserver(this); | 
| 603 } | 613 } | 
| 604 | 614 | 
| 605 Shell::~Shell() { | 615 Shell::~Shell() { | 
| 606 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); | 616 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); | 
| 607 | 617 | 
| 608 const Config config = shell_port_->GetAshConfig(); | 618 const Config config = shell_port_->GetAshConfig(); | 
| 609 | 619 | 
| 610 if (config != Config::MASH) | 620 if (config != Config::MASH) | 
| 611 user_metrics_recorder_->OnShellShuttingDown(); | 621 user_metrics_recorder_->OnShellShuttingDown(); | 
| 622 else | |
| 623 app_list()->set_delegate(nullptr); | |
| 612 | 624 | 
| 613 shell_delegate_->PreShutdown(); | 625 shell_delegate_->PreShutdown(); | 
| 614 | 626 | 
| 615 // Remove the focus from any window. This will prevent overhead and side | 627 // Remove the focus from any window. This will prevent overhead and side | 
| 616 // effects (e.g. crashes) from changing focus during shutdown. | 628 // effects (e.g. crashes) from changing focus during shutdown. | 
| 617 // See bug crbug.com/134502. | 629 // See bug crbug.com/134502. | 
| 618 aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr); | 630 aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr); | 
| 619 | 631 | 
| 620 // Please keep in same order as in Init() because it's easy to miss one. | 632 // Please keep in same order as in Init() because it's easy to miss one. | 
| 621 if (window_modality_controller_) | 633 if (window_modality_controller_) | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 laser_pointer_controller_.reset(); | 731 laser_pointer_controller_.reset(); | 
| 720 partial_magnification_controller_.reset(); | 732 partial_magnification_controller_.reset(); | 
| 721 | 733 | 
| 722 // This also deletes all RootWindows. Note that we invoke Shutdown() on | 734 // This also deletes all RootWindows. Note that we invoke Shutdown() on | 
| 723 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 735 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 
| 724 // destruction | 736 // destruction | 
| 725 // of its owned RootWindowControllers relies on the value. | 737 // of its owned RootWindowControllers relies on the value. | 
| 726 ScreenAsh::CreateScreenForShutdown(); | 738 ScreenAsh::CreateScreenForShutdown(); | 
| 727 display_configuration_controller_.reset(); | 739 display_configuration_controller_.reset(); | 
| 728 | 740 | 
| 729 // AppListDelegateImpl depends upon AppList. | |
| 730 app_list_delegate_impl_.reset(); | |
| 731 | |
| 732 // These members access Shell in their destructors. | 741 // These members access Shell in their destructors. | 
| 733 wallpaper_controller_.reset(); | 742 wallpaper_controller_.reset(); | 
| 734 accessibility_delegate_.reset(); | 743 accessibility_delegate_.reset(); | 
| 735 | 744 | 
| 736 // Balances the Install() in Initialize(). | 745 // Balances the Install() in Initialize(). | 
| 737 views::FocusManagerFactory::Install(nullptr); | 746 views::FocusManagerFactory::Install(nullptr); | 
| 738 | 747 | 
| 739 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 748 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 
| 740 shelf_window_watcher_.reset(); | 749 shelf_window_watcher_.reset(); | 
| 741 | 750 | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); | 838 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); | 
| 830 auto css_backend = | 839 auto css_backend = | 
| 831 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); | 840 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); | 
| 832 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( | 841 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( | 
| 833 "Ash", devtools_server_.get()); | 842 "Ash", devtools_server_.get()); | 
| 834 devtools_client->AddAgent(std::move(dom_backend)); | 843 devtools_client->AddAgent(std::move(dom_backend)); | 
| 835 devtools_client->AddAgent(std::move(css_backend)); | 844 devtools_client->AddAgent(std::move(css_backend)); | 
| 836 devtools_server_->AttachClient(std::move(devtools_client)); | 845 devtools_server_->AttachClient(std::move(devtools_client)); | 
| 837 } | 846 } | 
| 838 | 847 | 
| 839 if (config == Config::MASH) | |
| 840 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); | |
| 841 | |
| 842 // TODO(sky): move creation to ShellPort. | 848 // TODO(sky): move creation to ShellPort. | 
| 843 if (config != Config::MASH) | 849 if (config != Config::MASH) | 
| 844 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 850 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 
| 845 | 851 | 
| 846 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 852 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 
| 847 | 853 | 
| 848 if (config == Config::CLASSIC) { | 854 if (config == Config::CLASSIC) { | 
| 849 // TODO: needs to work in mus. http://crbug.com/705592. | 855 // TODO: needs to work in mus. http://crbug.com/705592. | 
| 850 native_cursor_manager_ = new AshNativeCursorManager; | 856 native_cursor_manager_ = new AshNativeCursorManager; | 
| 851 cursor_manager_.reset( | 857 cursor_manager_.reset( | 
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1211 } | 1217 } | 
| 1212 | 1218 | 
| 1213 void Shell::OnWindowActivated( | 1219 void Shell::OnWindowActivated( | 
| 1214 ::wm::ActivationChangeObserver::ActivationReason reason, | 1220 ::wm::ActivationChangeObserver::ActivationReason reason, | 
| 1215 aura::Window* gained_active, | 1221 aura::Window* gained_active, | 
| 1216 aura::Window* lost_active) { | 1222 aura::Window* lost_active) { | 
| 1217 if (gained_active) | 1223 if (gained_active) | 
| 1218 root_window_for_new_windows_ = gained_active->GetRootWindow(); | 1224 root_window_for_new_windows_ = gained_active->GetRootWindow(); | 
| 1219 } | 1225 } | 
| 1220 | 1226 | 
| 1227 void Shell::OnAppListVisibilityChanged(bool visible, int64_t display_id) { | |
| 1228 NotifyAppListShownOrDismissed(visible, | |
| 
 
xiyuan
2017/06/06 15:51:04
NotifyAppListShownOrDismissed -> NotifyAppListVisi
 
newcomer
2017/06/06 16:42:29
Done.
 
 | |
| 1229 ShellPort::Get()-> | |
| 1230 GetRootWindowForDisplayId(display_id)); | |
| 1231 } | |
| 1232 | |
| 1221 void Shell::OnSessionStateChanged(session_manager::SessionState state) { | 1233 void Shell::OnSessionStateChanged(session_manager::SessionState state) { | 
| 1222 // Initialize the shelf when a session becomes active. It's safe to do this | 1234 // 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). | 1235 // multiple times (e.g. initial login vs. multiprofile add session). | 
| 1224 if (state == session_manager::SessionState::ACTIVE) { | 1236 if (state == session_manager::SessionState::ACTIVE) { | 
| 1225 InitializeShelf(); | 1237 InitializeShelf(); | 
| 1226 if (GetAshConfig() != Config::MASH) { | 1238 if (GetAshConfig() != Config::MASH) { | 
| 1227 // Recreate the keyboard after initial login and after multiprofile login. | 1239 // Recreate the keyboard after initial login and after multiprofile login. | 
| 1228 CreateKeyboard(); | 1240 CreateKeyboard(); | 
| 1229 } | 1241 } | 
| 1230 } | 1242 } | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 void Shell::OnPrefServiceInitialized( | 1277 void Shell::OnPrefServiceInitialized( | 
| 1266 std::unique_ptr<::PrefService> pref_service) { | 1278 std::unique_ptr<::PrefService> pref_service) { | 
| 1267 if (!instance_) | 1279 if (!instance_) | 
| 1268 return; | 1280 return; | 
| 1269 // |pref_service_| is null if can't connect to Chrome (as happens when | 1281 // |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). | 1282 // running mash outside of chrome --mash and chrome isn't built). | 
| 1271 pref_service_ = std::move(pref_service); | 1283 pref_service_ = std::move(pref_service); | 
| 1272 } | 1284 } | 
| 1273 | 1285 | 
| 1274 } // namespace ash | 1286 } // namespace ash | 
| OLD | NEW |