| 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 | 9 |
| 10 #include "ash/accelerators/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
| 11 #include "ash/accelerators/accelerator_filter.h" | 11 #include "ash/accelerators/accelerator_filter.h" |
| 12 #include "ash/accelerators/focus_manager_factory.h" | 12 #include "ash/accelerators/focus_manager_factory.h" |
| 13 #include "ash/accelerators/nested_dispatcher_controller.h" | 13 #include "ash/accelerators/nested_dispatcher_controller.h" |
| 14 #include "ash/ash_switches.h" | 14 #include "ash/ash_switches.h" |
| 15 #include "ash/autoclick/autoclick_controller.h" | 15 #include "ash/autoclick/autoclick_controller.h" |
| 16 #include "ash/caps_lock_delegate.h" | 16 #include "ash/caps_lock_delegate.h" |
| 17 #include "ash/desktop_background/desktop_background_controller.h" | 17 #include "ash/desktop_background/desktop_background_controller.h" |
| 18 #include "ash/desktop_background/desktop_background_view.h" | 18 #include "ash/desktop_background/desktop_background_view.h" |
| 19 #include "ash/desktop_background/user_wallpaper_delegate.h" | 19 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 20 #include "ash/display/display_controller.h" | 20 #include "ash/display/display_controller.h" |
| 21 #include "ash/display/display_manager.h" | 21 #include "ash/display/display_manager.h" |
| 22 #include "ash/display/event_transformation_handler.h" | 22 #include "ash/display/event_transformation_handler.h" |
| 23 #include "ash/display/mouse_cursor_event_filter.h" | 23 #include "ash/display/mouse_cursor_event_filter.h" |
| 24 #include "ash/display/resolution_notification_controller.h" | 24 #include "ash/display/resolution_notification_controller.h" |
| 25 #include "ash/display/screen_position_controller.h" | 25 #include "ash/display/screen_position_controller.h" |
| 26 #include "ash/display/virtual_keyboard_window_controller.h" |
| 26 #include "ash/drag_drop/drag_drop_controller.h" | 27 #include "ash/drag_drop/drag_drop_controller.h" |
| 27 #include "ash/first_run/first_run_helper_impl.h" | 28 #include "ash/first_run/first_run_helper_impl.h" |
| 28 #include "ash/focus_cycler.h" | 29 #include "ash/focus_cycler.h" |
| 29 #include "ash/high_contrast/high_contrast_controller.h" | 30 #include "ash/high_contrast/high_contrast_controller.h" |
| 30 #include "ash/host/root_window_host_factory.h" | 31 #include "ash/host/root_window_host_factory.h" |
| 31 #include "ash/keyboard_uma_event_filter.h" | 32 #include "ash/keyboard_uma_event_filter.h" |
| 32 #include "ash/launcher/launcher_delegate.h" | 33 #include "ash/launcher/launcher_delegate.h" |
| 33 #include "ash/launcher/launcher_item_delegate.h" | 34 #include "ash/launcher/launcher_item_delegate.h" |
| 34 #include "ash/launcher/launcher_item_delegate_manager.h" | 35 #include "ash/launcher/launcher_item_delegate_manager.h" |
| 35 #include "ash/launcher/launcher_model.h" | 36 #include "ash/launcher/launcher_model.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 const gfx::Insets& insets) { | 331 const gfx::Insets& insets) { |
| 331 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( | 332 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( |
| 332 contains, insets)) { | 333 contains, insets)) { |
| 333 return; | 334 return; |
| 334 } | 335 } |
| 335 FOR_EACH_OBSERVER(ShellObserver, observers_, | 336 FOR_EACH_OBSERVER(ShellObserver, observers_, |
| 336 OnDisplayWorkAreaInsetsChanged()); | 337 OnDisplayWorkAreaInsetsChanged()); |
| 337 } | 338 } |
| 338 | 339 |
| 339 void Shell::OnLoginStateChanged(user::LoginStatus status) { | 340 void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 340 if (status != user::LOGGED_IN_NONE) { | |
| 341 // TODO(bshe): Primary root window controller may not be the controller to | |
| 342 // attach virtual keyboard. See http://crbug.com/303429 | |
| 343 InitKeyboard(GetPrimaryRootWindowController()); | |
| 344 GetPrimaryRootWindowController()->ActivateKeyboard( | |
| 345 keyboard_controller_.get()); | |
| 346 } | |
| 347 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); | 341 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
| 348 } | 342 } |
| 349 | 343 |
| 344 void Shell::OnLoginUserProfilePrepared() { |
| 345 CreateLauncher(); |
| 346 CreateKeyboard(); |
| 347 } |
| 348 |
| 350 void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 349 void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 351 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 350 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 352 for (RootWindowControllerList::iterator iter = controllers.begin(); | 351 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 353 iter != controllers.end(); ++iter) | 352 iter != controllers.end(); ++iter) |
| 354 (*iter)->UpdateAfterLoginStatusChange(status); | 353 (*iter)->UpdateAfterLoginStatusChange(status); |
| 355 } | 354 } |
| 356 | 355 |
| 357 void Shell::OnAppTerminating() { | 356 void Shell::OnAppTerminating() { |
| 358 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); | 357 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
| 359 } | 358 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 374 #endif | 373 #endif |
| 375 } | 374 } |
| 376 | 375 |
| 377 void Shell::CreateLauncher() { | 376 void Shell::CreateLauncher() { |
| 378 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 377 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 379 for (RootWindowControllerList::iterator iter = controllers.begin(); | 378 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 380 iter != controllers.end(); ++iter) | 379 iter != controllers.end(); ++iter) |
| 381 (*iter)->shelf()->CreateLauncher(); | 380 (*iter)->shelf()->CreateLauncher(); |
| 382 } | 381 } |
| 383 | 382 |
| 383 void Shell::CreateKeyboard() { |
| 384 // TODO(bshe): Primary root window controller may not be the controller to |
| 385 // attach virtual keyboard. See http://crbug.com/303429 |
| 386 InitKeyboard(); |
| 387 if (keyboard::IsKeyboardUsabilityTestEnabled()) { |
| 388 display_controller()->virtual_keyboard_window_controller()-> |
| 389 ActivateKeyboard(keyboard_controller_.get()); |
| 390 } else { |
| 391 GetPrimaryRootWindowController()-> |
| 392 ActivateKeyboard(keyboard_controller_.get()); |
| 393 } |
| 394 } |
| 395 |
| 384 void Shell::ShowLauncher() { | 396 void Shell::ShowLauncher() { |
| 385 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 397 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 386 for (RootWindowControllerList::iterator iter = controllers.begin(); | 398 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 387 iter != controllers.end(); ++iter) | 399 iter != controllers.end(); ++iter) |
| 388 (*iter)->ShowLauncher(); | 400 (*iter)->ShowLauncher(); |
| 389 } | 401 } |
| 390 | 402 |
| 391 void Shell::AddShellObserver(ShellObserver* observer) { | 403 void Shell::AddShellObserver(ShellObserver* observer) { |
| 392 observers_.AddObserver(observer); | 404 observers_.AddObserver(observer); |
| 393 } | 405 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 system_tray_delegate_->Shutdown(); | 625 system_tray_delegate_->Shutdown(); |
| 614 system_tray_delegate_.reset(); | 626 system_tray_delegate_.reset(); |
| 615 | 627 |
| 616 locale_notification_controller_.reset(); | 628 locale_notification_controller_.reset(); |
| 617 | 629 |
| 618 // Drag-and-drop must be canceled prior to close all windows. | 630 // Drag-and-drop must be canceled prior to close all windows. |
| 619 drag_drop_controller_.reset(); | 631 drag_drop_controller_.reset(); |
| 620 | 632 |
| 621 // Destroy all child windows including widgets. | 633 // Destroy all child windows including widgets. |
| 622 display_controller_->CloseChildWindows(); | 634 display_controller_->CloseChildWindows(); |
| 635 display_controller_->CloseNonDesktopDisplay(); |
| 623 | 636 |
| 624 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems | 637 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
| 625 // needs to remove observers from it. | 638 // needs to remove observers from it. |
| 626 system_tray_notifier_.reset(); | 639 system_tray_notifier_.reset(); |
| 627 | 640 |
| 628 #if defined(OS_CHROMEOS) | 641 #if defined(OS_CHROMEOS) |
| 629 // Destroy VideoActivityNotifier before destroying VideoDetector. | 642 // Destroy VideoActivityNotifier before destroying VideoDetector. |
| 630 video_activity_notifier_.reset(); | 643 video_activity_notifier_.reset(); |
| 631 #endif // defined(OS_CHROMEOS) | 644 #endif // defined(OS_CHROMEOS) |
| 632 | 645 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 #endif | 700 #endif |
| 688 | 701 |
| 689 DCHECK(instance_ == this); | 702 DCHECK(instance_ == this); |
| 690 instance_ = NULL; | 703 instance_ = NULL; |
| 691 } | 704 } |
| 692 | 705 |
| 693 void Shell::Init() { | 706 void Shell::Init() { |
| 694 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 707 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 695 | 708 |
| 696 delegate_->PreInit(); | 709 delegate_->PreInit(); |
| 697 if (command_line->HasSwitch(keyboard::switches::kKeyboardUsabilityTest)) { | 710 if (keyboard::IsKeyboardUsabilityTestEnabled()) { |
| 698 display_manager_->SetSecondDisplayMode( | 711 display_manager_->SetSecondDisplayMode( |
| 699 internal::DisplayManager::VIRTUAL_KEYBOARD); | 712 internal::DisplayManager::VIRTUAL_KEYBOARD); |
| 700 } | 713 } |
| 701 bool display_initialized = display_manager_->InitFromCommandLine(); | 714 bool display_initialized = display_manager_->InitFromCommandLine(); |
| 702 #if defined(OS_CHROMEOS) && defined(USE_X11) | 715 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 703 output_configurator_animation_.reset( | 716 output_configurator_animation_.reset( |
| 704 new internal::OutputConfiguratorAnimation()); | 717 new internal::OutputConfiguratorAnimation()); |
| 705 output_configurator_->AddObserver(output_configurator_animation_.get()); | 718 output_configurator_->AddObserver(output_configurator_animation_.get()); |
| 706 | 719 |
| 707 if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) { | 720 if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 display_manager_.get())); | 929 display_manager_.get())); |
| 917 // The compositor thread and main message loop have to be running in | 930 // The compositor thread and main message loop have to be running in |
| 918 // order to create mirror window. Run it after the main message loop | 931 // order to create mirror window. Run it after the main message loop |
| 919 // is started. | 932 // is started. |
| 920 base::MessageLoopForUI::current()->PostTask( | 933 base::MessageLoopForUI::current()->PostTask( |
| 921 FROM_HERE, | 934 FROM_HERE, |
| 922 base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny, | 935 base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny, |
| 923 weak_display_manager_factory_->GetWeakPtr())); | 936 weak_display_manager_factory_->GetWeakPtr())); |
| 924 } | 937 } |
| 925 | 938 |
| 926 void Shell::InitKeyboard(internal::RootWindowController* root) { | 939 void Shell::InitKeyboard() { |
| 927 if (keyboard::IsKeyboardEnabled()) { | 940 if (keyboard::IsKeyboardEnabled()) { |
| 928 if (keyboard_controller_.get()) { | 941 if (keyboard_controller_.get()) { |
| 929 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 942 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 930 for (RootWindowControllerList::iterator iter = controllers.begin(); | 943 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 931 iter != controllers.end(); ++iter) { | 944 iter != controllers.end(); ++iter) { |
| 932 (*iter)->DeactivateKeyboard(keyboard_controller_.get()); | 945 (*iter)->DeactivateKeyboard(keyboard_controller_.get()); |
| 933 } | 946 } |
| 934 } | 947 } |
| 935 keyboard::KeyboardControllerProxy* proxy = | 948 keyboard::KeyboardControllerProxy* proxy = |
| 936 delegate_->CreateKeyboardControllerProxy(); | 949 delegate_->CreateKeyboardControllerProxy(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 //////////////////////////////////////////////////////////////////////////////// | 1009 //////////////////////////////////////////////////////////////////////////////// |
| 997 // Shell, aura::client::ActivationChangeObserver implementation: | 1010 // Shell, aura::client::ActivationChangeObserver implementation: |
| 998 | 1011 |
| 999 void Shell::OnWindowActivated(aura::Window* gained_active, | 1012 void Shell::OnWindowActivated(aura::Window* gained_active, |
| 1000 aura::Window* lost_active) { | 1013 aura::Window* lost_active) { |
| 1001 if (gained_active) | 1014 if (gained_active) |
| 1002 target_root_window_ = gained_active->GetRootWindow(); | 1015 target_root_window_ = gained_active->GetRootWindow(); |
| 1003 } | 1016 } |
| 1004 | 1017 |
| 1005 } // namespace ash | 1018 } // namespace ash |
| OLD | NEW |