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