| Index: ui/keyboard/keyboard_ui.cc
|
| diff --git a/ui/keyboard/keyboard_ui.cc b/ui/keyboard/keyboard_ui.cc
|
| index 816933bf7e6afbb60488e9af8e7030645900125f..b0e4efbc89d1d3361d1d51ef75e334f897efe07d 100644
|
| --- a/ui/keyboard/keyboard_ui.cc
|
| +++ b/ui/keyboard/keyboard_ui.cc
|
| @@ -4,9 +4,11 @@
|
|
|
| #include "ui/keyboard/keyboard_ui.h"
|
|
|
| +#include "base/command_line.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/base/ime/input_method.h"
|
| #include "ui/base/ime/text_input_client.h"
|
| +#include "ui/base/ui_base_switches.h"
|
| #include "ui/keyboard/keyboard_controller.h"
|
|
|
| namespace keyboard {
|
| @@ -29,14 +31,31 @@ void KeyboardUI::HideKeyboardContainer(aura::Window* container) {
|
| }
|
|
|
| void KeyboardUI::EnsureCaretInWorkArea() {
|
| - if (GetInputMethod()->GetTextInputClient()) {
|
| + if (GetInputMethod()) {
|
| aura::Window* keyboard_window = GetKeyboardWindow();
|
| aura::Window* root_window = keyboard_window->GetRootWindow();
|
| gfx::Rect available_bounds = root_window->bounds();
|
| gfx::Rect keyboard_bounds = keyboard_window->bounds();
|
| - available_bounds.set_height(available_bounds.height() -
|
| - keyboard_bounds.height());
|
| - GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(available_bounds);
|
| +
|
| + // Only use new virtual keyboard behavior if flag enabled and in non-sticky
|
| + // mode.
|
| + bool new_vk_behavior =
|
| + (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + ::switches::kUseNewVKWindowBehavior) &&
|
| + !keyboard::KeyboardController::GetInstance()->get_lock_keyboard());
|
| +
|
| + if (new_vk_behavior) {
|
| + // Inform InputMethod of new available screen bounds
|
| + if (keyboard_controller_->keyboard_visible())
|
| + available_bounds.set_height(available_bounds.height() -
|
| + keyboard_bounds.height());
|
| + GetInputMethod()->set_available_bounds(available_bounds);
|
| + } else if (GetInputMethod()->GetTextInputClient()) {
|
| + available_bounds.set_height(available_bounds.height() -
|
| + keyboard_bounds.height());
|
| + GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(
|
| + available_bounds);
|
| + }
|
| }
|
| }
|
|
|
|
|