| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 private: | 163 private: |
| 164 // Overridden from ::wm::VisibilityController: | 164 // Overridden from ::wm::VisibilityController: |
| 165 bool CallAnimateOnChildWindowVisibilityChanged(aura::Window* window, | 165 bool CallAnimateOnChildWindowVisibilityChanged(aura::Window* window, |
| 166 bool visible) override { | 166 bool visible) override { |
| 167 return AnimateOnChildWindowVisibilityChanged(window, visible); | 167 return AnimateOnChildWindowVisibilityChanged(window, visible); |
| 168 } | 168 } |
| 169 | 169 |
| 170 DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); | 170 DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 AshWindowTreeHostInitParams ShellInitParamsToAshWindowTreeHostInitParams( | |
| 174 const ShellInitParams& shell_init_params) { | |
| 175 AshWindowTreeHostInitParams ash_init_params; | |
| 176 #if defined(OS_WIN) | |
| 177 ash_init_params.remote_hwnd = shell_init_params.remote_hwnd; | |
| 178 #endif | |
| 179 return ash_init_params; | |
| 180 } | |
| 181 | |
| 182 } // namespace | 173 } // namespace |
| 183 | 174 |
| 184 // static | 175 // static |
| 185 Shell* Shell::instance_ = nullptr; | 176 Shell* Shell::instance_ = nullptr; |
| 186 // static | 177 // static |
| 187 bool Shell::initially_hide_cursor_ = false; | 178 bool Shell::initially_hide_cursor_ = false; |
| 188 | 179 |
| 189 //////////////////////////////////////////////////////////////////////////////// | 180 //////////////////////////////////////////////////////////////////////////////// |
| 190 // Shell, public: | 181 // Shell, public: |
| 191 | 182 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 DCHECK_GT(session_state_delegate_->NumberOfLoggedInUsers(), 0); | 324 DCHECK_GT(session_state_delegate_->NumberOfLoggedInUsers(), 0); |
| 334 wm_shell_->CreateShelfDelegate(); | 325 wm_shell_->CreateShelfDelegate(); |
| 335 | 326 |
| 336 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 327 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 337 for (RootWindowControllerList::iterator iter = controllers.begin(); | 328 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 338 iter != controllers.end(); ++iter) | 329 iter != controllers.end(); ++iter) |
| 339 (*iter)->CreateShelf(); | 330 (*iter)->CreateShelf(); |
| 340 } | 331 } |
| 341 | 332 |
| 342 void Shell::CreateKeyboard() { | 333 void Shell::CreateKeyboard() { |
| 343 if (in_mus_) | |
| 344 return; | |
| 345 // TODO(bshe): Primary root window controller may not be the controller to | 334 // TODO(bshe): Primary root window controller may not be the controller to |
| 346 // attach virtual keyboard. See http://crbug.com/303429 | 335 // attach virtual keyboard. See http://crbug.com/303429 |
| 347 InitKeyboard(); | 336 InitKeyboard(); |
| 348 GetPrimaryRootWindowController()->ActivateKeyboard( | 337 GetPrimaryRootWindowController()->ActivateKeyboard( |
| 349 keyboard::KeyboardController::GetInstance()); | 338 keyboard::KeyboardController::GetInstance()); |
| 350 } | 339 } |
| 351 | 340 |
| 352 void Shell::DeactivateKeyboard() { | 341 void Shell::DeactivateKeyboard() { |
| 353 // TODO(jamescook): Move keyboard create and hide into WmShell. | 342 // TODO(jamescook): Move keyboard create and hide into WmShell. |
| 354 wm_shell_->keyboard_ui()->Hide(); | 343 wm_shell_->keyboard_ui()->Hide(); |
| 355 if (in_mus_) | |
| 356 return; | |
| 357 if (keyboard::KeyboardController::GetInstance()) { | 344 if (keyboard::KeyboardController::GetInstance()) { |
| 358 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 345 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 359 for (RootWindowControllerList::iterator iter = controllers.begin(); | 346 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 360 iter != controllers.end(); ++iter) { | 347 iter != controllers.end(); ++iter) { |
| 361 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); | 348 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
| 362 } | 349 } |
| 363 } | 350 } |
| 364 keyboard::KeyboardController::ResetInstance(nullptr); | 351 keyboard::KeyboardController::ResetInstance(nullptr); |
| 365 } | 352 } |
| 366 | 353 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 // Needs to happen right before |instance_| is reset. | 600 // Needs to happen right before |instance_| is reset. |
| 614 wm_shell_.reset(); | 601 wm_shell_.reset(); |
| 615 | 602 |
| 616 DCHECK(instance_ == this); | 603 DCHECK(instance_ == this); |
| 617 instance_ = nullptr; | 604 instance_ = nullptr; |
| 618 } | 605 } |
| 619 | 606 |
| 620 void Shell::Init(const ShellInitParams& init_params) { | 607 void Shell::Init(const ShellInitParams& init_params) { |
| 621 wm_shell_->Initialize(init_params.blocking_pool); | 608 wm_shell_->Initialize(init_params.blocking_pool); |
| 622 | 609 |
| 623 in_mus_ = init_params.in_mus; | |
| 624 | |
| 625 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 610 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); |
| 626 | 611 |
| 627 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 612 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 628 DCHECK(in_mus_) << "linux desktop does not support ash."; | 613 NOTREACHED() << "linux desktop does not support ash."; |
| 629 #endif | 614 #endif |
| 630 | 615 |
| 631 scoped_overview_animation_settings_factory_.reset( | 616 scoped_overview_animation_settings_factory_.reset( |
| 632 new ScopedOverviewAnimationSettingsFactoryAura); | 617 new ScopedOverviewAnimationSettingsFactoryAura); |
| 633 window_positioner_.reset(new WindowPositioner(wm_shell_.get())); | 618 window_positioner_.reset(new WindowPositioner(wm_shell_.get())); |
| 634 | 619 |
| 635 if (!in_mus_) { | 620 native_cursor_manager_ = new AshNativeCursorManager; |
| 636 native_cursor_manager_ = new AshNativeCursorManager; | |
| 637 #if defined(OS_CHROMEOS) | 621 #if defined(OS_CHROMEOS) |
| 638 cursor_manager_.reset( | 622 cursor_manager_.reset( |
| 639 new CursorManager(base::WrapUnique(native_cursor_manager_))); | 623 new CursorManager(base::WrapUnique(native_cursor_manager_))); |
| 640 #else | 624 #else |
| 641 cursor_manager_.reset( | 625 cursor_manager_.reset( |
| 642 new ::wm::CursorManager(base::WrapUnique(native_cursor_manager_))); | 626 new ::wm::CursorManager(base::WrapUnique(native_cursor_manager_))); |
| 643 #endif | 627 #endif |
| 644 } | |
| 645 | 628 |
| 646 wm_shell_->delegate()->PreInit(); | 629 wm_shell_->delegate()->PreInit(); |
| 647 bool display_initialized = display_manager_->InitFromCommandLine(); | 630 bool display_initialized = display_manager_->InitFromCommandLine(); |
| 648 | 631 |
| 649 display_configuration_controller_.reset(new DisplayConfigurationController( | 632 display_configuration_controller_.reset(new DisplayConfigurationController( |
| 650 display_manager_.get(), window_tree_host_manager_.get())); | 633 display_manager_.get(), window_tree_host_manager_.get())); |
| 651 | 634 |
| 652 #if defined(OS_CHROMEOS) | 635 #if defined(OS_CHROMEOS) |
| 653 // When running as part of mash display configuration is handled by the mus | 636 |
| 654 // process, so we won't try to configure displays here. | |
| 655 if (in_mus_) { | |
| 656 display_configurator_->set_configure_display(false); | |
| 657 } else { | |
| 658 #if defined(USE_OZONE) | 637 #if defined(USE_OZONE) |
| 659 display_configurator_->Init( | 638 display_configurator_->Init( |
| 660 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), | 639 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), |
| 661 !gpu_support_->IsPanelFittingDisabled()); | 640 !gpu_support_->IsPanelFittingDisabled()); |
| 662 #elif defined(USE_X11) | 641 #elif defined(USE_X11) |
| 663 display_configurator_->Init( | 642 display_configurator_->Init(base::MakeUnique<ui::NativeDisplayDelegateX11>(), |
| 664 base::MakeUnique<ui::NativeDisplayDelegateX11>(), | 643 !gpu_support_->IsPanelFittingDisabled()); |
| 665 !gpu_support_->IsPanelFittingDisabled()); | |
| 666 #endif | 644 #endif |
| 667 } | |
| 668 | 645 |
| 669 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. | 646 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. |
| 670 chromeos::DBusThreadManager* dbus_thread_manager = | 647 chromeos::DBusThreadManager* dbus_thread_manager = |
| 671 chromeos::DBusThreadManager::Get(); | 648 chromeos::DBusThreadManager::Get(); |
| 672 projecting_observer_.reset( | 649 projecting_observer_.reset( |
| 673 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); | 650 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); |
| 674 display_configurator_->AddObserver(projecting_observer_.get()); | 651 display_configurator_->AddObserver(projecting_observer_.get()); |
| 675 wm_shell_->AddShellObserver(projecting_observer_.get()); | 652 wm_shell_->AddShellObserver(projecting_observer_.get()); |
| 676 | 653 |
| 677 if (!in_mus_ && !display_initialized && | 654 if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) { |
| 678 base::SysInfo::IsRunningOnChromeOS()) { | |
| 679 display_change_observer_.reset(new DisplayChangeObserver); | 655 display_change_observer_.reset(new DisplayChangeObserver); |
| 680 // Register |display_change_observer_| first so that the rest of | 656 // Register |display_change_observer_| first so that the rest of |
| 681 // observer gets invoked after the root windows are configured. | 657 // observer gets invoked after the root windows are configured. |
| 682 display_configurator_->AddObserver(display_change_observer_.get()); | 658 display_configurator_->AddObserver(display_change_observer_.get()); |
| 683 display_error_observer_.reset(new DisplayErrorObserver()); | 659 display_error_observer_.reset(new DisplayErrorObserver()); |
| 684 display_configurator_->AddObserver(display_error_observer_.get()); | 660 display_configurator_->AddObserver(display_error_observer_.get()); |
| 685 display_configurator_->set_state_controller(display_change_observer_.get()); | 661 display_configurator_->set_state_controller(display_change_observer_.get()); |
| 686 display_configurator_->set_mirroring_controller(display_manager_.get()); | 662 display_configurator_->set_mirroring_controller(display_manager_.get()); |
| 687 display_configurator_->ForceInitialConfigure( | 663 display_configurator_->ForceInitialConfigure( |
| 688 wm_shell_->delegate()->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); | 664 wm_shell_->delegate()->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 710 wm::AshFocusRules* focus_rules = new wm::AshFocusRules(); | 686 wm::AshFocusRules* focus_rules = new wm::AshFocusRules(); |
| 711 | 687 |
| 712 ::wm::FocusController* focus_controller = | 688 ::wm::FocusController* focus_controller = |
| 713 new ::wm::FocusController(focus_rules); | 689 new ::wm::FocusController(focus_rules); |
| 714 focus_client_.reset(focus_controller); | 690 focus_client_.reset(focus_controller); |
| 715 activation_client_ = focus_controller; | 691 activation_client_ = focus_controller; |
| 716 | 692 |
| 717 screen_position_controller_.reset(new ScreenPositionController); | 693 screen_position_controller_.reset(new ScreenPositionController); |
| 718 | 694 |
| 719 window_tree_host_manager_->Start(); | 695 window_tree_host_manager_->Start(); |
| 720 window_tree_host_manager_->CreatePrimaryHost( | 696 AshWindowTreeHostInitParams ash_init_params; |
| 721 ShellInitParamsToAshWindowTreeHostInitParams(init_params)); | 697 window_tree_host_manager_->CreatePrimaryHost(ash_init_params); |
| 722 aura::Window* root_window = window_tree_host_manager_->GetPrimaryRootWindow(); | 698 aura::Window* root_window = window_tree_host_manager_->GetPrimaryRootWindow(); |
| 723 wm_shell_->set_root_window_for_new_windows(WmWindowAura::Get(root_window)); | 699 wm_shell_->set_root_window_for_new_windows(WmWindowAura::Get(root_window)); |
| 724 | 700 |
| 725 #if defined(OS_CHROMEOS) | 701 #if defined(OS_CHROMEOS) |
| 726 resolution_notification_controller_.reset( | 702 resolution_notification_controller_.reset( |
| 727 new ResolutionNotificationController); | 703 new ResolutionNotificationController); |
| 728 #endif | 704 #endif |
| 729 | 705 |
| 730 if (cursor_manager_) | 706 if (cursor_manager_) |
| 731 cursor_manager_->SetDisplay( | 707 cursor_manager_->SetDisplay( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 wm_shell_->SetSystemTrayDelegate( | 812 wm_shell_->SetSystemTrayDelegate( |
| 837 base::WrapUnique(wm_shell_->delegate()->CreateSystemTrayDelegate())); | 813 base::WrapUnique(wm_shell_->delegate()->CreateSystemTrayDelegate())); |
| 838 | 814 |
| 839 locale_notification_controller_.reset(new LocaleNotificationController); | 815 locale_notification_controller_.reset(new LocaleNotificationController); |
| 840 | 816 |
| 841 #if defined(OS_CHROMEOS) | 817 #if defined(OS_CHROMEOS) |
| 842 // Create TouchTransformerController before | 818 // Create TouchTransformerController before |
| 843 // WindowTreeHostManager::InitDisplays() | 819 // WindowTreeHostManager::InitDisplays() |
| 844 // since TouchTransformerController listens on | 820 // since TouchTransformerController listens on |
| 845 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). | 821 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). |
| 846 if (!in_mus_) | 822 touch_transformer_controller_.reset(new TouchTransformerController()); |
| 847 touch_transformer_controller_.reset(new TouchTransformerController()); | |
| 848 #endif // defined(OS_CHROMEOS) | 823 #endif // defined(OS_CHROMEOS) |
| 849 | 824 |
| 850 wm_shell_->SetKeyboardUI(init_params.keyboard_factory.is_null() | 825 wm_shell_->SetKeyboardUI(KeyboardUI::Create()); |
| 851 ? KeyboardUI::Create() | |
| 852 : init_params.keyboard_factory.Run()); | |
| 853 | 826 |
| 854 window_tree_host_manager_->InitHosts(); | 827 window_tree_host_manager_->InitHosts(); |
| 855 | 828 |
| 856 #if defined(OS_CHROMEOS) | 829 #if defined(OS_CHROMEOS) |
| 857 // Needs to be created after InitDisplays() since it may cause the virtual | 830 // Needs to be created after InitDisplays() since it may cause the virtual |
| 858 // keyboard to be deployed. | 831 // keyboard to be deployed. |
| 859 virtual_keyboard_controller_.reset(new VirtualKeyboardController); | 832 virtual_keyboard_controller_.reset(new VirtualKeyboardController); |
| 860 #endif // defined(OS_CHROMEOS) | 833 #endif // defined(OS_CHROMEOS) |
| 861 | 834 |
| 862 #if defined(OS_CHROMEOS) | 835 #if defined(OS_CHROMEOS) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 889 // is started. | 862 // is started. |
| 890 display_manager_->CreateMirrorWindowAsyncIfAny(); | 863 display_manager_->CreateMirrorWindowAsyncIfAny(); |
| 891 | 864 |
| 892 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), | 865 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), |
| 893 OnShellInitialized()); | 866 OnShellInitialized()); |
| 894 | 867 |
| 895 user_metrics_recorder_->OnShellInitialized(); | 868 user_metrics_recorder_->OnShellInitialized(); |
| 896 } | 869 } |
| 897 | 870 |
| 898 void Shell::InitKeyboard() { | 871 void Shell::InitKeyboard() { |
| 899 if (in_mus_) | |
| 900 return; | |
| 901 | |
| 902 if (keyboard::IsKeyboardEnabled()) { | 872 if (keyboard::IsKeyboardEnabled()) { |
| 903 if (keyboard::KeyboardController::GetInstance()) { | 873 if (keyboard::KeyboardController::GetInstance()) { |
| 904 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 874 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 905 for (RootWindowControllerList::iterator iter = controllers.begin(); | 875 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 906 iter != controllers.end(); ++iter) { | 876 iter != controllers.end(); ++iter) { |
| 907 (*iter)->DeactivateKeyboard( | 877 (*iter)->DeactivateKeyboard( |
| 908 keyboard::KeyboardController::GetInstance()); | 878 keyboard::KeyboardController::GetInstance()); |
| 909 } | 879 } |
| 910 } | 880 } |
| 911 keyboard::KeyboardController::ResetInstance( | 881 keyboard::KeyboardController::ResetInstance( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { | 931 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { |
| 962 return std::unique_ptr<ui::EventTargetIterator>(); | 932 return std::unique_ptr<ui::EventTargetIterator>(); |
| 963 } | 933 } |
| 964 | 934 |
| 965 ui::EventTargeter* Shell::GetEventTargeter() { | 935 ui::EventTargeter* Shell::GetEventTargeter() { |
| 966 NOTREACHED(); | 936 NOTREACHED(); |
| 967 return nullptr; | 937 return nullptr; |
| 968 } | 938 } |
| 969 | 939 |
| 970 } // namespace ash | 940 } // namespace ash |
| OLD | NEW |