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

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: always compile mojo_shell 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"
39 #include "ash/mojo_shell.h"
38 #include "ash/new_window_delegate.h" 40 #include "ash/new_window_delegate.h"
39 #include "ash/root_window_controller.h" 41 #include "ash/root_window_controller.h"
40 #include "ash/session/session_state_delegate.h" 42 #include "ash/session/session_state_delegate.h"
41 #include "ash/shelf/app_list_shelf_item_delegate.h" 43 #include "ash/shelf/app_list_shelf_item_delegate.h"
42 #include "ash/shelf/shelf_delegate.h" 44 #include "ash/shelf/shelf_delegate.h"
43 #include "ash/shelf/shelf_item_delegate.h" 45 #include "ash/shelf/shelf_item_delegate.h"
44 #include "ash/shelf/shelf_item_delegate_manager.h" 46 #include "ash/shelf/shelf_item_delegate_manager.h"
45 #include "ash/shelf/shelf_layout_manager.h" 47 #include "ash/shelf/shelf_layout_manager.h"
46 #include "ash/shelf/shelf_model.h" 48 #include "ash/shelf/shelf_model.h"
47 #include "ash/shelf/shelf_widget.h" 49 #include "ash/shelf/shelf_widget.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 (*iter)->shelf()->CreateShelf(); 439 (*iter)->shelf()->CreateShelf();
438 } 440 }
439 441
440 void Shell::OnShelfCreatedForRootWindow(aura::Window* root_window) { 442 void Shell::OnShelfCreatedForRootWindow(aura::Window* root_window) {
441 FOR_EACH_OBSERVER(ShellObserver, 443 FOR_EACH_OBSERVER(ShellObserver,
442 observers_, 444 observers_,
443 OnShelfCreatedForRootWindow(root_window)); 445 OnShelfCreatedForRootWindow(root_window));
444 } 446 }
445 447
446 void Shell::CreateKeyboard() { 448 void Shell::CreateKeyboard() {
449 if (GetMojoShell())
450 return;
447 // TODO(bshe): Primary root window controller may not be the controller to 451 // TODO(bshe): Primary root window controller may not be the controller to
448 // attach virtual keyboard. See http://crbug.com/303429 452 // attach virtual keyboard. See http://crbug.com/303429
449 InitKeyboard(); 453 InitKeyboard();
450 GetPrimaryRootWindowController()-> 454 GetPrimaryRootWindowController()->
451 ActivateKeyboard(keyboard::KeyboardController::GetInstance()); 455 ActivateKeyboard(keyboard::KeyboardController::GetInstance());
452 } 456 }
453 457
454 void Shell::DeactivateKeyboard() { 458 void Shell::DeactivateKeyboard() {
459 keyboard_ui_->Hide();
460 if (GetMojoShell())
461 return;
455 if (keyboard::KeyboardController::GetInstance()) { 462 if (keyboard::KeyboardController::GetInstance()) {
456 RootWindowControllerList controllers = GetAllRootWindowControllers(); 463 RootWindowControllerList controllers = GetAllRootWindowControllers();
457 for (RootWindowControllerList::iterator iter = controllers.begin(); 464 for (RootWindowControllerList::iterator iter = controllers.begin();
458 iter != controllers.end(); ++iter) { 465 iter != controllers.end(); ++iter) {
459 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); 466 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
460 } 467 }
461 } 468 }
462 keyboard::KeyboardController::ResetInstance(nullptr); 469 keyboard::KeyboardController::ResetInstance(nullptr);
463 } 470 }
464 471
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 base::Bind(&SystemTrayDelegate::SignOut, 1045 base::Bind(&SystemTrayDelegate::SignOut,
1039 base::Unretained(system_tray_delegate_.get())))); 1046 base::Unretained(system_tray_delegate_.get()))));
1040 1047
1041 // Create TouchTransformerController before 1048 // Create TouchTransformerController before
1042 // WindowTreeHostManager::InitDisplays() 1049 // WindowTreeHostManager::InitDisplays()
1043 // since TouchTransformerController listens on 1050 // since TouchTransformerController listens on
1044 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). 1051 // WindowTreeHostManager::Observer::OnDisplaysInitialized().
1045 touch_transformer_controller_.reset(new TouchTransformerController()); 1052 touch_transformer_controller_.reset(new TouchTransformerController());
1046 #endif // defined(OS_CHROMEOS) 1053 #endif // defined(OS_CHROMEOS)
1047 1054
1055 keyboard_ui_ = KeyboardUI::Create();
1056
sadrul 2016/02/10 23:57:14 I wonder if ShellInitParams could include a Keyboa
sky 2016/02/11 00:39:47 Both of your suggestions are certainly doable. If
sadrul 2016/02/11 14:36:07 Even in the complete mustash world, it would be pr
1048 window_tree_host_manager_->InitHosts(); 1057 window_tree_host_manager_->InitHosts();
1049 1058
1050 #if defined(OS_CHROMEOS) 1059 #if defined(OS_CHROMEOS)
1051 // Needs to be created after InitDisplays() since it may cause the virtual 1060 // Needs to be created after InitDisplays() since it may cause the virtual
1052 // keyboard to be deployed. 1061 // keyboard to be deployed.
1053 virtual_keyboard_controller_.reset(new VirtualKeyboardController); 1062 virtual_keyboard_controller_.reset(new VirtualKeyboardController);
1054 #endif // defined(OS_CHROMEOS) 1063 #endif // defined(OS_CHROMEOS)
1055 1064
1056 // It needs to be created after RootWindowController has been created 1065 // It needs to be created after RootWindowController has been created
1057 // (which calls OnWindowResized has been called, otherwise the 1066 // (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 1092 // order to create mirror window. Run it after the main message loop
1084 // is started. 1093 // is started.
1085 display_manager_->CreateMirrorWindowAsyncIfAny(); 1094 display_manager_->CreateMirrorWindowAsyncIfAny();
1086 1095
1087 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShellInitialized()); 1096 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShellInitialized());
1088 1097
1089 user_metrics_recorder_->OnShellInitialized(); 1098 user_metrics_recorder_->OnShellInitialized();
1090 } 1099 }
1091 1100
1092 void Shell::InitKeyboard() { 1101 void Shell::InitKeyboard() {
1102 if (GetMojoShell())
1103 return;
sadrul 2016/02/10 23:57:14 Similarly, would it make sense to include a flag t
1104
1093 if (keyboard::IsKeyboardEnabled()) { 1105 if (keyboard::IsKeyboardEnabled()) {
1094 if (keyboard::KeyboardController::GetInstance()) { 1106 if (keyboard::KeyboardController::GetInstance()) {
1095 RootWindowControllerList controllers = GetAllRootWindowControllers(); 1107 RootWindowControllerList controllers = GetAllRootWindowControllers();
1096 for (RootWindowControllerList::iterator iter = controllers.begin(); 1108 for (RootWindowControllerList::iterator iter = controllers.begin();
1097 iter != controllers.end(); ++iter) { 1109 iter != controllers.end(); ++iter) {
1098 (*iter)->DeactivateKeyboard( 1110 (*iter)->DeactivateKeyboard(
1099 keyboard::KeyboardController::GetInstance()); 1111 keyboard::KeyboardController::GetInstance());
1100 } 1112 }
1101 } 1113 }
1102 keyboard::KeyboardController::ResetInstance( 1114 keyboard::KeyboardController::ResetInstance(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1182
1171 void Shell::OnWindowActivated( 1183 void Shell::OnWindowActivated(
1172 aura::client::ActivationChangeObserver::ActivationReason reason, 1184 aura::client::ActivationChangeObserver::ActivationReason reason,
1173 aura::Window* gained_active, 1185 aura::Window* gained_active,
1174 aura::Window* lost_active) { 1186 aura::Window* lost_active) {
1175 if (gained_active) 1187 if (gained_active)
1176 target_root_window_ = gained_active->GetRootWindow(); 1188 target_root_window_ = gained_active->GetRootWindow();
1177 } 1189 }
1178 1190
1179 } // namespace ash 1191 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698