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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 switches::kUseIMEService)); | 321 switches::kUseIMEService)); |
322 } | 322 } |
323 | 323 |
324 // static | 324 // static |
325 void Shell::RegisterPrefs(PrefRegistrySimple* registry) { | 325 void Shell::RegisterPrefs(PrefRegistrySimple* registry) { |
326 NightLightController::RegisterPrefs(registry); | 326 NightLightController::RegisterPrefs(registry); |
327 } | 327 } |
328 | 328 |
329 // static | 329 // static |
330 bool Shell::ShouldEnableSimplifiedDisplayManagement() { | 330 bool Shell::ShouldEnableSimplifiedDisplayManagement() { |
331 return GetAshConfig() != Config::MASH; | 331 return ShouldEnableSimplifiedDisplayManagement(GetAshConfig()); |
332 } | |
333 | |
334 bool Shell::ShouldEnableSimplifiedDisplayManagement(Config config) { | |
335 return true; | |
332 } | 336 } |
333 | 337 |
334 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( | 338 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
335 views::Widget* widget) { | 339 views::Widget* widget) { |
336 // Use translucent-style window frames for dialogs. | 340 // Use translucent-style window frames for dialogs. |
337 return new CustomFrameViewAsh(widget); | 341 return new CustomFrameViewAsh(widget); |
338 } | 342 } |
339 | 343 |
340 void Shell::SetDisplayWorkAreaInsets(Window* contains, | 344 void Shell::SetDisplayWorkAreaInsets(Window* contains, |
341 const gfx::Insets& insets) { | 345 const gfx::Insets& insets) { |
(...skipping 23 matching lines...) Expand all Loading... | |
365 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 369 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
366 for (RootWindowControllerList::iterator iter = controllers.begin(); | 370 for (RootWindowControllerList::iterator iter = controllers.begin(); |
367 iter != controllers.end(); ++iter) { | 371 iter != controllers.end(); ++iter) { |
368 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); | 372 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
369 } | 373 } |
370 } | 374 } |
371 keyboard::KeyboardController::ResetInstance(nullptr); | 375 keyboard::KeyboardController::ResetInstance(nullptr); |
372 } | 376 } |
373 | 377 |
374 bool Shell::ShouldSaveDisplaySettings() { | 378 bool Shell::ShouldSaveDisplaySettings() { |
379 // This function is only called from Chrome, hence the DCHECK for not-MASH. | |
375 DCHECK(GetAshConfig() != Config::MASH); | 380 DCHECK(GetAshConfig() != Config::MASH); |
376 return !( | 381 return !( |
377 screen_orientation_controller_->ignore_display_configuration_updates() || | 382 screen_orientation_controller_->ignore_display_configuration_updates() || |
378 resolution_notification_controller_->DoesNotificationTimeout()); | 383 resolution_notification_controller_->DoesNotificationTimeout()); |
379 } | 384 } |
380 | 385 |
381 ShelfModel* Shell::shelf_model() { | 386 ShelfModel* Shell::shelf_model() { |
382 return shelf_controller_->model(); | 387 return shelf_controller_->model(); |
383 } | 388 } |
384 | 389 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 display_configurator_(new display::DisplayConfigurator()), | 590 display_configurator_(new display::DisplayConfigurator()), |
586 native_cursor_manager_(nullptr), | 591 native_cursor_manager_(nullptr), |
587 simulate_modal_window_open_for_testing_(false), | 592 simulate_modal_window_open_for_testing_(false), |
588 is_touch_hud_projection_enabled_(false) { | 593 is_touch_hud_projection_enabled_(false) { |
589 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 594 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
590 // state on ShellPortClassic. http://crbug.com/671246. | 595 // state on ShellPortClassic. http://crbug.com/671246. |
591 | 596 |
592 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | 597 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); |
593 | 598 |
594 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. | 599 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. |
595 if (shell_port_->GetAshConfig() != Config::MASH) { | 600 if (ShouldEnableSimplifiedDisplayManagement(shell_port_->GetAshConfig())) { |
596 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 601 display_manager_.reset(ScreenAsh::CreateDisplayManager()); |
597 window_tree_host_manager_.reset(new WindowTreeHostManager); | 602 window_tree_host_manager_.reset(new WindowTreeHostManager); |
598 user_metrics_recorder_.reset(new UserMetricsRecorder); | 603 user_metrics_recorder_.reset(new UserMetricsRecorder); |
599 } | 604 } |
600 | 605 |
601 PowerStatus::Initialize(); | 606 PowerStatus::Initialize(); |
602 | 607 |
603 session_controller_->AddObserver(this); | 608 session_controller_->AddObserver(this); |
604 } | 609 } |
605 | 610 |
(...skipping 22 matching lines...) Expand all Loading... | |
628 RemovePreTargetHandler(speech_feedback_handler_.get()); | 633 RemovePreTargetHandler(speech_feedback_handler_.get()); |
629 speech_feedback_handler_.reset(); | 634 speech_feedback_handler_.reset(); |
630 | 635 |
631 RemovePreTargetHandler(overlay_filter_.get()); | 636 RemovePreTargetHandler(overlay_filter_.get()); |
632 overlay_filter_.reset(); | 637 overlay_filter_.reset(); |
633 | 638 |
634 RemovePreTargetHandler(accelerator_filter_.get()); | 639 RemovePreTargetHandler(accelerator_filter_.get()); |
635 RemovePreTargetHandler(event_transformation_handler_.get()); | 640 RemovePreTargetHandler(event_transformation_handler_.get()); |
636 RemovePreTargetHandler(toplevel_window_event_handler_.get()); | 641 RemovePreTargetHandler(toplevel_window_event_handler_.get()); |
637 RemovePostTargetHandler(toplevel_window_event_handler_.get()); | 642 RemovePostTargetHandler(toplevel_window_event_handler_.get()); |
638 if (config != Config::MASH) { | 643 if (ShouldEnableSimplifiedDisplayManagement()) { |
639 RemovePreTargetHandler(system_gesture_filter_.get()); | 644 RemovePreTargetHandler(system_gesture_filter_.get()); |
640 RemovePreTargetHandler(mouse_cursor_filter_.get()); | 645 RemovePreTargetHandler(mouse_cursor_filter_.get()); |
641 } | 646 } |
642 RemovePreTargetHandler(modality_filter_.get()); | 647 RemovePreTargetHandler(modality_filter_.get()); |
643 | 648 |
644 // TooltipController is deleted with the Shell so removing its references. | 649 // TooltipController is deleted with the Shell so removing its references. |
645 RemovePreTargetHandler(tooltip_controller_.get()); | 650 RemovePreTargetHandler(tooltip_controller_.get()); |
646 | 651 |
647 screen_orientation_controller_.reset(); | 652 screen_orientation_controller_.reset(); |
648 screen_layout_observer_.reset(); | 653 screen_layout_observer_.reset(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 853 window_positioner_ = base::MakeUnique<WindowPositioner>(); |
849 | 854 |
850 if (config == Config::CLASSIC) { | 855 if (config == Config::CLASSIC) { |
851 // TODO: needs to work in mus. http://crbug.com/705592. | 856 // TODO: needs to work in mus. http://crbug.com/705592. |
852 native_cursor_manager_ = new AshNativeCursorManager; | 857 native_cursor_manager_ = new AshNativeCursorManager; |
853 cursor_manager_.reset( | 858 cursor_manager_.reset( |
854 new CursorManager(base::WrapUnique(native_cursor_manager_))); | 859 new CursorManager(base::WrapUnique(native_cursor_manager_))); |
855 } | 860 } |
856 | 861 |
857 shell_delegate_->PreInit(); | 862 shell_delegate_->PreInit(); |
858 // TODO(sky): remove MASH from here. | 863 bool display_initialized = (!ShouldEnableSimplifiedDisplayManagement() || |
859 bool display_initialized = | 864 display_manager_->InitFromCommandLine()); |
860 (config == Config::MASH || display_manager_->InitFromCommandLine()); | 865 if (!display_initialized && config != Config::CLASSIC && |
861 if (config == Config::MUS && !display_initialized) { | 866 ShouldEnableSimplifiedDisplayManagement()) { |
862 // Run display configuration off device in mus mode. | 867 // Run display configuration off device in mus mode. |
863 display_manager_->set_configure_displays(true); | 868 display_manager_->set_configure_displays(true); |
864 display_configurator_->set_configure_display(true); | 869 display_configurator_->set_configure_display(true); |
865 } | 870 } |
866 if (config != Config::MASH) { | 871 if (ShouldEnableSimplifiedDisplayManagement()) { |
867 // TODO(sky): should work in mash too. | |
868 display_configuration_controller_.reset(new DisplayConfigurationController( | 872 display_configuration_controller_.reset(new DisplayConfigurationController( |
869 display_manager_.get(), window_tree_host_manager_.get())); | 873 display_manager_.get(), window_tree_host_manager_.get())); |
870 display_configurator_->Init(shell_port_->CreateNativeDisplayDelegate(), | 874 display_configurator_->Init(shell_port_->CreateNativeDisplayDelegate(), |
871 !gpu_support_->IsPanelFittingDisabled()); | 875 !gpu_support_->IsPanelFittingDisabled()); |
872 } | 876 } |
873 | 877 |
874 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. | 878 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. |
875 chromeos::DBusThreadManager* dbus_thread_manager = | 879 chromeos::DBusThreadManager* dbus_thread_manager = |
876 chromeos::DBusThreadManager::Get(); | 880 chromeos::DBusThreadManager::Get(); |
877 projecting_observer_.reset( | 881 projecting_observer_.reset( |
878 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); | 882 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); |
879 display_configurator_->AddObserver(projecting_observer_.get()); | 883 display_configurator_->AddObserver(projecting_observer_.get()); |
880 AddShellObserver(projecting_observer_.get()); | 884 AddShellObserver(projecting_observer_.get()); |
881 | 885 |
882 // TODO(sky): once simplified display management is enabled for mash | 886 if (!display_initialized && ((config != Config::CLASSIC && |
883 // config == Config::MUS should be config != Config::CLASSIC. | 887 ShouldEnableSimplifiedDisplayManagement()) || |
884 if (!display_initialized && | 888 chromeos::IsRunningAsSystemCompositor())) { |
885 (config == Config::MUS || chromeos::IsRunningAsSystemCompositor())) { | |
886 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( | 889 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( |
887 display_configurator_.get(), display_manager_.get()); | 890 display_configurator_.get(), display_manager_.get()); |
888 | 891 |
889 shutdown_observer_ = | 892 shutdown_observer_ = |
890 base::MakeUnique<ShutdownObserver>(display_configurator_.get()); | 893 base::MakeUnique<ShutdownObserver>(display_configurator_.get()); |
891 | 894 |
892 // Register |display_change_observer_| first so that the rest of | 895 // Register |display_change_observer_| first so that the rest of |
893 // observer gets invoked after the root windows are configured. | 896 // observer gets invoked after the root windows are configured. |
894 display_configurator_->AddObserver(display_change_observer_.get()); | 897 display_configurator_->AddObserver(display_change_observer_.get()); |
895 display_error_observer_.reset(new DisplayErrorObserver()); | 898 display_error_observer_.reset(new DisplayErrorObserver()); |
896 display_configurator_->AddObserver(display_error_observer_.get()); | 899 display_configurator_->AddObserver(display_error_observer_.get()); |
897 display_configurator_->set_state_controller(display_change_observer_.get()); | 900 display_configurator_->set_state_controller(display_change_observer_.get()); |
898 display_configurator_->set_mirroring_controller(display_manager_.get()); | 901 display_configurator_->set_mirroring_controller(display_manager_.get()); |
899 display_configurator_->ForceInitialConfigure( | 902 display_configurator_->ForceInitialConfigure( |
900 base::CommandLine::ForCurrentProcess()->HasSwitch( | 903 base::CommandLine::ForCurrentProcess()->HasSwitch( |
901 chromeos::switches::kFirstExecAfterBoot) | 904 chromeos::switches::kFirstExecAfterBoot) |
902 ? kChromeOsBootColor | 905 ? kChromeOsBootColor |
903 : 0); | 906 : 0); |
904 display_initialized = true; | 907 display_initialized = true; |
905 } | 908 } |
906 display_color_manager_.reset(new DisplayColorManager( | 909 display_color_manager_.reset(new DisplayColorManager( |
907 display_configurator_.get(), init_params.blocking_pool)); | 910 display_configurator_.get(), init_params.blocking_pool)); |
908 | 911 |
909 if (!display_initialized) | 912 if (!display_initialized) |
910 display_manager_->InitDefaultDisplay(); | 913 display_manager_->InitDefaultDisplay(); |
911 | 914 |
912 if (config == Config::CLASSIC) { | 915 // TODO(sky): move this to chrome for mash. |
916 if (ShouldEnableSimplifiedDisplayManagement()) | |
913 display_manager_->RefreshFontParams(); | 917 display_manager_->RefreshFontParams(); |
914 | 918 |
919 if (config == Config::CLASSIC) { | |
915 aura::Env::GetInstance()->set_context_factory(init_params.context_factory); | 920 aura::Env::GetInstance()->set_context_factory(init_params.context_factory); |
916 aura::Env::GetInstance()->set_context_factory_private( | 921 aura::Env::GetInstance()->set_context_factory_private( |
917 init_params.context_factory_private); | 922 init_params.context_factory_private); |
918 } | 923 } |
919 | 924 |
920 // The WindowModalityController needs to be at the front of the input event | 925 // The WindowModalityController needs to be at the front of the input event |
921 // pretarget handler list to ensure that it processes input events when modal | 926 // pretarget handler list to ensure that it processes input events when modal |
922 // windows are active. | 927 // windows are active. |
923 window_modality_controller_.reset(new ::wm::WindowModalityController(this)); | 928 window_modality_controller_.reset(new ::wm::WindowModalityController(this)); |
924 | 929 |
925 env_filter_.reset(new ::wm::CompoundEventFilter); | 930 env_filter_.reset(new ::wm::CompoundEventFilter); |
926 AddPreTargetHandler(env_filter_.get()); | 931 AddPreTargetHandler(env_filter_.get()); |
927 | 932 |
928 // FocusController takes ownership of AshFocusRules. | 933 // FocusController takes ownership of AshFocusRules. |
929 focus_controller_ = | 934 focus_controller_ = |
930 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); | 935 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); |
931 focus_controller_->AddObserver(this); | 936 focus_controller_->AddObserver(this); |
932 if (config != Config::CLASSIC) { | 937 if (config != Config::CLASSIC) { |
933 window_tree_client_->focus_synchronizer()->SetSingletonFocusClient( | 938 window_tree_client_->focus_synchronizer()->SetSingletonFocusClient( |
934 focus_controller_.get()); | 939 focus_controller_.get()); |
935 } | 940 } |
936 | 941 |
937 screen_position_controller_.reset(new ScreenPositionController); | 942 screen_position_controller_.reset(new ScreenPositionController); |
938 | 943 |
939 shell_port_->CreatePrimaryHost(); | 944 shell_port_->CreatePrimaryHost(); |
940 root_window_for_new_windows_ = GetPrimaryRootWindow(); | 945 root_window_for_new_windows_ = GetPrimaryRootWindow(); |
941 | 946 |
942 if (config != Config::MASH) { | 947 if (ShouldEnableSimplifiedDisplayManagement()) { |
943 resolution_notification_controller_.reset( | 948 resolution_notification_controller_.reset( |
msw
2017/05/26 16:38:50
optional nit: base::MakeUnique here and below
sky
2017/06/05 22:37:40
I'm holding off on this.
| |
944 new ResolutionNotificationController); | 949 new ResolutionNotificationController); |
945 } | 950 } |
946 | 951 |
947 if (cursor_manager_) { | 952 if (cursor_manager_) { |
948 cursor_manager_->SetDisplay( | 953 cursor_manager_->SetDisplay( |
949 display::Screen::GetScreen()->GetPrimaryDisplay()); | 954 display::Screen::GetScreen()->GetPrimaryDisplay()); |
950 } | 955 } |
951 | 956 |
952 accelerator_controller_ = shell_port_->CreateAcceleratorController(); | 957 accelerator_controller_ = shell_port_->CreateAcceleratorController(); |
953 maximize_mode_controller_ = base::MakeUnique<MaximizeModeController>(); | 958 maximize_mode_controller_ = base::MakeUnique<MaximizeModeController>(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 } | 1010 } |
1006 | 1011 |
1007 drag_drop_controller_.reset(new DragDropController); | 1012 drag_drop_controller_.reset(new DragDropController); |
1008 // |screenshot_controller_| needs to be created (and prepended as a | 1013 // |screenshot_controller_| needs to be created (and prepended as a |
1009 // pre-target handler) at this point, because |mouse_cursor_filter_| needs to | 1014 // pre-target handler) at this point, because |mouse_cursor_filter_| needs to |
1010 // process mouse events prior to screenshot session. | 1015 // process mouse events prior to screenshot session. |
1011 // See http://crbug.com/459214 | 1016 // See http://crbug.com/459214 |
1012 screenshot_controller_.reset(new ScreenshotController()); | 1017 screenshot_controller_.reset(new ScreenshotController()); |
1013 // TODO: evaluate if MouseCursorEventFilter needs to work for mash. | 1018 // TODO: evaluate if MouseCursorEventFilter needs to work for mash. |
1014 // http://crbug.com/706474. | 1019 // http://crbug.com/706474. |
1015 if (config != Config::MASH) { | 1020 if (ShouldEnableSimplifiedDisplayManagement()) { |
1016 mouse_cursor_filter_.reset(new MouseCursorEventFilter()); | 1021 mouse_cursor_filter_.reset(new MouseCursorEventFilter()); |
1017 PrependPreTargetHandler(mouse_cursor_filter_.get()); | 1022 PrependPreTargetHandler(mouse_cursor_filter_.get()); |
1018 } | 1023 } |
1019 | 1024 |
1020 // Create Controllers that may need root window. | 1025 // Create Controllers that may need root window. |
1021 // TODO(oshima): Move as many controllers before creating | 1026 // TODO(oshima): Move as many controllers before creating |
1022 // RootWindowController as possible. | 1027 // RootWindowController as possible. |
1023 visibility_controller_.reset(new AshVisibilityController); | 1028 visibility_controller_.reset(new AshVisibilityController); |
1024 | 1029 |
1025 laser_pointer_controller_.reset(new LaserPointerController()); | 1030 laser_pointer_controller_.reset(new LaserPointerController()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1088 cursor_manager_->HideCursor(); | 1093 cursor_manager_->HideCursor(); |
1089 cursor_manager_->SetCursor(ui::CursorType::kPointer); | 1094 cursor_manager_->SetCursor(ui::CursorType::kPointer); |
1090 } | 1095 } |
1091 | 1096 |
1092 power_event_observer_.reset(new PowerEventObserver()); | 1097 power_event_observer_.reset(new PowerEventObserver()); |
1093 user_activity_notifier_.reset( | 1098 user_activity_notifier_.reset( |
1094 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); | 1099 new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); |
1095 video_activity_notifier_.reset( | 1100 video_activity_notifier_.reset( |
1096 new VideoActivityNotifier(video_detector_.get())); | 1101 new VideoActivityNotifier(video_detector_.get())); |
1097 bluetooth_notification_controller_.reset(new BluetoothNotificationController); | 1102 bluetooth_notification_controller_.reset(new BluetoothNotificationController); |
1098 if (config != Config::MASH) { | 1103 if (ShouldEnableSimplifiedDisplayManagement()) { |
1099 screen_orientation_controller_.reset(new ScreenOrientationController()); | 1104 screen_orientation_controller_.reset(new ScreenOrientationController()); |
1100 screen_layout_observer_.reset(new ScreenLayoutObserver()); | 1105 screen_layout_observer_.reset(new ScreenLayoutObserver()); |
1101 } | 1106 } |
1102 sms_observer_.reset(new SmsObserver()); | 1107 sms_observer_.reset(new SmsObserver()); |
1103 | 1108 |
1104 // The compositor thread and main message loop have to be running in | 1109 // The compositor thread and main message loop have to be running in |
1105 // order to create mirror window. Run it after the main message loop | 1110 // order to create mirror window. Run it after the main message loop |
1106 // is started. | 1111 // is started. |
1107 if (config != Config::MASH) | 1112 if (ShouldEnableSimplifiedDisplayManagement()) |
1108 display_manager_->CreateMirrorWindowAsyncIfAny(); | 1113 display_manager_->CreateMirrorWindowAsyncIfAny(); |
1109 | 1114 |
1110 for (auto& observer : shell_observers_) | 1115 for (auto& observer : shell_observers_) |
1111 observer.OnShellInitialized(); | 1116 observer.OnShellInitialized(); |
1112 | 1117 |
1113 if (config != Config::MASH) | 1118 if (config != Config::MASH) |
1114 user_metrics_recorder_->OnShellInitialized(); | 1119 user_metrics_recorder_->OnShellInitialized(); |
1115 } | 1120 } |
1116 | 1121 |
1117 void Shell::InitKeyboard() { | 1122 void Shell::InitKeyboard() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1269 void Shell::OnPrefServiceInitialized( | 1274 void Shell::OnPrefServiceInitialized( |
1270 std::unique_ptr<::PrefService> pref_service) { | 1275 std::unique_ptr<::PrefService> pref_service) { |
1271 if (!instance_) | 1276 if (!instance_) |
1272 return; | 1277 return; |
1273 // |pref_service_| is null if can't connect to Chrome (as happens when | 1278 // |pref_service_| is null if can't connect to Chrome (as happens when |
1274 // running mash outside of chrome --mash and chrome isn't built). | 1279 // running mash outside of chrome --mash and chrome isn't built). |
1275 pref_service_ = std::move(pref_service); | 1280 pref_service_ = std::move(pref_service); |
1276 } | 1281 } |
1277 | 1282 |
1278 } // namespace ash | 1283 } // namespace ash |
OLD | NEW |