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_proxy.h" | 5 #include "ui/keyboard/keyboard_controller_proxy.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "content/public/browser/site_instance.h" | 9 #include "content/public/browser/site_instance.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
15 #include "content/public/common/bindings_policy.h" | 15 #include "content/public/common/bindings_policy.h" |
16 #include "ui/aura/layout_manager.h" | 16 #include "ui/aura/layout_manager.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/base/ime/input_method.h" |
| 19 #include "ui/base/ime/text_input_client.h" |
18 #include "ui/keyboard/keyboard_constants.h" | 20 #include "ui/keyboard/keyboard_constants.h" |
19 #include "ui/keyboard/keyboard_switches.h" | 21 #include "ui/keyboard/keyboard_switches.h" |
20 #include "ui/keyboard/keyboard_util.h" | 22 #include "ui/keyboard/keyboard_util.h" |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 // The WebContentsDelegate for the keyboard. | 26 // The WebContentsDelegate for the keyboard. |
25 // The delegate deletes itself when the keyboard is destroyed. | 27 // The delegate deletes itself when the keyboard is destroyed. |
26 class KeyboardContentsDelegate : public content::WebContentsDelegate, | 28 class KeyboardContentsDelegate : public content::WebContentsDelegate, |
27 public content::WebContentsObserver { | 29 public content::WebContentsObserver { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 137 |
136 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) { | 138 void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) { |
137 container->Hide(); | 139 container->Hide(); |
138 GetKeyboardWindow()->Hide(); | 140 GetKeyboardWindow()->Hide(); |
139 } | 141 } |
140 | 142 |
141 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { | 143 void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) { |
142 } | 144 } |
143 | 145 |
144 void KeyboardControllerProxy::EnsureCaretInWorkArea() { | 146 void KeyboardControllerProxy::EnsureCaretInWorkArea() { |
| 147 if (GetInputMethod()->GetTextInputClient()) { |
| 148 aura::Window* keyboard_window = GetKeyboardWindow(); |
| 149 aura::Window* root_window = keyboard_window->GetRootWindow(); |
| 150 gfx::Rect available_bounds = root_window->bounds(); |
| 151 gfx::Rect keyboard_bounds = keyboard_window->bounds(); |
| 152 available_bounds.set_height(available_bounds.height() - |
| 153 keyboard_bounds.height()); |
| 154 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(available_bounds); |
| 155 } |
145 } | 156 } |
146 | 157 |
147 void KeyboardControllerProxy::LoadSystemKeyboard() { | 158 void KeyboardControllerProxy::LoadSystemKeyboard() { |
148 DCHECK(keyboard_contents_); | 159 DCHECK(keyboard_contents_); |
149 if (keyboard_contents_->GetURL() != default_url_) { | 160 if (keyboard_contents_->GetURL() != default_url_) { |
150 // TODO(bshe): The height of system virtual keyboard and IME virtual | 161 // TODO(bshe): The height of system virtual keyboard and IME virtual |
151 // keyboard may different. The height needs to be restored too. | 162 // keyboard may different. The height needs to be restored too. |
152 LoadContents(default_url_); | 163 LoadContents(default_url_); |
153 } | 164 } |
154 } | 165 } |
155 | 166 |
156 void KeyboardControllerProxy::ReloadKeyboardIfNeeded() { | 167 void KeyboardControllerProxy::ReloadKeyboardIfNeeded() { |
157 DCHECK(keyboard_contents_); | 168 DCHECK(keyboard_contents_); |
158 if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) { | 169 if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) { |
159 LoadContents(GetVirtualKeyboardUrl()); | 170 LoadContents(GetVirtualKeyboardUrl()); |
160 } | 171 } |
161 } | 172 } |
162 | 173 |
163 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { | 174 void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) { |
164 } | 175 } |
165 | 176 |
166 } // namespace keyboard | 177 } // namespace keyboard |
OLD | NEW |