| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #include "ash/display/screen_position_controller.h" | 83 #include "ash/display/screen_position_controller.h" |
| 84 #include "ash/display/shutdown_observer_chromeos.h" | 84 #include "ash/display/shutdown_observer_chromeos.h" |
| 85 #include "ash/display/window_tree_host_manager.h" | 85 #include "ash/display/window_tree_host_manager.h" |
| 86 #include "ash/drag_drop/drag_drop_controller.h" | 86 #include "ash/drag_drop/drag_drop_controller.h" |
| 87 #include "ash/first_run/first_run_helper_impl.h" | 87 #include "ash/first_run/first_run_helper_impl.h" |
| 88 #include "ash/high_contrast/high_contrast_controller.h" | 88 #include "ash/high_contrast/high_contrast_controller.h" |
| 89 #include "ash/ime/input_method_event_handler.h" | 89 #include "ash/ime/input_method_event_handler.h" |
| 90 #include "ash/laser/laser_pointer_controller.h" | 90 #include "ash/laser/laser_pointer_controller.h" |
| 91 #include "ash/magnifier/magnification_controller.h" | 91 #include "ash/magnifier/magnification_controller.h" |
| 92 #include "ash/magnifier/partial_magnification_controller.h" | 92 #include "ash/magnifier/partial_magnification_controller.h" |
| 93 #include "ash/public/cpp/config.h" |
| 93 #include "ash/public/cpp/shell_window_ids.h" | 94 #include "ash/public/cpp/shell_window_ids.h" |
| 94 #include "ash/root_window_controller.h" | 95 #include "ash/root_window_controller.h" |
| 95 #include "ash/shell_init_params.h" | 96 #include "ash/shell_init_params.h" |
| 96 #include "ash/sticky_keys/sticky_keys_controller.h" | 97 #include "ash/sticky_keys/sticky_keys_controller.h" |
| 97 #include "ash/system/chromeos/power/power_event_observer.h" | 98 #include "ash/system/chromeos/power/power_event_observer.h" |
| 98 #include "ash/system/chromeos/power/video_activity_notifier.h" | 99 #include "ash/system/chromeos/power/video_activity_notifier.h" |
| 99 #include "ash/system/chromeos/screen_layout_observer.h" | 100 #include "ash/system/chromeos/screen_layout_observer.h" |
| 100 #include "ash/touch/ash_touch_transform_controller.h" | 101 #include "ash/touch/ash_touch_transform_controller.h" |
| 101 #include "ash/utility/screenshot_controller.h" | 102 #include "ash/utility/screenshot_controller.h" |
| 102 #include "ash/virtual_keyboard_controller.h" | 103 #include "ash/virtual_keyboard_controller.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { | 303 aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { |
| 303 return root_window->GetChildById(container_id); | 304 return root_window->GetChildById(container_id); |
| 304 } | 305 } |
| 305 | 306 |
| 306 // static | 307 // static |
| 307 const aura::Window* Shell::GetContainer(const aura::Window* root_window, | 308 const aura::Window* Shell::GetContainer(const aura::Window* root_window, |
| 308 int container_id) { | 309 int container_id) { |
| 309 return root_window->GetChildById(container_id); | 310 return root_window->GetChildById(container_id); |
| 310 } | 311 } |
| 311 | 312 |
| 313 // static |
| 314 Config Shell::GetConfig() { |
| 315 return GetInstance()->wm_shell_->GetConfig(); |
| 316 } |
| 317 |
| 312 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( | 318 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 313 views::Widget* widget) { | 319 views::Widget* widget) { |
| 314 // Use translucent-style window frames for dialogs. | 320 // Use translucent-style window frames for dialogs. |
| 315 return new CustomFrameViewAsh(widget); | 321 return new CustomFrameViewAsh(widget); |
| 316 } | 322 } |
| 317 | 323 |
| 318 void Shell::SetDisplayWorkAreaInsets(Window* contains, | 324 void Shell::SetDisplayWorkAreaInsets(Window* contains, |
| 319 const gfx::Insets& insets) { | 325 const gfx::Insets& insets) { |
| 320 wm_shell_->SetDisplayWorkAreaInsets(WmWindow::Get(contains), insets); | 326 wm_shell_->SetDisplayWorkAreaInsets(WmWindow::Get(contains), insets); |
| 321 } | 327 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 for (WmWindow* root_window : wm_shell_->GetAllRootWindows()) | 435 for (WmWindow* root_window : wm_shell_->GetAllRootWindows()) |
| 430 root_window->GetRootWindowController()->CreateShelfView(); | 436 root_window->GetRootWindowController()->CreateShelfView(); |
| 431 } | 437 } |
| 432 | 438 |
| 433 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { | 439 void Shell::SetLargeCursorSizeInDip(int large_cursor_size_in_dip) { |
| 434 window_tree_host_manager_->cursor_window_controller() | 440 window_tree_host_manager_->cursor_window_controller() |
| 435 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); | 441 ->SetLargeCursorSizeInDip(large_cursor_size_in_dip); |
| 436 } | 442 } |
| 437 | 443 |
| 438 void Shell::SetCursorCompositingEnabled(bool enabled) { | 444 void Shell::SetCursorCompositingEnabled(bool enabled) { |
| 439 window_tree_host_manager_->cursor_window_controller() | 445 if (GetConfig() == Config::CLASSIC) { |
| 440 ->SetCursorCompositingEnabled(enabled); | 446 // TODO: needs to work in mus. http://crbug.com/705592. |
| 441 native_cursor_manager_->SetNativeCursorEnabled(!enabled); | 447 window_tree_host_manager_->cursor_window_controller() |
| 448 ->SetCursorCompositingEnabled(enabled); |
| 449 native_cursor_manager_->SetNativeCursorEnabled(!enabled); |
| 450 } |
| 442 } | 451 } |
| 443 | 452 |
| 444 void Shell::DoInitialWorkspaceAnimation() { | 453 void Shell::DoInitialWorkspaceAnimation() { |
| 445 return GetPrimaryRootWindowController() | 454 return GetPrimaryRootWindowController() |
| 446 ->workspace_controller() | 455 ->workspace_controller() |
| 447 ->DoInitialAnimation(); | 456 ->DoInitialAnimation(); |
| 448 } | 457 } |
| 449 | 458 |
| 450 void Shell::AddShellObserver(ShellObserver* observer) { | 459 void Shell::AddShellObserver(ShellObserver* observer) { |
| 451 shell_observers_.AddObserver(observer); | 460 shell_observers_.AddObserver(observer); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 wallpaper_delegate_.reset(); | 780 wallpaper_delegate_.reset(); |
| 772 pref_store_ = nullptr; | 781 pref_store_ = nullptr; |
| 773 shell_delegate_.reset(); | 782 shell_delegate_.reset(); |
| 774 | 783 |
| 775 DCHECK(instance_ == this); | 784 DCHECK(instance_ == this); |
| 776 instance_ = nullptr; | 785 instance_ = nullptr; |
| 777 } | 786 } |
| 778 | 787 |
| 779 void Shell::Init(const ShellInitParams& init_params) { | 788 void Shell::Init(const ShellInitParams& init_params) { |
| 780 const bool is_mash = wm_shell_->IsRunningInMash(); | 789 const bool is_mash = wm_shell_->IsRunningInMash(); |
| 790 const Config config = wm_shell_->GetConfig(); |
| 781 | 791 |
| 782 blocking_pool_ = init_params.blocking_pool; | 792 blocking_pool_ = init_params.blocking_pool; |
| 783 | 793 |
| 784 wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate(); | 794 wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate(); |
| 785 | 795 |
| 786 // Can be null in tests. | 796 // Can be null in tests. |
| 787 if (shell_delegate_->GetShellConnector()) { | 797 if (shell_delegate_->GetShellConnector()) { |
| 788 prefs::mojom::PreferencesServiceFactoryPtr pref_factory_ptr; | 798 prefs::mojom::PreferencesServiceFactoryPtr pref_factory_ptr; |
| 789 shell_delegate_->GetShellConnector()->BindInterface( | 799 shell_delegate_->GetShellConnector()->BindInterface( |
| 790 prefs::mojom::kServiceName, &pref_factory_ptr); | 800 prefs::mojom::kServiceName, &pref_factory_ptr); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 820 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); | 830 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); |
| 821 | 831 |
| 822 // TODO(sky): move creation to WmShell. | 832 // TODO(sky): move creation to WmShell. |
| 823 if (!is_mash) | 833 if (!is_mash) |
| 824 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 834 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); |
| 825 | 835 |
| 826 scoped_overview_animation_settings_factory_.reset( | 836 scoped_overview_animation_settings_factory_.reset( |
| 827 new ScopedOverviewAnimationSettingsFactoryAura); | 837 new ScopedOverviewAnimationSettingsFactoryAura); |
| 828 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 838 window_positioner_ = base::MakeUnique<WindowPositioner>(); |
| 829 | 839 |
| 830 if (!is_mash) { | 840 if (config == Config::CLASSIC) { |
| 841 // TODO: needs to work in mus. http://crbug.com/705592. |
| 831 native_cursor_manager_ = new AshNativeCursorManager; | 842 native_cursor_manager_ = new AshNativeCursorManager; |
| 832 cursor_manager_.reset( | 843 cursor_manager_.reset( |
| 833 new CursorManager(base::WrapUnique(native_cursor_manager_))); | 844 new CursorManager(base::WrapUnique(native_cursor_manager_))); |
| 834 } | 845 } |
| 835 | 846 |
| 836 shell_delegate_->PreInit(); | 847 shell_delegate_->PreInit(); |
| 837 bool display_initialized = true; | 848 bool display_initialized = true; |
| 838 if (!is_mash) { | 849 if (config == Config::CLASSIC) { |
| 850 // TODO: decide if this needs to be made to work in Config::MUS. |
| 851 // http://crbug.com/705595. |
| 839 display_initialized = display_manager_->InitFromCommandLine(); | 852 display_initialized = display_manager_->InitFromCommandLine(); |
| 840 | 853 |
| 841 display_configuration_controller_.reset(new DisplayConfigurationController( | 854 display_configuration_controller_.reset(new DisplayConfigurationController( |
| 842 display_manager_.get(), window_tree_host_manager_.get())); | 855 display_manager_.get(), window_tree_host_manager_.get())); |
| 843 | 856 |
| 844 #if defined(USE_OZONE) | 857 #if defined(USE_OZONE) |
| 845 display_configurator_->Init( | 858 display_configurator_->Init( |
| 846 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), | 859 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), |
| 847 !gpu_support_->IsPanelFittingDisabled()); | 860 !gpu_support_->IsPanelFittingDisabled()); |
| 848 #elif defined(USE_X11) | 861 #elif defined(USE_X11) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 } | 932 } |
| 920 | 933 |
| 921 if (cursor_manager_) { | 934 if (cursor_manager_) { |
| 922 cursor_manager_->SetDisplay( | 935 cursor_manager_->SetDisplay( |
| 923 display::Screen::GetScreen()->GetPrimaryDisplay()); | 936 display::Screen::GetScreen()->GetPrimaryDisplay()); |
| 924 } | 937 } |
| 925 | 938 |
| 926 accelerator_controller_ = wm_shell_->CreateAcceleratorController(); | 939 accelerator_controller_ = wm_shell_->CreateAcceleratorController(); |
| 927 maximize_mode_controller_ = base::MakeUnique<MaximizeModeController>(); | 940 maximize_mode_controller_ = base::MakeUnique<MaximizeModeController>(); |
| 928 | 941 |
| 929 if (!is_mash) { | 942 if (config == Config::CLASSIC) { |
| 943 // Not applicable to mus/mash as events are already routed to InputMethod |
| 944 // first. |
| 930 AddPreTargetHandler( | 945 AddPreTargetHandler( |
| 931 window_tree_host_manager_->input_method_event_handler()); | 946 window_tree_host_manager_->input_method_event_handler()); |
| 932 } | 947 } |
| 933 | 948 |
| 934 magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); | 949 magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); |
| 935 AddPreTargetHandler(magnifier_key_scroll_handler_.get()); | 950 AddPreTargetHandler(magnifier_key_scroll_handler_.get()); |
| 936 speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler(); | 951 speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler(); |
| 937 AddPreTargetHandler(speech_feedback_handler_.get()); | 952 AddPreTargetHandler(speech_feedback_handler_.get()); |
| 938 | 953 |
| 939 // The order in which event filters are added is significant. | 954 // The order in which event filters are added is significant. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 | 1244 |
| 1230 // Only trigger an update in mash because with classic ash chrome calls | 1245 // Only trigger an update in mash because with classic ash chrome calls |
| 1231 // UpdateAfterLoginStatusChange() directly. | 1246 // UpdateAfterLoginStatusChange() directly. |
| 1232 if (wm_shell_->IsRunningInMash()) { | 1247 if (wm_shell_->IsRunningInMash()) { |
| 1233 // TODO(jamescook): Should this call Shell::OnLoginStatusChanged() too? | 1248 // TODO(jamescook): Should this call Shell::OnLoginStatusChanged() too? |
| 1234 UpdateAfterLoginStatusChange(session_controller_->GetLoginStatus()); | 1249 UpdateAfterLoginStatusChange(session_controller_->GetLoginStatus()); |
| 1235 } | 1250 } |
| 1236 } | 1251 } |
| 1237 | 1252 |
| 1238 } // namespace ash | 1253 } // namespace ash |
| OLD | NEW |