Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: ash/shell.cc

Issue 2815043002: Removes ShellPort::IsRunningInMash() (Closed)
Patch Set: dont set instance_ in constructor Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shelf/wm_shelf.cc ('k') | ash/shell_port.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 RootWindowControllerList controllers = GetAllRootWindowControllers(); 356 RootWindowControllerList controllers = GetAllRootWindowControllers();
357 for (RootWindowControllerList::iterator iter = controllers.begin(); 357 for (RootWindowControllerList::iterator iter = controllers.begin();
358 iter != controllers.end(); ++iter) { 358 iter != controllers.end(); ++iter) {
359 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); 359 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
360 } 360 }
361 } 361 }
362 keyboard::KeyboardController::ResetInstance(nullptr); 362 keyboard::KeyboardController::ResetInstance(nullptr);
363 } 363 }
364 364
365 bool Shell::ShouldSaveDisplaySettings() { 365 bool Shell::ShouldSaveDisplaySettings() {
366 DCHECK(!shell_port_->IsRunningInMash()); 366 DCHECK(GetAshConfig() != Config::MASH);
367 return !( 367 return !(
368 screen_orientation_controller_->ignore_display_configuration_updates() || 368 screen_orientation_controller_->ignore_display_configuration_updates() ||
369 resolution_notification_controller_->DoesNotificationTimeout()); 369 resolution_notification_controller_->DoesNotificationTimeout());
370 } 370 }
371 371
372 ShelfModel* Shell::shelf_model() { 372 ShelfModel* Shell::shelf_model() {
373 return shelf_controller_->model(); 373 return shelf_controller_->model();
374 } 374 }
375 375
376 aura::client::ActivationClient* Shell::activation_client() { 376 aura::client::ActivationClient* Shell::activation_client() {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 app_list_(base::MakeUnique<app_list::AppList>()), 564 app_list_(base::MakeUnique<app_list::AppList>()),
565 link_handler_model_factory_(nullptr), 565 link_handler_model_factory_(nullptr),
566 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), 566 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()),
567 display_configurator_(new display::DisplayConfigurator()), 567 display_configurator_(new display::DisplayConfigurator()),
568 native_cursor_manager_(nullptr), 568 native_cursor_manager_(nullptr),
569 simulate_modal_window_open_for_testing_(false), 569 simulate_modal_window_open_for_testing_(false),
570 is_touch_hud_projection_enabled_(false) { 570 is_touch_hud_projection_enabled_(false) {
571 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash 571 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash
572 // state on ShellPortClassic. http://crbug.com/671246. 572 // state on ShellPortClassic. http://crbug.com/671246.
573 573
574 if (!shell_port_->IsRunningInMash()) { 574 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set.
575 if (shell_port_->GetAshConfig() != Config::MASH) {
575 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); 576 gpu_support_.reset(shell_delegate_->CreateGPUSupport());
576 display_manager_.reset(ScreenAsh::CreateDisplayManager()); 577 display_manager_.reset(ScreenAsh::CreateDisplayManager());
577 window_tree_host_manager_.reset(new WindowTreeHostManager); 578 window_tree_host_manager_.reset(new WindowTreeHostManager);
578 user_metrics_recorder_.reset(new UserMetricsRecorder); 579 user_metrics_recorder_.reset(new UserMetricsRecorder);
579 } 580 }
580 581
581 PowerStatus::Initialize(); 582 PowerStatus::Initialize();
582 583
583 session_controller_->AddSessionStateObserver(this); 584 session_controller_->AddSessionStateObserver(this);
584 } 585 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 session_controller_->RemoveSessionStateObserver(this); 763 session_controller_->RemoveSessionStateObserver(this);
763 wallpaper_delegate_.reset(); 764 wallpaper_delegate_.reset();
764 pref_service_ = nullptr; 765 pref_service_ = nullptr;
765 shell_delegate_.reset(); 766 shell_delegate_.reset();
766 767
767 DCHECK(instance_ == this); 768 DCHECK(instance_ == this);
768 instance_ = nullptr; 769 instance_ = nullptr;
769 } 770 }
770 771
771 void Shell::Init(const ShellInitParams& init_params) { 772 void Shell::Init(const ShellInitParams& init_params) {
772 const bool is_mash = shell_port_->IsRunningInMash();
773 const Config config = shell_port_->GetAshConfig(); 773 const Config config = shell_port_->GetAshConfig();
774 774
775 blocking_pool_ = init_params.blocking_pool; 775 blocking_pool_ = init_params.blocking_pool;
776 776
777 wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate(); 777 wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate();
778 778
779 // Can be null in tests. 779 // Can be null in tests.
780 if (shell_port_->IsRunningInMash() && shell_delegate_->GetShellConnector()) { 780 if (config == Config::MASH && shell_delegate_->GetShellConnector()) {
781 prefs::ConnectToPrefService( 781 prefs::ConnectToPrefService(
782 shell_delegate_->GetShellConnector(), 782 shell_delegate_->GetShellConnector(),
783 make_scoped_refptr(new PrefRegistrySimple()), 783 make_scoped_refptr(new PrefRegistrySimple()),
784 std::vector<PrefValueStore::PrefStoreType>(), 784 std::vector<PrefValueStore::PrefStoreType>(),
785 base::Bind(&Shell::OnPrefServiceInitialized, base::Unretained(this)), 785 base::Bind(&Shell::OnPrefServiceInitialized, base::Unretained(this)),
786 prefs::mojom::kForwarderServiceName); 786 prefs::mojom::kForwarderServiceName);
787 } 787 }
788 788
789 // Some delegates access ShellPort during their construction. Create them here 789 // Some delegates access ShellPort during their construction. Create them here
790 // instead of the ShellPort constructor. 790 // instead of the ShellPort constructor.
(...skipping 13 matching lines...) Expand all
804 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); 804 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>();
805 auto css_backend = 805 auto css_backend =
806 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); 806 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get());
807 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( 807 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>(
808 "Ash", devtools_server_.get()); 808 "Ash", devtools_server_.get());
809 devtools_client->AddAgent(std::move(dom_backend)); 809 devtools_client->AddAgent(std::move(dom_backend));
810 devtools_client->AddAgent(std::move(css_backend)); 810 devtools_client->AddAgent(std::move(css_backend));
811 devtools_server_->AttachClient(std::move(devtools_client)); 811 devtools_server_->AttachClient(std::move(devtools_client));
812 } 812 }
813 813
814 if (is_mash) 814 if (config == Config::MASH)
815 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); 815 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>();
816 816
817 // TODO(sky): move creation to ShellPort. 817 // TODO(sky): move creation to ShellPort.
818 if (!is_mash) 818 if (config != Config::MASH)
819 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); 819 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>();
820 820
821 scoped_overview_animation_settings_factory_.reset( 821 scoped_overview_animation_settings_factory_.reset(
822 new ScopedOverviewAnimationSettingsFactoryAura); 822 new ScopedOverviewAnimationSettingsFactoryAura);
823 window_positioner_ = base::MakeUnique<WindowPositioner>(); 823 window_positioner_ = base::MakeUnique<WindowPositioner>();
824 824
825 if (config == Config::CLASSIC) { 825 if (config == Config::CLASSIC) {
826 // TODO: needs to work in mus. http://crbug.com/705592. 826 // TODO: needs to work in mus. http://crbug.com/705592.
827 native_cursor_manager_ = new AshNativeCursorManager; 827 native_cursor_manager_ = new AshNativeCursorManager;
828 cursor_manager_.reset( 828 cursor_manager_.reset(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 // FocusController takes ownership of AshFocusRules. 904 // FocusController takes ownership of AshFocusRules.
905 focus_controller_ = 905 focus_controller_ =
906 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); 906 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules());
907 focus_controller_->AddObserver(this); 907 focus_controller_->AddObserver(this);
908 908
909 screen_position_controller_.reset(new ScreenPositionController); 909 screen_position_controller_.reset(new ScreenPositionController);
910 910
911 shell_port_->CreatePrimaryHost(); 911 shell_port_->CreatePrimaryHost();
912 root_window_for_new_windows_ = WmWindow::Get(GetPrimaryRootWindow()); 912 root_window_for_new_windows_ = WmWindow::Get(GetPrimaryRootWindow());
913 913
914 if (!is_mash) { 914 if (config != Config::MASH) {
915 resolution_notification_controller_.reset( 915 resolution_notification_controller_.reset(
916 new ResolutionNotificationController); 916 new ResolutionNotificationController);
917 } 917 }
918 918
919 if (cursor_manager_) { 919 if (cursor_manager_) {
920 cursor_manager_->SetDisplay( 920 cursor_manager_->SetDisplay(
921 display::Screen::GetScreen()->GetPrimaryDisplay()); 921 display::Screen::GetScreen()->GetPrimaryDisplay());
922 } 922 }
923 923
924 accelerator_controller_ = shell_port_->CreateAcceleratorController(); 924 accelerator_controller_ = shell_port_->CreateAcceleratorController();
(...skipping 25 matching lines...) Expand all
950 std::unique_ptr<::wm::AcceleratorDelegate>(new AcceleratorDelegate), 950 std::unique_ptr<::wm::AcceleratorDelegate>(new AcceleratorDelegate),
951 accelerator_controller_->accelerator_history())); 951 accelerator_controller_->accelerator_history()));
952 AddPreTargetHandler(accelerator_filter_.get()); 952 AddPreTargetHandler(accelerator_filter_.get());
953 953
954 event_transformation_handler_.reset(new EventTransformationHandler); 954 event_transformation_handler_.reset(new EventTransformationHandler);
955 AddPreTargetHandler(event_transformation_handler_.get()); 955 AddPreTargetHandler(event_transformation_handler_.get());
956 956
957 toplevel_window_event_handler_ = 957 toplevel_window_event_handler_ =
958 base::MakeUnique<ToplevelWindowEventHandler>(); 958 base::MakeUnique<ToplevelWindowEventHandler>();
959 959
960 if (!is_mash) { 960 if (config != Config::MASH) {
961 system_gesture_filter_.reset(new SystemGestureEventFilter); 961 system_gesture_filter_.reset(new SystemGestureEventFilter);
962 AddPreTargetHandler(system_gesture_filter_.get()); 962 AddPreTargetHandler(system_gesture_filter_.get());
963 } 963 }
964 964
965 sticky_keys_controller_.reset(new StickyKeysController); 965 sticky_keys_controller_.reset(new StickyKeysController);
966 screen_pinning_controller_ = base::MakeUnique<ScreenPinningController>(); 966 screen_pinning_controller_ = base::MakeUnique<ScreenPinningController>();
967 967
968 lock_state_controller_ = 968 lock_state_controller_ =
969 base::MakeUnique<LockStateController>(shutdown_controller_.get()); 969 base::MakeUnique<LockStateController>(shutdown_controller_.get());
970 power_button_controller_.reset( 970 power_button_controller_.reset(
971 new PowerButtonController(lock_state_controller_.get())); 971 new PowerButtonController(lock_state_controller_.get()));
972 // Pass the initial display state to PowerButtonController. 972 // Pass the initial display state to PowerButtonController.
973 power_button_controller_->OnDisplayModeChanged( 973 power_button_controller_->OnDisplayModeChanged(
974 display_configurator_->cached_displays()); 974 display_configurator_->cached_displays());
975 975
976 AddShellObserver(lock_state_controller_.get()); 976 AddShellObserver(lock_state_controller_.get());
977 977
978 // The connector is unavailable in some tests. 978 // The connector is unavailable in some tests.
979 if (is_mash && shell_delegate_->GetShellConnector()) { 979 if (config == Config::MASH && shell_delegate_->GetShellConnector()) {
980 ui::mojom::UserActivityMonitorPtr user_activity_monitor; 980 ui::mojom::UserActivityMonitorPtr user_activity_monitor;
981 shell_delegate_->GetShellConnector()->BindInterface(ui::mojom::kServiceName, 981 shell_delegate_->GetShellConnector()->BindInterface(ui::mojom::kServiceName,
982 &user_activity_monitor); 982 &user_activity_monitor);
983 user_activity_forwarder_ = base::MakeUnique<aura::UserActivityForwarder>( 983 user_activity_forwarder_ = base::MakeUnique<aura::UserActivityForwarder>(
984 std::move(user_activity_monitor), user_activity_detector_.get()); 984 std::move(user_activity_monitor), user_activity_detector_.get());
985 } 985 }
986 986
987 drag_drop_controller_.reset(new DragDropController); 987 drag_drop_controller_.reset(new DragDropController);
988 // |screenshot_controller_| needs to be created (and prepended as a 988 // |screenshot_controller_| needs to be created (and prepended as a
989 // pre-target handler) at this point, because |mouse_cursor_filter_| needs to 989 // pre-target handler) at this point, because |mouse_cursor_filter_| needs to
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 SetSystemTrayDelegate( 1033 SetSystemTrayDelegate(
1034 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); 1034 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate()));
1035 1035
1036 // May trigger initialization of the Bluetooth adapter. 1036 // May trigger initialization of the Bluetooth adapter.
1037 tray_bluetooth_helper_->Initialize(); 1037 tray_bluetooth_helper_->Initialize();
1038 1038
1039 // Create AshTouchTransformController before 1039 // Create AshTouchTransformController before
1040 // WindowTreeHostManager::InitDisplays() 1040 // WindowTreeHostManager::InitDisplays()
1041 // since AshTouchTransformController listens on 1041 // since AshTouchTransformController listens on
1042 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). 1042 // WindowTreeHostManager::Observer::OnDisplaysInitialized().
1043 if (!is_mash) { 1043 if (config != Config::MASH) {
1044 touch_transformer_controller_.reset(new AshTouchTransformController( 1044 touch_transformer_controller_.reset(new AshTouchTransformController(
1045 display_configurator_.get(), display_manager_.get())); 1045 display_configurator_.get(), display_manager_.get()));
1046 } 1046 }
1047 1047
1048 keyboard_ui_ = shell_port_->CreateKeyboardUI(); 1048 keyboard_ui_ = shell_port_->CreateKeyboardUI();
1049 1049
1050 shell_port_->InitHosts(init_params); 1050 shell_port_->InitHosts(init_params);
1051 1051
1052 // Needs to be created after InitDisplays() since it may cause the virtual 1052 // Needs to be created after InitDisplays() since it may cause the virtual
1053 // keyboard to be deployed. 1053 // keyboard to be deployed.
1054 if (!is_mash) 1054 if (config != Config::MASH)
1055 virtual_keyboard_controller_.reset(new VirtualKeyboardController); 1055 virtual_keyboard_controller_.reset(new VirtualKeyboardController);
1056 1056
1057 audio_a11y_controller_.reset(new chromeos::AudioA11yController); 1057 audio_a11y_controller_.reset(new chromeos::AudioA11yController);
1058 1058
1059 // Initialize the wallpaper after the RootWindowController has been created, 1059 // Initialize the wallpaper after the RootWindowController has been created,
1060 // otherwise the widget will not paint when restoring after a browser crash. 1060 // otherwise the widget will not paint when restoring after a browser crash.
1061 // Also, initialize after display initialization to ensure correct sizing. 1061 // Also, initialize after display initialization to ensure correct sizing.
1062 wallpaper_delegate_->InitializeWallpaper(); 1062 wallpaper_delegate_->InitializeWallpaper();
1063 1063
1064 if (cursor_manager_) { 1064 if (cursor_manager_) {
1065 if (initially_hide_cursor_) 1065 if (initially_hide_cursor_)
1066 cursor_manager_->HideCursor(); 1066 cursor_manager_->HideCursor();
1067 cursor_manager_->SetCursor(ui::kCursorPointer); 1067 cursor_manager_->SetCursor(ui::kCursorPointer);
1068 } 1068 }
1069 1069
1070 power_event_observer_.reset(new PowerEventObserver()); 1070 power_event_observer_.reset(new PowerEventObserver());
1071 user_activity_notifier_.reset( 1071 user_activity_notifier_.reset(
1072 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); 1072 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get()));
1073 video_activity_notifier_.reset( 1073 video_activity_notifier_.reset(
1074 new VideoActivityNotifier(video_detector_.get())); 1074 new VideoActivityNotifier(video_detector_.get()));
1075 bluetooth_notification_controller_.reset(new BluetoothNotificationController); 1075 bluetooth_notification_controller_.reset(new BluetoothNotificationController);
1076 if (!is_mash) { 1076 if (config != Config::MASH) {
1077 screen_orientation_controller_.reset(new ScreenOrientationController()); 1077 screen_orientation_controller_.reset(new ScreenOrientationController());
1078 screen_layout_observer_.reset(new ScreenLayoutObserver()); 1078 screen_layout_observer_.reset(new ScreenLayoutObserver());
1079 } 1079 }
1080 sms_observer_.reset(new SmsObserver()); 1080 sms_observer_.reset(new SmsObserver());
1081 1081
1082 // The compositor thread and main message loop have to be running in 1082 // The compositor thread and main message loop have to be running in
1083 // order to create mirror window. Run it after the main message loop 1083 // order to create mirror window. Run it after the main message loop
1084 // is started. 1084 // is started.
1085 if (!is_mash) 1085 if (config != Config::MASH)
1086 display_manager_->CreateMirrorWindowAsyncIfAny(); 1086 display_manager_->CreateMirrorWindowAsyncIfAny();
1087 1087
1088 for (auto& observer : shell_observers_) 1088 for (auto& observer : shell_observers_)
1089 observer.OnShellInitialized(); 1089 observer.OnShellInitialized();
1090 1090
1091 if (!is_mash) 1091 if (config != Config::MASH)
1092 user_metrics_recorder_->OnShellInitialized(); 1092 user_metrics_recorder_->OnShellInitialized();
1093 } 1093 }
1094 1094
1095 void Shell::InitKeyboard() { 1095 void Shell::InitKeyboard() {
1096 if (keyboard::IsKeyboardEnabled()) { 1096 if (keyboard::IsKeyboardEnabled()) {
1097 if (keyboard::KeyboardController::GetInstance()) { 1097 if (keyboard::KeyboardController::GetInstance()) {
1098 RootWindowControllerList controllers = GetAllRootWindowControllers(); 1098 RootWindowControllerList controllers = GetAllRootWindowControllers();
1099 for (RootWindowControllerList::iterator iter = controllers.begin(); 1099 for (RootWindowControllerList::iterator iter = controllers.begin();
1100 iter != controllers.end(); ++iter) { 1100 iter != controllers.end(); ++iter) {
1101 (*iter)->DeactivateKeyboard( 1101 (*iter)->DeactivateKeyboard(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 if (gained_active_wm) 1213 if (gained_active_wm)
1214 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); 1214 root_window_for_new_windows_ = gained_active_wm->GetRootWindow();
1215 } 1215 }
1216 1216
1217 void Shell::SessionStateChanged(session_manager::SessionState state) { 1217 void Shell::SessionStateChanged(session_manager::SessionState state) {
1218 // Create the shelf when a session becomes active. It's safe to do this 1218 // Create the shelf when a session becomes active. It's safe to do this
1219 // multiple times (e.g. initial login vs. multiprofile add session). 1219 // multiple times (e.g. initial login vs. multiprofile add session).
1220 if (state == session_manager::SessionState::ACTIVE) { 1220 if (state == session_manager::SessionState::ACTIVE) {
1221 CreateShelfView(); 1221 CreateShelfView();
1222 1222
1223 if (!shell_port_->IsRunningInMash()) { 1223 if (GetAshConfig() != Config::MASH) {
1224 // Recreate the keyboard after initial login and after multiprofile login. 1224 // Recreate the keyboard after initial login and after multiprofile login.
1225 CreateKeyboard(); 1225 CreateKeyboard();
1226 } 1226 }
1227 } 1227 }
1228 } 1228 }
1229 1229
1230 void Shell::LoginStatusChanged(LoginStatus login_status) { 1230 void Shell::LoginStatusChanged(LoginStatus login_status) {
1231 UpdateAfterLoginStatusChange(login_status); 1231 UpdateAfterLoginStatusChange(login_status);
1232 1232
1233 // TODO(xiyuan): Update OnLoginStateChanged -> OnLoginStatusChanged. 1233 // TODO(xiyuan): Update OnLoginStateChanged -> OnLoginStatusChanged.
(...skipping 19 matching lines...) Expand all
1253 1253
1254 void Shell::OnPrefServiceInitialized( 1254 void Shell::OnPrefServiceInitialized(
1255 std::unique_ptr<::PrefService> pref_service) { 1255 std::unique_ptr<::PrefService> pref_service) {
1256 if (!instance_) 1256 if (!instance_)
1257 return; 1257 return;
1258 DCHECK(pref_service); 1258 DCHECK(pref_service);
1259 pref_service_ = std::move(pref_service); 1259 pref_service_ = std::move(pref_service);
1260 } 1260 }
1261 1261
1262 } // namespace ash 1262 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/wm_shelf.cc ('k') | ash/shell_port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698