Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: ui/keyboard/keyboard_ui.cc

Issue 2553603002: New accessibility virtual keyboard behavior in non-sticky mode. (Closed)
Patch Set: Remove unused variable Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ui.h" 5 #include "ui/keyboard/keyboard_ui.h"
6 6
7 #include "base/command_line.h"
7 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
8 #include "ui/base/ime/input_method.h" 9 #include "ui/base/ime/input_method.h"
9 #include "ui/base/ime/text_input_client.h" 10 #include "ui/base/ime/text_input_client.h"
11 #include "ui/base/ui_base_switches.h"
10 #include "ui/keyboard/keyboard_controller.h" 12 #include "ui/keyboard/keyboard_controller.h"
11 13
12 namespace keyboard { 14 namespace keyboard {
13 15
14 KeyboardUI::KeyboardUI() : keyboard_controller_(nullptr) {} 16 KeyboardUI::KeyboardUI() : keyboard_controller_(nullptr) {}
15 KeyboardUI::~KeyboardUI() {} 17 KeyboardUI::~KeyboardUI() {}
16 18
17 void KeyboardUI::ShowKeyboardContainer(aura::Window* container) { 19 void KeyboardUI::ShowKeyboardContainer(aura::Window* container) {
18 if (HasKeyboardWindow()) { 20 if (HasKeyboardWindow()) {
19 GetKeyboardWindow()->Show(); 21 GetKeyboardWindow()->Show();
20 container->Show(); 22 container->Show();
21 } 23 }
22 } 24 }
23 25
24 void KeyboardUI::HideKeyboardContainer(aura::Window* container) { 26 void KeyboardUI::HideKeyboardContainer(aura::Window* container) {
25 if (HasKeyboardWindow()) { 27 if (HasKeyboardWindow()) {
26 container->Hide(); 28 container->Hide();
27 GetKeyboardWindow()->Hide(); 29 GetKeyboardWindow()->Hide();
28 } 30 }
29 } 31 }
30 32
31 void KeyboardUI::EnsureCaretInWorkArea() { 33 void KeyboardUI::EnsureCaretInWorkArea() {
32 if (GetInputMethod()->GetTextInputClient()) { 34 if (GetInputMethod()) {
oshima 2017/04/17 13:24:22 nit: quit early
yhanada 2017/04/26 11:29:45 Done.
33 aura::Window* keyboard_window = GetKeyboardWindow(); 35 const aura::Window* keyboard_window = GetKeyboardWindow();
34 GetInputMethod()->GetTextInputClient()->EnsureCaretNotInRect( 36 const gfx::Rect keyboard_bounds_in_screen =
35 keyboard_window->GetBoundsInScreen()); 37 keyboard_window->IsVisible() ? keyboard_window->GetBoundsInScreen()
38 : gfx::Rect();
39
40 // Use new virtual keyboard behavior only if the flag enabled and in
41 // non-sticky mode.
42 const bool new_vk_behavior =
43 (base::CommandLine::ForCurrentProcess()->HasSwitch(
44 ::switches::kUseNewVirtualKeyboardBehavior) &&
45 !keyboard::KeyboardController::GetInstance()->keyboard_locked());
46
47 if (new_vk_behavior) {
48 GetInputMethod()->SetOnScreenKeyboardBounds(keyboard_bounds_in_screen);
49 } else if (GetInputMethod()->GetTextInputClient()) {
50 GetInputMethod()->GetTextInputClient()->EnsureCaretNotInRect(
51 keyboard_bounds_in_screen);
52 }
36 } 53 }
37 } 54 }
38 55
39 void KeyboardUI::SetController(KeyboardController* controller) { 56 void KeyboardUI::SetController(KeyboardController* controller) {
40 keyboard_controller_ = controller; 57 keyboard_controller_ = controller;
41 } 58 }
42 59
43 } // namespace keyboard 60 } // namespace keyboard
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698