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/magnifier/magnification_controller.h" | 36 #include "ash/magnifier/magnification_controller.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 const gfx::Insets& insets) { | 330 const gfx::Insets& insets) { |
330 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( | 331 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( |
331 contains, insets)) { | 332 contains, insets)) { |
332 return; | 333 return; |
333 } | 334 } |
334 FOR_EACH_OBSERVER(ShellObserver, observers_, | 335 FOR_EACH_OBSERVER(ShellObserver, observers_, |
335 OnDisplayWorkAreaInsetsChanged()); | 336 OnDisplayWorkAreaInsetsChanged()); |
336 } | 337 } |
337 | 338 |
338 void Shell::OnLoginStateChanged(user::LoginStatus status) { | 339 void Shell::OnLoginStateChanged(user::LoginStatus status) { |
339 if (status != user::LOGGED_IN_NONE) { | |
340 // TODO(bshe): Primary root window controller may not be the controller to | |
341 // attach virtual keyboard. See http://crbug.com/303429 | |
342 InitKeyboard(GetPrimaryRootWindowController()); | |
343 GetPrimaryRootWindowController()->ActivateKeyboard( | |
344 keyboard_controller_.get()); | |
345 } | |
346 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); | 340 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
347 } | 341 } |
348 | 342 |
| 343 void Shell::OnLoginUserProfilePrepared() { |
| 344 CreateLauncher(); |
| 345 CreateKeyboard(); |
| 346 } |
| 347 |
349 void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 348 void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
350 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 349 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
351 for (RootWindowControllerList::iterator iter = controllers.begin(); | 350 for (RootWindowControllerList::iterator iter = controllers.begin(); |
352 iter != controllers.end(); ++iter) | 351 iter != controllers.end(); ++iter) |
353 (*iter)->UpdateAfterLoginStatusChange(status); | 352 (*iter)->UpdateAfterLoginStatusChange(status); |
354 } | 353 } |
355 | 354 |
356 void Shell::OnAppTerminating() { | 355 void Shell::OnAppTerminating() { |
357 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); | 356 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
358 } | 357 } |
(...skipping 14 matching lines...) Expand all Loading... |
373 #endif | 372 #endif |
374 } | 373 } |
375 | 374 |
376 void Shell::CreateLauncher() { | 375 void Shell::CreateLauncher() { |
377 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 376 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
378 for (RootWindowControllerList::iterator iter = controllers.begin(); | 377 for (RootWindowControllerList::iterator iter = controllers.begin(); |
379 iter != controllers.end(); ++iter) | 378 iter != controllers.end(); ++iter) |
380 (*iter)->shelf()->CreateLauncher(); | 379 (*iter)->shelf()->CreateLauncher(); |
381 } | 380 } |
382 | 381 |
| 382 void Shell::CreateKeyboard() { |
| 383 // TODO(bshe): Primary root window controller may not be the controller to |
| 384 // attach virtual keyboard. See http://crbug.com/303429 |
| 385 InitKeyboard(); |
| 386 if (keyboard::IsKeyboardUsabilityExperimentEnabled()) { |
| 387 display_controller()->virtual_keyboard_window_controller()-> |
| 388 ActivateKeyboard(keyboard_controller_.get()); |
| 389 } else { |
| 390 GetPrimaryRootWindowController()-> |
| 391 ActivateKeyboard(keyboard_controller_.get()); |
| 392 } |
| 393 } |
| 394 |
383 void Shell::ShowLauncher() { | 395 void Shell::ShowLauncher() { |
384 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 396 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
385 for (RootWindowControllerList::iterator iter = controllers.begin(); | 397 for (RootWindowControllerList::iterator iter = controllers.begin(); |
386 iter != controllers.end(); ++iter) | 398 iter != controllers.end(); ++iter) |
387 (*iter)->ShowLauncher(); | 399 (*iter)->ShowLauncher(); |
388 } | 400 } |
389 | 401 |
390 void Shell::AddShellObserver(ShellObserver* observer) { | 402 void Shell::AddShellObserver(ShellObserver* observer) { |
391 observers_.AddObserver(observer); | 403 observers_.AddObserver(observer); |
392 } | 404 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 system_tray_delegate_->Shutdown(); | 623 system_tray_delegate_->Shutdown(); |
612 system_tray_delegate_.reset(); | 624 system_tray_delegate_.reset(); |
613 | 625 |
614 locale_notification_controller_.reset(); | 626 locale_notification_controller_.reset(); |
615 | 627 |
616 // Drag-and-drop must be canceled prior to close all windows. | 628 // Drag-and-drop must be canceled prior to close all windows. |
617 drag_drop_controller_.reset(); | 629 drag_drop_controller_.reset(); |
618 | 630 |
619 // Destroy all child windows including widgets. | 631 // Destroy all child windows including widgets. |
620 display_controller_->CloseChildWindows(); | 632 display_controller_->CloseChildWindows(); |
| 633 display_controller_->CloseNonDesktopDisplay(); |
621 | 634 |
622 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems | 635 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
623 // needs to remove observers from it. | 636 // needs to remove observers from it. |
624 system_tray_notifier_.reset(); | 637 system_tray_notifier_.reset(); |
625 | 638 |
626 #if defined(OS_CHROMEOS) | 639 #if defined(OS_CHROMEOS) |
627 // Destroy VideoActivityNotifier before destroying VideoDetector. | 640 // Destroy VideoActivityNotifier before destroying VideoDetector. |
628 video_activity_notifier_.reset(); | 641 video_activity_notifier_.reset(); |
629 #endif // defined(OS_CHROMEOS) | 642 #endif // defined(OS_CHROMEOS) |
630 | 643 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 #endif | 698 #endif |
686 | 699 |
687 DCHECK(instance_ == this); | 700 DCHECK(instance_ == this); |
688 instance_ = NULL; | 701 instance_ = NULL; |
689 } | 702 } |
690 | 703 |
691 void Shell::Init() { | 704 void Shell::Init() { |
692 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 705 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
693 | 706 |
694 delegate_->PreInit(); | 707 delegate_->PreInit(); |
695 if (command_line->HasSwitch(keyboard::switches::kKeyboardUsabilityTest)) { | 708 if (keyboard::IsKeyboardUsabilityExperimentEnabled()) { |
696 display_manager_->SetSecondDisplayMode( | 709 display_manager_->SetSecondDisplayMode( |
697 internal::DisplayManager::VIRTUAL_KEYBOARD); | 710 internal::DisplayManager::VIRTUAL_KEYBOARD); |
698 } | 711 } |
699 bool display_initialized = display_manager_->InitFromCommandLine(); | 712 bool display_initialized = display_manager_->InitFromCommandLine(); |
700 #if defined(OS_CHROMEOS) && defined(USE_X11) | 713 #if defined(OS_CHROMEOS) && defined(USE_X11) |
701 output_configurator_animation_.reset( | 714 output_configurator_animation_.reset( |
702 new internal::OutputConfiguratorAnimation()); | 715 new internal::OutputConfiguratorAnimation()); |
703 output_configurator_->AddObserver(output_configurator_animation_.get()); | 716 output_configurator_->AddObserver(output_configurator_animation_.get()); |
704 | 717 |
705 if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) { | 718 if (!display_initialized && base::SysInfo::IsRunningOnChromeOS()) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 display_manager_.get())); | 921 display_manager_.get())); |
909 // The compositor thread and main message loop have to be running in | 922 // The compositor thread and main message loop have to be running in |
910 // order to create mirror window. Run it after the main message loop | 923 // order to create mirror window. Run it after the main message loop |
911 // is started. | 924 // is started. |
912 base::MessageLoopForUI::current()->PostTask( | 925 base::MessageLoopForUI::current()->PostTask( |
913 FROM_HERE, | 926 FROM_HERE, |
914 base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny, | 927 base::Bind(&internal::DisplayManager::CreateMirrorWindowIfAny, |
915 weak_display_manager_factory_->GetWeakPtr())); | 928 weak_display_manager_factory_->GetWeakPtr())); |
916 } | 929 } |
917 | 930 |
918 void Shell::InitKeyboard(internal::RootWindowController* root) { | 931 void Shell::InitKeyboard() { |
919 if (keyboard::IsKeyboardEnabled()) { | 932 if (keyboard::IsKeyboardEnabled()) { |
920 if (keyboard_controller_.get()) { | 933 if (keyboard_controller_.get()) { |
921 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 934 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
922 for (RootWindowControllerList::iterator iter = controllers.begin(); | 935 for (RootWindowControllerList::iterator iter = controllers.begin(); |
923 iter != controllers.end(); ++iter) { | 936 iter != controllers.end(); ++iter) { |
924 (*iter)->DeactivateKeyboard(keyboard_controller_.get()); | 937 (*iter)->DeactivateKeyboard(keyboard_controller_.get()); |
925 } | 938 } |
926 } | 939 } |
927 keyboard::KeyboardControllerProxy* proxy = | 940 keyboard::KeyboardControllerProxy* proxy = |
928 delegate_->CreateKeyboardControllerProxy(); | 941 delegate_->CreateKeyboardControllerProxy(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 //////////////////////////////////////////////////////////////////////////////// | 1001 //////////////////////////////////////////////////////////////////////////////// |
989 // Shell, aura::client::ActivationChangeObserver implementation: | 1002 // Shell, aura::client::ActivationChangeObserver implementation: |
990 | 1003 |
991 void Shell::OnWindowActivated(aura::Window* gained_active, | 1004 void Shell::OnWindowActivated(aura::Window* gained_active, |
992 aura::Window* lost_active) { | 1005 aura::Window* lost_active) { |
993 if (gained_active) | 1006 if (gained_active) |
994 target_root_window_ = gained_active->GetRootWindow(); | 1007 target_root_window_ = gained_active->GetRootWindow(); |
995 } | 1008 } |
996 | 1009 |
997 } // namespace ash | 1010 } // namespace ash |
OLD | NEW |