Chromium Code Reviews| Index: ui/keyboard/keyboard_ui.cc |
| diff --git a/ui/keyboard/keyboard_ui.cc b/ui/keyboard/keyboard_ui.cc |
| index 896add64cb2fa7fb0d84096e41a51c31141d9c9b..bcba2b3b13758a840a53cb2a6c3ab6534b452c4d 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,10 +31,25 @@ void KeyboardUI::HideKeyboardContainer(aura::Window* container) { |
| } |
| void KeyboardUI::EnsureCaretInWorkArea() { |
| - if (GetInputMethod()->GetTextInputClient()) { |
| - aura::Window* keyboard_window = GetKeyboardWindow(); |
| - GetInputMethod()->GetTextInputClient()->EnsureCaretNotInRect( |
| - keyboard_window->GetBoundsInScreen()); |
| + if (GetInputMethod()) { |
|
oshima
2017/04/17 13:24:22
nit: quit early
yhanada
2017/04/26 11:29:45
Done.
|
| + const aura::Window* keyboard_window = GetKeyboardWindow(); |
| + const gfx::Rect keyboard_bounds_in_screen = |
| + keyboard_window->IsVisible() ? keyboard_window->GetBoundsInScreen() |
| + : gfx::Rect(); |
| + |
| + // Use new virtual keyboard behavior only if the flag enabled and in |
| + // non-sticky mode. |
| + const bool new_vk_behavior = |
| + (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + ::switches::kUseNewVirtualKeyboardBehavior) && |
| + !keyboard::KeyboardController::GetInstance()->keyboard_locked()); |
| + |
| + if (new_vk_behavior) { |
| + GetInputMethod()->SetOnScreenKeyboardBounds(keyboard_bounds_in_screen); |
| + } else if (GetInputMethod()->GetTextInputClient()) { |
| + GetInputMethod()->GetTextInputClient()->EnsureCaretNotInRect( |
| + keyboard_bounds_in_screen); |
| + } |
| } |
| } |