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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 #include "ui/base/ui_base_switches.h" | 145 #include "ui/base/ui_base_switches.h" |
146 #include "ui/base/user_activity/user_activity_detector.h" | 146 #include "ui/base/user_activity/user_activity_detector.h" |
147 #include "ui/chromeos/user_activity_power_manager_notifier.h" | 147 #include "ui/chromeos/user_activity_power_manager_notifier.h" |
148 #include "ui/compositor/layer.h" | 148 #include "ui/compositor/layer.h" |
149 #include "ui/compositor/layer_animator.h" | 149 #include "ui/compositor/layer_animator.h" |
150 #include "ui/display/display.h" | 150 #include "ui/display/display.h" |
151 #include "ui/display/manager/chromeos/display_change_observer.h" | 151 #include "ui/display/manager/chromeos/display_change_observer.h" |
152 #include "ui/display/manager/chromeos/display_configurator.h" | 152 #include "ui/display/manager/chromeos/display_configurator.h" |
153 #include "ui/display/manager/display_manager.h" | 153 #include "ui/display/manager/display_manager.h" |
154 #include "ui/display/screen.h" | 154 #include "ui/display/screen.h" |
| 155 #include "ui/display/types/native_display_delegate.h" |
155 #include "ui/events/event_target_iterator.h" | 156 #include "ui/events/event_target_iterator.h" |
156 #include "ui/gfx/geometry/insets.h" | 157 #include "ui/gfx/geometry/insets.h" |
157 #include "ui/gfx/image/image_skia.h" | 158 #include "ui/gfx/image/image_skia.h" |
158 #include "ui/keyboard/keyboard_controller.h" | 159 #include "ui/keyboard/keyboard_controller.h" |
159 #include "ui/keyboard/keyboard_switches.h" | 160 #include "ui/keyboard/keyboard_switches.h" |
160 #include "ui/keyboard/keyboard_util.h" | 161 #include "ui/keyboard/keyboard_util.h" |
161 #include "ui/views/corewm/tooltip_aura.h" | 162 #include "ui/views/corewm/tooltip_aura.h" |
162 #include "ui/views/corewm/tooltip_controller.h" | 163 #include "ui/views/corewm/tooltip_controller.h" |
163 #include "ui/views/focus/focus_manager_factory.h" | 164 #include "ui/views/focus/focus_manager_factory.h" |
164 #include "ui/views/widget/native_widget_aura.h" | 165 #include "ui/views/widget/native_widget_aura.h" |
165 #include "ui/views/widget/widget.h" | 166 #include "ui/views/widget/widget.h" |
166 #include "ui/wm/core/accelerator_filter.h" | 167 #include "ui/wm/core/accelerator_filter.h" |
167 #include "ui/wm/core/compound_event_filter.h" | 168 #include "ui/wm/core/compound_event_filter.h" |
168 #include "ui/wm/core/focus_controller.h" | 169 #include "ui/wm/core/focus_controller.h" |
169 #include "ui/wm/core/shadow_controller.h" | 170 #include "ui/wm/core/shadow_controller.h" |
170 #include "ui/wm/core/visibility_controller.h" | 171 #include "ui/wm/core/visibility_controller.h" |
171 #include "ui/wm/core/window_modality_controller.h" | 172 #include "ui/wm/core/window_modality_controller.h" |
172 | 173 |
173 #if defined(USE_X11) | |
174 #include "ui/display/manager/chromeos/x11/native_display_delegate_x11.h" | |
175 #include "ui/gfx/x/x11_types.h" // nogncheck | |
176 #endif | |
177 | |
178 #if defined(USE_OZONE) | |
179 #include "ui/display/types/native_display_delegate.h" | |
180 #include "ui/ozone/public/ozone_platform.h" | |
181 #endif | |
182 | |
183 namespace ash { | 174 namespace ash { |
184 | 175 |
185 namespace { | 176 namespace { |
186 | 177 |
187 using aura::Window; | 178 using aura::Window; |
188 using views::Widget; | 179 using views::Widget; |
189 | 180 |
190 // A Corewm VisibilityController subclass that calls the Ash animation routine | 181 // A Corewm VisibilityController subclass that calls the Ash animation routine |
191 // so we can pick up our extended animations. See ash/wm/window_animations.h. | 182 // so we can pick up our extended animations. See ash/wm/window_animations.h. |
192 class AshVisibilityController : public ::wm::VisibilityController { | 183 class AshVisibilityController : public ::wm::VisibilityController { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 app_list_(base::MakeUnique<app_list::AppList>()), | 554 app_list_(base::MakeUnique<app_list::AppList>()), |
564 link_handler_model_factory_(nullptr), | 555 link_handler_model_factory_(nullptr), |
565 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), | 556 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), |
566 display_configurator_(new display::DisplayConfigurator()), | 557 display_configurator_(new display::DisplayConfigurator()), |
567 native_cursor_manager_(nullptr), | 558 native_cursor_manager_(nullptr), |
568 simulate_modal_window_open_for_testing_(false), | 559 simulate_modal_window_open_for_testing_(false), |
569 is_touch_hud_projection_enabled_(false) { | 560 is_touch_hud_projection_enabled_(false) { |
570 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 561 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
571 // state on ShellPortClassic. http://crbug.com/671246. | 562 // state on ShellPortClassic. http://crbug.com/671246. |
572 | 563 |
| 564 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); |
| 565 |
573 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. | 566 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. |
574 if (shell_port_->GetAshConfig() != Config::MASH) { | 567 if (shell_port_->GetAshConfig() != Config::MASH) { |
575 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | |
576 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 568 display_manager_.reset(ScreenAsh::CreateDisplayManager()); |
577 window_tree_host_manager_.reset(new WindowTreeHostManager); | 569 window_tree_host_manager_.reset(new WindowTreeHostManager); |
578 user_metrics_recorder_.reset(new UserMetricsRecorder); | 570 user_metrics_recorder_.reset(new UserMetricsRecorder); |
579 } | 571 } |
580 | 572 |
581 PowerStatus::Initialize(); | 573 PowerStatus::Initialize(); |
582 | 574 |
583 session_controller_->AddObserver(this); | 575 session_controller_->AddObserver(this); |
584 } | 576 } |
585 | 577 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 817 window_positioner_ = base::MakeUnique<WindowPositioner>(); |
826 | 818 |
827 if (config == Config::CLASSIC) { | 819 if (config == Config::CLASSIC) { |
828 // TODO: needs to work in mus. http://crbug.com/705592. | 820 // TODO: needs to work in mus. http://crbug.com/705592. |
829 native_cursor_manager_ = new AshNativeCursorManager; | 821 native_cursor_manager_ = new AshNativeCursorManager; |
830 cursor_manager_.reset( | 822 cursor_manager_.reset( |
831 new CursorManager(base::WrapUnique(native_cursor_manager_))); | 823 new CursorManager(base::WrapUnique(native_cursor_manager_))); |
832 } | 824 } |
833 | 825 |
834 shell_delegate_->PreInit(); | 826 shell_delegate_->PreInit(); |
835 bool display_initialized = true; | 827 // TODO(sky): remove MASH from here. |
836 if (config == Config::CLASSIC) { | 828 bool display_initialized = (config == Config::MASH || |
837 // TODO: decide if this needs to be made to work in Config::MUS. | 829 (config == Config::CLASSIC && |
838 // http://crbug.com/705595. | 830 display_manager_->InitFromCommandLine())); |
839 display_initialized = display_manager_->InitFromCommandLine(); | 831 if (config == Config::MUS) { |
840 | 832 // Run display configuration off device in mus mode. |
| 833 display_manager_->set_configure_displays(true); |
| 834 display_configurator_->set_configure_display(true); |
| 835 } |
| 836 if (config != Config::MASH) { |
| 837 // TODO(sky): should work in mash too. |
841 display_configuration_controller_.reset(new DisplayConfigurationController( | 838 display_configuration_controller_.reset(new DisplayConfigurationController( |
842 display_manager_.get(), window_tree_host_manager_.get())); | 839 display_manager_.get(), window_tree_host_manager_.get())); |
843 | 840 display_configurator_->Init(shell_port_->CreateNativeDisplayDelegate(), |
844 #if defined(USE_OZONE) | 841 !gpu_support_->IsPanelFittingDisabled()); |
845 display_configurator_->Init( | |
846 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), | |
847 !gpu_support_->IsPanelFittingDisabled()); | |
848 #elif defined(USE_X11) | |
849 display_configurator_->Init( | |
850 base::MakeUnique<display::NativeDisplayDelegateX11>(), | |
851 !gpu_support_->IsPanelFittingDisabled()); | |
852 #endif | |
853 } | 842 } |
854 | 843 |
855 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. | 844 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. |
856 chromeos::DBusThreadManager* dbus_thread_manager = | 845 chromeos::DBusThreadManager* dbus_thread_manager = |
857 chromeos::DBusThreadManager::Get(); | 846 chromeos::DBusThreadManager::Get(); |
858 projecting_observer_.reset( | 847 projecting_observer_.reset( |
859 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); | 848 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); |
860 display_configurator_->AddObserver(projecting_observer_.get()); | 849 display_configurator_->AddObserver(projecting_observer_.get()); |
861 AddShellObserver(projecting_observer_.get()); | 850 AddShellObserver(projecting_observer_.get()); |
862 | 851 |
| 852 // TODO(sky): config == Config::MUS should be config == Config::MASH. |
| 853 // XXX WANT! |
| 854 // if (!display_initialized && |
| 855 // (config == Config::MUS || |
| 856 // chromeos::IsRunningAsSystemCompositor())) { |
863 if (!display_initialized && chromeos::IsRunningAsSystemCompositor()) { | 857 if (!display_initialized && chromeos::IsRunningAsSystemCompositor()) { |
864 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( | 858 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( |
865 display_configurator_.get(), display_manager_.get()); | 859 display_configurator_.get(), display_manager_.get()); |
866 | 860 |
867 shutdown_observer_ = | 861 shutdown_observer_ = |
868 base::MakeUnique<ShutdownObserver>(display_configurator_.get()); | 862 base::MakeUnique<ShutdownObserver>(display_configurator_.get()); |
869 | 863 |
870 // Register |display_change_observer_| first so that the rest of | 864 // Register |display_change_observer_| first so that the rest of |
871 // observer gets invoked after the root windows are configured. | 865 // observer gets invoked after the root windows are configured. |
872 display_configurator_->AddObserver(display_change_observer_.get()); | 866 display_configurator_->AddObserver(display_change_observer_.get()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 std::unique_ptr<::wm::AcceleratorDelegate>(new AcceleratorDelegate), | 945 std::unique_ptr<::wm::AcceleratorDelegate>(new AcceleratorDelegate), |
952 accelerator_controller_->accelerator_history())); | 946 accelerator_controller_->accelerator_history())); |
953 AddPreTargetHandler(accelerator_filter_.get()); | 947 AddPreTargetHandler(accelerator_filter_.get()); |
954 | 948 |
955 event_transformation_handler_.reset(new EventTransformationHandler); | 949 event_transformation_handler_.reset(new EventTransformationHandler); |
956 AddPreTargetHandler(event_transformation_handler_.get()); | 950 AddPreTargetHandler(event_transformation_handler_.get()); |
957 | 951 |
958 toplevel_window_event_handler_ = | 952 toplevel_window_event_handler_ = |
959 base::MakeUnique<ToplevelWindowEventHandler>(); | 953 base::MakeUnique<ToplevelWindowEventHandler>(); |
960 | 954 |
961 // TODO: get working in Config::MUS. This uses InputDeviceManager, which is | 955 if (config != Config::MASH) { |
962 // not created in mus. http://crbug.com/712290. | |
963 if (config == Config::CLASSIC) { | |
964 system_gesture_filter_.reset(new SystemGestureEventFilter); | 956 system_gesture_filter_.reset(new SystemGestureEventFilter); |
965 AddPreTargetHandler(system_gesture_filter_.get()); | 957 AddPreTargetHandler(system_gesture_filter_.get()); |
966 } | 958 } |
967 | 959 |
968 sticky_keys_controller_.reset(new StickyKeysController); | 960 sticky_keys_controller_.reset(new StickyKeysController); |
969 screen_pinning_controller_ = base::MakeUnique<ScreenPinningController>(); | 961 screen_pinning_controller_ = base::MakeUnique<ScreenPinningController>(); |
970 | 962 |
971 lock_state_controller_ = | 963 lock_state_controller_ = |
972 base::MakeUnique<LockStateController>(shutdown_controller_.get()); | 964 base::MakeUnique<LockStateController>(shutdown_controller_.get()); |
973 power_button_controller_.reset( | 965 power_button_controller_.reset( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 SetSystemTrayDelegate( | 1026 SetSystemTrayDelegate( |
1035 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); | 1027 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); |
1036 | 1028 |
1037 // May trigger initialization of the Bluetooth adapter. | 1029 // May trigger initialization of the Bluetooth adapter. |
1038 tray_bluetooth_helper_->Initialize(); | 1030 tray_bluetooth_helper_->Initialize(); |
1039 | 1031 |
1040 // Create AshTouchTransformController before | 1032 // Create AshTouchTransformController before |
1041 // WindowTreeHostManager::InitDisplays() | 1033 // WindowTreeHostManager::InitDisplays() |
1042 // since AshTouchTransformController listens on | 1034 // since AshTouchTransformController listens on |
1043 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). | 1035 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). |
1044 if (config != Config::MASH) { | 1036 // TODO(sky): needs to to work for mus too. |
| 1037 if (config == Config::CLASSIC) { |
1045 touch_transformer_controller_.reset(new AshTouchTransformController( | 1038 touch_transformer_controller_.reset(new AshTouchTransformController( |
1046 display_configurator_.get(), display_manager_.get())); | 1039 display_configurator_.get(), display_manager_.get())); |
1047 } | 1040 } |
1048 | 1041 |
1049 keyboard_ui_ = shell_port_->CreateKeyboardUI(); | 1042 keyboard_ui_ = shell_port_->CreateKeyboardUI(); |
1050 | 1043 |
1051 shell_port_->InitHosts(init_params); | 1044 shell_port_->InitHosts(init_params); |
1052 | 1045 |
1053 // Needs to be created after InitDisplays() since it may cause the virtual | 1046 // Needs to be created after InitDisplays() since it may cause the virtual |
1054 // keyboard to be deployed. | 1047 // keyboard to be deployed. |
1055 // TODO: get working in Config::MUS. This uses InputDeviceManager, which is | 1048 if (config != Config::MASH) |
1056 // not created in mus. http://crbug.com/712290. | |
1057 if (config == Config::CLASSIC) | |
1058 virtual_keyboard_controller_.reset(new VirtualKeyboardController); | 1049 virtual_keyboard_controller_.reset(new VirtualKeyboardController); |
1059 | 1050 |
1060 audio_a11y_controller_.reset(new chromeos::AudioA11yController); | 1051 audio_a11y_controller_.reset(new chromeos::AudioA11yController); |
1061 | 1052 |
1062 // Initialize the wallpaper after the RootWindowController has been created, | 1053 // Initialize the wallpaper after the RootWindowController has been created, |
1063 // otherwise the widget will not paint when restoring after a browser crash. | 1054 // otherwise the widget will not paint when restoring after a browser crash. |
1064 // Also, initialize after display initialization to ensure correct sizing. | 1055 // Also, initialize after display initialization to ensure correct sizing. |
1065 wallpaper_delegate_->InitializeWallpaper(); | 1056 wallpaper_delegate_->InitializeWallpaper(); |
1066 | 1057 |
1067 if (cursor_manager_) { | 1058 if (cursor_manager_) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 void Shell::OnPrefServiceInitialized( | 1227 void Shell::OnPrefServiceInitialized( |
1237 std::unique_ptr<::PrefService> pref_service) { | 1228 std::unique_ptr<::PrefService> pref_service) { |
1238 if (!instance_) | 1229 if (!instance_) |
1239 return; | 1230 return; |
1240 // |pref_service_| is null if can't connect to Chrome (as happens when | 1231 // |pref_service_| is null if can't connect to Chrome (as happens when |
1241 // running mash outside of chrome --mash and chrome isn't built). | 1232 // running mash outside of chrome --mash and chrome isn't built). |
1242 pref_service_ = std::move(pref_service); | 1233 pref_service_ = std::move(pref_service); |
1243 } | 1234 } |
1244 | 1235 |
1245 } // namespace ash | 1236 } // namespace ash |
OLD | NEW |