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