| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/display/virtual_keyboard_window_controller.h" | 5 #include "ash/display/virtual_keyboard_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/root_window_transformers.h" | 10 #include "ash/display/root_window_transformers.h" |
| 11 #include "ash/host/ash_window_tree_host.h" | 11 #include "ash/host/ash_window_tree_host.h" |
| 12 #include "ash/host/ash_window_tree_host_init_params.h" | 12 #include "ash/host/ash_window_tree_host_init_params.h" |
| 13 #include "ash/host/root_window_transformer.h" | 13 #include "ash/host/root_window_transformer.h" |
| 14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/root_window_settings.h" | 15 #include "ash/root_window_settings.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "ui/aura/env.h" | 20 #include "ui/aura/env.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 21 #include "ui/aura/window_event_dispatcher.h" |
| 22 #include "ui/keyboard/keyboard_controller.h" | 22 #include "ui/keyboard/keyboard_controller.h" |
| 23 #include "ui/keyboard/keyboard_util.h" | 23 #include "ui/keyboard/keyboard_util.h" |
| 24 | 24 |
| 25 namespace ash { | 25 namespace ash { |
| 26 | 26 |
| 27 VirtualKeyboardWindowController::VirtualKeyboardWindowController() { | 27 VirtualKeyboardWindowController::VirtualKeyboardWindowController( |
| 28 ui::ContextFactory* context_factory) |
| 29 : context_factory_(context_factory) { |
| 28 Shell::GetInstance()->AddShellObserver(this); | 30 Shell::GetInstance()->AddShellObserver(this); |
| 29 } | 31 } |
| 30 | 32 |
| 31 VirtualKeyboardWindowController::~VirtualKeyboardWindowController() { | 33 VirtualKeyboardWindowController::~VirtualKeyboardWindowController() { |
| 32 Shell::GetInstance()->RemoveShellObserver(this); | 34 Shell::GetInstance()->RemoveShellObserver(this); |
| 33 // Make sure the root window gets deleted before cursor_window_delegate. | 35 // Make sure the root window gets deleted before cursor_window_delegate. |
| 34 Close(); | 36 Close(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void VirtualKeyboardWindowController::ActivateKeyboard( | 39 void VirtualKeyboardWindowController::ActivateKeyboard( |
| 38 keyboard::KeyboardController* keyboard_controller) { | 40 keyboard::KeyboardController* keyboard_controller) { |
| 39 root_window_controller_->ActivateKeyboard(keyboard_controller); | 41 root_window_controller_->ActivateKeyboard(keyboard_controller); |
| 40 } | 42 } |
| 41 | 43 |
| 42 void VirtualKeyboardWindowController::UpdateWindow( | 44 void VirtualKeyboardWindowController::UpdateWindow( |
| 43 const DisplayInfo& display_info) { | 45 const DisplayInfo& display_info) { |
| 44 static int virtual_keyboard_host_count = 0; | 46 static int virtual_keyboard_host_count = 0; |
| 45 if (!root_window_controller_.get()) { | 47 if (!root_window_controller_.get()) { |
| 46 AshWindowTreeHostInitParams init_params; | 48 AshWindowTreeHostInitParams init_params; |
| 49 init_params.context_factory = context_factory_; |
| 47 init_params.initial_bounds = display_info.bounds_in_native(); | 50 init_params.initial_bounds = display_info.bounds_in_native(); |
| 48 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(init_params); | 51 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(init_params); |
| 49 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 52 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 50 | 53 |
| 51 host->window()->SetName(base::StringPrintf("VirtualKeyboardRootWindow-%d", | 54 host->window()->SetName(base::StringPrintf("VirtualKeyboardRootWindow-%d", |
| 52 virtual_keyboard_host_count++)); | 55 virtual_keyboard_host_count++)); |
| 53 | 56 |
| 54 // No need to remove WindowTreeHostObserver because the DisplayController | 57 // No need to remove WindowTreeHostObserver because the DisplayController |
| 55 // outlives the host. | 58 // outlives the host. |
| 56 host->AddObserver(Shell::GetInstance()->display_controller()); | 59 host->AddObserver(Shell::GetInstance()->display_controller()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 Shell::GetInstance()->CreateKeyboard(); | 104 Shell::GetInstance()->CreateKeyboard(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 void VirtualKeyboardWindowController::OnMaximizeModeEnded() { | 107 void VirtualKeyboardWindowController::OnMaximizeModeEnded() { |
| 105 keyboard::SetTouchKeyboardEnabled(false); | 108 keyboard::SetTouchKeyboardEnabled(false); |
| 106 if (!keyboard::IsKeyboardEnabled()) | 109 if (!keyboard::IsKeyboardEnabled()) |
| 107 Shell::GetInstance()->DeactivateKeyboard(); | 110 Shell::GetInstance()->DeactivateKeyboard(); |
| 108 } | 111 } |
| 109 | 112 |
| 110 } // namespace ash | 113 } // namespace ash |
| OLD | NEW |