Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: ash/shell.cc

Issue 1684823004: Refactors keyboard related code so mash can use a keyboard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 #include "ash/display/screen_position_controller.h" 24 #include "ash/display/screen_position_controller.h"
25 #include "ash/display/window_tree_host_manager.h" 25 #include "ash/display/window_tree_host_manager.h"
26 #include "ash/drag_drop/drag_drop_controller.h" 26 #include "ash/drag_drop/drag_drop_controller.h"
27 #include "ash/first_run/first_run_helper_impl.h" 27 #include "ash/first_run/first_run_helper_impl.h"
28 #include "ash/focus_cycler.h" 28 #include "ash/focus_cycler.h"
29 #include "ash/frame/custom_frame_view_ash.h" 29 #include "ash/frame/custom_frame_view_ash.h"
30 #include "ash/gpu_support.h" 30 #include "ash/gpu_support.h"
31 #include "ash/high_contrast/high_contrast_controller.h" 31 #include "ash/high_contrast/high_contrast_controller.h"
32 #include "ash/host/ash_window_tree_host_init_params.h" 32 #include "ash/host/ash_window_tree_host_init_params.h"
33 #include "ash/ime/input_method_event_handler.h" 33 #include "ash/ime/input_method_event_handler.h"
34 #include "ash/keyboard/keyboard_ui.h"
34 #include "ash/keyboard_uma_event_filter.h" 35 #include "ash/keyboard_uma_event_filter.h"
35 #include "ash/magnifier/magnification_controller.h" 36 #include "ash/magnifier/magnification_controller.h"
36 #include "ash/magnifier/partial_magnification_controller.h" 37 #include "ash/magnifier/partial_magnification_controller.h"
37 #include "ash/media_delegate.h" 38 #include "ash/media_delegate.h"
38 #include "ash/new_window_delegate.h" 39 #include "ash/new_window_delegate.h"
39 #include "ash/root_window_controller.h" 40 #include "ash/root_window_controller.h"
40 #include "ash/session/session_state_delegate.h" 41 #include "ash/session/session_state_delegate.h"
41 #include "ash/shelf/app_list_shelf_item_delegate.h" 42 #include "ash/shelf/app_list_shelf_item_delegate.h"
42 #include "ash/shelf/shelf_delegate.h" 43 #include "ash/shelf/shelf_delegate.h"
43 #include "ash/shelf/shelf_item_delegate.h" 44 #include "ash/shelf/shelf_item_delegate.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 (*iter)->shelf()->CreateShelf(); 438 (*iter)->shelf()->CreateShelf();
438 } 439 }
439 440
440 void Shell::OnShelfCreatedForRootWindow(aura::Window* root_window) { 441 void Shell::OnShelfCreatedForRootWindow(aura::Window* root_window) {
441 FOR_EACH_OBSERVER(ShellObserver, 442 FOR_EACH_OBSERVER(ShellObserver,
442 observers_, 443 observers_,
443 OnShelfCreatedForRootWindow(root_window)); 444 OnShelfCreatedForRootWindow(root_window));
444 } 445 }
445 446
446 void Shell::CreateKeyboard() { 447 void Shell::CreateKeyboard() {
448 if (in_mus_)
449 return;
447 // TODO(bshe): Primary root window controller may not be the controller to 450 // TODO(bshe): Primary root window controller may not be the controller to
448 // attach virtual keyboard. See http://crbug.com/303429 451 // attach virtual keyboard. See http://crbug.com/303429
449 InitKeyboard(); 452 InitKeyboard();
450 GetPrimaryRootWindowController()-> 453 GetPrimaryRootWindowController()->
451 ActivateKeyboard(keyboard::KeyboardController::GetInstance()); 454 ActivateKeyboard(keyboard::KeyboardController::GetInstance());
452 } 455 }
453 456
454 void Shell::DeactivateKeyboard() { 457 void Shell::DeactivateKeyboard() {
458 keyboard_ui_->Hide();
459 if (in_mus_)
460 return;
455 if (keyboard::KeyboardController::GetInstance()) { 461 if (keyboard::KeyboardController::GetInstance()) {
456 RootWindowControllerList controllers = GetAllRootWindowControllers(); 462 RootWindowControllerList controllers = GetAllRootWindowControllers();
457 for (RootWindowControllerList::iterator iter = controllers.begin(); 463 for (RootWindowControllerList::iterator iter = controllers.begin();
458 iter != controllers.end(); ++iter) { 464 iter != controllers.end(); ++iter) {
459 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); 465 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
460 } 466 }
461 } 467 }
462 keyboard::KeyboardController::ResetInstance(nullptr); 468 keyboard::KeyboardController::ResetInstance(nullptr);
463 } 469 }
464 470
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 840
835 // Ensure that DBusThreadManager outlives this Shell. 841 // Ensure that DBusThreadManager outlives this Shell.
836 DCHECK(chromeos::DBusThreadManager::IsInitialized()); 842 DCHECK(chromeos::DBusThreadManager::IsInitialized());
837 #endif 843 #endif
838 844
839 DCHECK(instance_ == this); 845 DCHECK(instance_ == this);
840 instance_ = nullptr; 846 instance_ = nullptr;
841 } 847 }
842 848
843 void Shell::Init(const ShellInitParams& init_params) { 849 void Shell::Init(const ShellInitParams& init_params) {
850 in_mus_ = init_params.in_mus;
851
844 delegate_->PreInit(); 852 delegate_->PreInit();
845 bool display_initialized = display_manager_->InitFromCommandLine(); 853 bool display_initialized = display_manager_->InitFromCommandLine();
846 854
847 display_configuration_controller_.reset(new DisplayConfigurationController( 855 display_configuration_controller_.reset(new DisplayConfigurationController(
848 display_manager_.get(), window_tree_host_manager_.get())); 856 display_manager_.get(), window_tree_host_manager_.get()));
849 857
850 #if defined(OS_CHROMEOS) 858 #if defined(OS_CHROMEOS)
851 display_configurator_->Init(!gpu_support_->IsPanelFittingDisabled()); 859 display_configurator_->Init(!gpu_support_->IsPanelFittingDisabled());
852 860
853 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. 861 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 base::Bind(&SystemTrayDelegate::SignOut, 1046 base::Bind(&SystemTrayDelegate::SignOut,
1039 base::Unretained(system_tray_delegate_.get())))); 1047 base::Unretained(system_tray_delegate_.get()))));
1040 1048
1041 // Create TouchTransformerController before 1049 // Create TouchTransformerController before
1042 // WindowTreeHostManager::InitDisplays() 1050 // WindowTreeHostManager::InitDisplays()
1043 // since TouchTransformerController listens on 1051 // since TouchTransformerController listens on
1044 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). 1052 // WindowTreeHostManager::Observer::OnDisplaysInitialized().
1045 touch_transformer_controller_.reset(new TouchTransformerController()); 1053 touch_transformer_controller_.reset(new TouchTransformerController());
1046 #endif // defined(OS_CHROMEOS) 1054 #endif // defined(OS_CHROMEOS)
1047 1055
1056 keyboard_ui_ = init_params.keyboard_factory.is_null()
1057 ? KeyboardUI::Create()
1058 : init_params.keyboard_factory.Run();
1059
1048 window_tree_host_manager_->InitHosts(); 1060 window_tree_host_manager_->InitHosts();
1049 1061
1050 #if defined(OS_CHROMEOS) 1062 #if defined(OS_CHROMEOS)
1051 // Needs to be created after InitDisplays() since it may cause the virtual 1063 // Needs to be created after InitDisplays() since it may cause the virtual
1052 // keyboard to be deployed. 1064 // keyboard to be deployed.
1053 virtual_keyboard_controller_.reset(new VirtualKeyboardController); 1065 virtual_keyboard_controller_.reset(new VirtualKeyboardController);
1054 #endif // defined(OS_CHROMEOS) 1066 #endif // defined(OS_CHROMEOS)
1055 1067
1056 // It needs to be created after RootWindowController has been created 1068 // It needs to be created after RootWindowController has been created
1057 // (which calls OnWindowResized has been called, otherwise the 1069 // (which calls OnWindowResized has been called, otherwise the
(...skipping 25 matching lines...) Expand all
1083 // order to create mirror window. Run it after the main message loop 1095 // order to create mirror window. Run it after the main message loop
1084 // is started. 1096 // is started.
1085 display_manager_->CreateMirrorWindowAsyncIfAny(); 1097 display_manager_->CreateMirrorWindowAsyncIfAny();
1086 1098
1087 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShellInitialized()); 1099 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShellInitialized());
1088 1100
1089 user_metrics_recorder_->OnShellInitialized(); 1101 user_metrics_recorder_->OnShellInitialized();
1090 } 1102 }
1091 1103
1092 void Shell::InitKeyboard() { 1104 void Shell::InitKeyboard() {
1105 if (in_mus_)
1106 return;
1107
1093 if (keyboard::IsKeyboardEnabled()) { 1108 if (keyboard::IsKeyboardEnabled()) {
1094 if (keyboard::KeyboardController::GetInstance()) { 1109 if (keyboard::KeyboardController::GetInstance()) {
1095 RootWindowControllerList controllers = GetAllRootWindowControllers(); 1110 RootWindowControllerList controllers = GetAllRootWindowControllers();
1096 for (RootWindowControllerList::iterator iter = controllers.begin(); 1111 for (RootWindowControllerList::iterator iter = controllers.begin();
1097 iter != controllers.end(); ++iter) { 1112 iter != controllers.end(); ++iter) {
1098 (*iter)->DeactivateKeyboard( 1113 (*iter)->DeactivateKeyboard(
1099 keyboard::KeyboardController::GetInstance()); 1114 keyboard::KeyboardController::GetInstance());
1100 } 1115 }
1101 } 1116 }
1102 keyboard::KeyboardController::ResetInstance( 1117 keyboard::KeyboardController::ResetInstance(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1185
1171 void Shell::OnWindowActivated( 1186 void Shell::OnWindowActivated(
1172 aura::client::ActivationChangeObserver::ActivationReason reason, 1187 aura::client::ActivationChangeObserver::ActivationReason reason,
1173 aura::Window* gained_active, 1188 aura::Window* gained_active,
1174 aura::Window* lost_active) { 1189 aura::Window* lost_active) {
1175 if (gained_active) 1190 if (gained_active)
1176 target_root_window_ = gained_active->GetRootWindow(); 1191 target_root_window_ = gained_active->GetRootWindow();
1177 } 1192 }
1178 1193
1179 } // namespace ash 1194 } // namespace ash
OLDNEW
« ash/mus/sysui_application.cc ('K') | « ash/shell.h ('k') | ash/shell_init_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698