OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/keyboard/keyboard_controller.h" | 5 #include "ui/keyboard/keyboard_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) | 238 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) |
239 : proxy_(proxy), | 239 : proxy_(proxy), |
240 input_method_(NULL), | 240 input_method_(NULL), |
241 keyboard_visible_(false), | 241 keyboard_visible_(false), |
242 show_on_resize_(false), | 242 show_on_resize_(false), |
243 lock_keyboard_(false), | 243 lock_keyboard_(false), |
244 type_(ui::TEXT_INPUT_TYPE_NONE), | 244 type_(ui::TEXT_INPUT_TYPE_NONE), |
245 weak_factory_(this) { | 245 weak_factory_(this) { |
246 CHECK(proxy); | 246 CHECK(proxy); |
247 input_method_ = proxy_->GetInputMethod(); | 247 input_method_ = proxy_->GetInputMethod(); |
| 248 input_method_->SetSupportsOnScreenKeyboard(true); |
248 input_method_->AddObserver(this); | 249 input_method_->AddObserver(this); |
249 window_bounds_observer_.reset(new WindowBoundsChangeObserver()); | 250 window_bounds_observer_.reset(new WindowBoundsChangeObserver()); |
250 } | 251 } |
251 | 252 |
252 KeyboardController::~KeyboardController() { | 253 KeyboardController::~KeyboardController() { |
253 if (container_) | 254 if (container_) |
254 container_->RemoveObserver(this); | 255 container_->RemoveObserver(this); |
255 if (input_method_) | 256 if (input_method_) { |
256 input_method_->RemoveObserver(this); | 257 input_method_->RemoveObserver(this); |
| 258 input_method_->SetSupportsOnScreenKeyboard(false); |
| 259 } |
257 ResetWindowInsets(); | 260 ResetWindowInsets(); |
258 } | 261 } |
259 | 262 |
260 // static | 263 // static |
261 void KeyboardController::ResetInstance(KeyboardController* controller) { | 264 void KeyboardController::ResetInstance(KeyboardController* controller) { |
262 if (instance_ && instance_ != controller) | 265 if (instance_ && instance_ != controller) |
263 delete instance_; | 266 delete instance_; |
264 instance_ = controller; | 267 instance_ = controller; |
265 } | 268 } |
266 | 269 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 void KeyboardController::OnInputMethodDestroyed( | 428 void KeyboardController::OnInputMethodDestroyed( |
426 const ui::InputMethod* input_method) { | 429 const ui::InputMethod* input_method) { |
427 DCHECK_EQ(input_method_, input_method); | 430 DCHECK_EQ(input_method_, input_method); |
428 input_method_ = NULL; | 431 input_method_ = NULL; |
429 } | 432 } |
430 | 433 |
431 void KeyboardController::OnShowImeIfNeeded() { | 434 void KeyboardController::OnShowImeIfNeeded() { |
432 ShowKeyboardInternal(); | 435 ShowKeyboardInternal(); |
433 } | 436 } |
434 | 437 |
| 438 void KeyboardController::OnKeyboardBoundsUnchanged() {} |
| 439 |
435 bool KeyboardController::ShouldEnableInsets(aura::Window* window) { | 440 bool KeyboardController::ShouldEnableInsets(aura::Window* window) { |
436 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); | 441 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); |
437 return (keyboard_window->GetRootWindow() == window->GetRootWindow() && | 442 return (keyboard_window->GetRootWindow() == window->GetRootWindow() && |
438 keyboard::IsKeyboardOverscrollEnabled() && | 443 keyboard::IsKeyboardOverscrollEnabled() && |
439 proxy_->GetKeyboardWindow()->IsVisible() && | 444 proxy_->GetKeyboardWindow()->IsVisible() && |
440 keyboard_visible_); | 445 keyboard_visible_); |
441 } | 446 } |
442 | 447 |
443 void KeyboardController::UpdateWindowInsets(aura::Window* window) { | 448 void KeyboardController::UpdateWindowInsets(aura::Window* window) { |
444 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); | 449 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); |
(...skipping 26 matching lines...) Expand all Loading... |
471 keyboard::MarkKeyboardLoadStarted(); | 476 keyboard::MarkKeyboardLoadStarted(); |
472 aura::Window* keyboard = proxy_->GetKeyboardWindow(); | 477 aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
473 keyboard->Show(); | 478 keyboard->Show(); |
474 container_->AddChild(keyboard); | 479 container_->AddChild(keyboard); |
475 keyboard->set_owned_by_parent(false); | 480 keyboard->set_owned_by_parent(false); |
476 } | 481 } |
477 | 482 |
478 proxy_->ReloadKeyboardIfNeeded(); | 483 proxy_->ReloadKeyboardIfNeeded(); |
479 | 484 |
480 if (keyboard_visible_) { | 485 if (keyboard_visible_) { |
| 486 proxy_->GetInputMethod()->NotifyKeyboardBoundsUnchanged(); |
481 return; | 487 return; |
482 } else if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { | 488 } else if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { |
483 show_on_resize_ = true; | 489 show_on_resize_ = true; |
484 return; | 490 return; |
485 } | 491 } |
486 | 492 |
487 keyboard_visible_ = true; | 493 keyboard_visible_ = true; |
488 | 494 |
489 // If the controller is in the process of hiding the keyboard, do not log | 495 // If the controller is in the process of hiding the keyboard, do not log |
490 // the stat here since the keyboard will not actually be shown. | 496 // the stat here since the keyboard will not actually be shown. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 proxy_->HideKeyboardContainer(container_.get()); | 570 proxy_->HideKeyboardContainer(container_.get()); |
565 } | 571 } |
566 | 572 |
567 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { | 573 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
568 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 574 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
569 if (target_window) | 575 if (target_window) |
570 window_bounds_observer_->AddObservedWindow(target_window); | 576 window_bounds_observer_->AddObservedWindow(target_window); |
571 } | 577 } |
572 | 578 |
573 } // namespace keyboard | 579 } // namespace keyboard |
OLD | NEW |