| 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 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 for (auto& observer : shell_observers_) | 346 for (auto& observer : shell_observers_) |
| 347 observer.OnCastingSessionStartedOrStopped(started); | 347 observer.OnCastingSessionStartedOrStopped(started); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void Shell::OnRootWindowAdded(aura::Window* root_window) { | 350 void Shell::OnRootWindowAdded(aura::Window* root_window) { |
| 351 for (auto& observer : shell_observers_) | 351 for (auto& observer : shell_observers_) |
| 352 observer.OnRootWindowAdded(root_window); | 352 observer.OnRootWindowAdded(root_window); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void Shell::CreateKeyboard() { | 355 void Shell::CreateKeyboard() { |
| 356 InitKeyboard(); | 356 if (keyboard::IsKeyboardEnabled()) { |
| 357 if (keyboard::KeyboardController::GetInstance()) { |
| 358 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 359 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 360 iter != controllers.end(); ++iter) { |
| 361 (*iter)->DeactivateKeyboard( |
| 362 keyboard::KeyboardController::GetInstance()); |
| 363 } |
| 364 } |
| 365 keyboard::KeyboardController::ResetInstance( |
| 366 new keyboard::KeyboardController(shell_delegate_->CreateKeyboardUI(), |
| 367 virtual_keyboard_controller_.get())); |
| 368 } |
| 369 |
| 357 GetPrimaryRootWindowController()->ActivateKeyboard( | 370 GetPrimaryRootWindowController()->ActivateKeyboard( |
| 358 keyboard::KeyboardController::GetInstance()); | 371 keyboard::KeyboardController::GetInstance()); |
| 359 } | 372 } |
| 360 | 373 |
| 361 void Shell::DeactivateKeyboard() { | 374 void Shell::DeactivateKeyboard() { |
| 362 // TODO(jamescook): Move keyboard create and hide into ShellPort. | 375 // TODO(jamescook): Move keyboard create and hide into ShellPort. |
| 363 keyboard_ui_->Hide(); | 376 keyboard_ui_->Hide(); |
| 364 if (keyboard::KeyboardController::GetInstance()) { | 377 if (keyboard::KeyboardController::GetInstance()) { |
| 365 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 378 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 366 for (RootWindowControllerList::iterator iter = controllers.begin(); | 379 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 if (config != Config::MASH) | 1128 if (config != Config::MASH) |
| 1116 display_manager_->CreateMirrorWindowAsyncIfAny(); | 1129 display_manager_->CreateMirrorWindowAsyncIfAny(); |
| 1117 | 1130 |
| 1118 for (auto& observer : shell_observers_) | 1131 for (auto& observer : shell_observers_) |
| 1119 observer.OnShellInitialized(); | 1132 observer.OnShellInitialized(); |
| 1120 | 1133 |
| 1121 if (config != Config::MASH) | 1134 if (config != Config::MASH) |
| 1122 user_metrics_recorder_->OnShellInitialized(); | 1135 user_metrics_recorder_->OnShellInitialized(); |
| 1123 } | 1136 } |
| 1124 | 1137 |
| 1125 void Shell::InitKeyboard() { | |
| 1126 if (keyboard::IsKeyboardEnabled()) { | |
| 1127 if (keyboard::KeyboardController::GetInstance()) { | |
| 1128 RootWindowControllerList controllers = GetAllRootWindowControllers(); | |
| 1129 for (RootWindowControllerList::iterator iter = controllers.begin(); | |
| 1130 iter != controllers.end(); ++iter) { | |
| 1131 (*iter)->DeactivateKeyboard( | |
| 1132 keyboard::KeyboardController::GetInstance()); | |
| 1133 } | |
| 1134 } | |
| 1135 keyboard::KeyboardController::ResetInstance( | |
| 1136 new keyboard::KeyboardController(shell_delegate_->CreateKeyboardUI(), | |
| 1137 virtual_keyboard_controller_.get())); | |
| 1138 } | |
| 1139 } | |
| 1140 | |
| 1141 void Shell::InitRootWindow(aura::Window* root_window) { | 1138 void Shell::InitRootWindow(aura::Window* root_window) { |
| 1142 DCHECK(focus_controller_); | 1139 DCHECK(focus_controller_); |
| 1143 DCHECK(visibility_controller_.get()); | 1140 DCHECK(visibility_controller_.get()); |
| 1144 DCHECK(drag_drop_controller_.get()); | 1141 DCHECK(drag_drop_controller_.get()); |
| 1145 | 1142 |
| 1146 aura::client::SetFocusClient(root_window, focus_controller_.get()); | 1143 aura::client::SetFocusClient(root_window, focus_controller_.get()); |
| 1147 aura::client::SetActivationClient(root_window, focus_controller_.get()); | 1144 aura::client::SetActivationClient(root_window, focus_controller_.get()); |
| 1148 root_window->AddPreTargetHandler(focus_controller_.get()); | 1145 root_window->AddPreTargetHandler(focus_controller_.get()); |
| 1149 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); | 1146 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
| 1150 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); | 1147 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 void Shell::OnPrefServiceInitialized( | 1274 void Shell::OnPrefServiceInitialized( |
| 1278 std::unique_ptr<::PrefService> pref_service) { | 1275 std::unique_ptr<::PrefService> pref_service) { |
| 1279 if (!instance_) | 1276 if (!instance_) |
| 1280 return; | 1277 return; |
| 1281 // |pref_service_| is null if can't connect to Chrome (as happens when | 1278 // |pref_service_| is null if can't connect to Chrome (as happens when |
| 1282 // running mash outside of chrome --mash and chrome isn't built). | 1279 // running mash outside of chrome --mash and chrome isn't built). |
| 1283 pref_service_ = std::move(pref_service); | 1280 pref_service_ = std::move(pref_service); |
| 1284 } | 1281 } |
| 1285 | 1282 |
| 1286 } // namespace ash | 1283 } // namespace ash |
| OLD | NEW |