summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben <ben@chromium.org>2015-10-09 17:45:12 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-10 00:45:50 +0000
commit974286a2cb68813b64c27c0fcd99cdfd899a007a (patch)
treea7d987599a5551deb75d0bef9877712e3e47db2f
parent77970f1c3cd71d535a248d6e15f14081312b300a (diff)
downloadchromium_src-974286a2cb68813b64c27c0fcd99cdfd899a007a.zip
chromium_src-974286a2cb68813b64c27c0fcd99cdfd899a007a.tar.gz
chromium_src-974286a2cb68813b64c27c0fcd99cdfd899a007a.tar.bz2
Extract content dependency from keyboard code
Move content specific stuff to content subdir. KeyboardControllerProxy -> KeyboardUI Restructure targets. R=sky@chromium.org http://crbug.com/332504 Review URL: https://codereview.chromium.org/1392713002 Cr-Commit-Position: refs/heads/master@{#353441}
-rw-r--r--ash/BUILD.gn4
-rw-r--r--ash/ash.gyp8
-rw-r--r--ash/content/shell_content_state.cc9
-rw-r--r--ash/root_window_controller_unittest.cc26
-rw-r--r--ash/shell.cc11
-rw-r--r--ash/shell/shell_delegate_impl.cc7
-rw-r--r--ash/shell/shell_delegate_impl.h4
-rw-r--r--ash/shell_delegate.h7
-rw-r--r--ash/test/content/keyboard_controller_proxy_stub.cc51
-rw-r--r--ash/test/content/keyboard_controller_proxy_stub.h43
-rw-r--r--ash/test/test_keyboard_ui.cc43
-rw-r--r--ash/test/test_keyboard_ui.h42
-rw-r--r--ash/test/test_shell_delegate.cc7
-rw-r--r--ash/test/test_shell_delegate.h4
-rw-r--r--ash/wm/always_on_top_controller_unittest.cc6
-rw-r--r--ash/wm/lock_layout_manager_unittest.cc11
-rw-r--r--ash/wm/system_modal_container_layout_manager_unittest.cc6
-rw-r--r--chrome/browser/BUILD.gn1
-rw-r--r--chrome/browser/extensions/BUILD.gn1
-rw-r--r--chrome/browser/extensions/chrome_component_extension_resource_manager.cc2
-rw-r--r--chrome/browser/ui/BUILD.gn1
-rw-r--r--chrome/browser/ui/ash/chrome_keyboard_ui.cc (renamed from chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc)39
-rw-r--r--chrome/browser/ui/ash/chrome_keyboard_ui.h (renamed from chrome/browser/ui/ash/ash_keyboard_controller_proxy.h)21
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.cc8
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.h4
-rw-r--r--chrome/browser/ui/ash/keyboard_controller_browsertest.cc18
-rw-r--r--chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc2
-rw-r--r--chrome/chrome_browser.gypi1
-rw-r--r--chrome/chrome_browser_extensions.gypi1
-rw-r--r--chrome/chrome_browser_ui.gypi5
-rw-r--r--chrome/common/extensions/chrome_manifest_url_handlers.cc2
-rw-r--r--ui/keyboard/BUILD.gn53
-rw-r--r--ui/keyboard/content/DEPS0
-rw-r--r--ui/keyboard/content/keyboard.cc (renamed from ui/keyboard/keyboard.cc)4
-rw-r--r--ui/keyboard/content/keyboard.h (renamed from ui/keyboard/keyboard.h)0
-rw-r--r--ui/keyboard/content/keyboard_constants.cc (renamed from ui/keyboard/keyboard_constants.cc)4
-rw-r--r--ui/keyboard/content/keyboard_constants.h (renamed from ui/keyboard/keyboard_constants.h)8
-rw-r--r--ui/keyboard/content/keyboard_content_util.cc108
-rw-r--r--ui/keyboard/content/keyboard_content_util.h31
-rw-r--r--ui/keyboard/content/keyboard_ui_content.cc321
-rw-r--r--ui/keyboard/content/keyboard_ui_content.h127
-rw-r--r--ui/keyboard/keyboard.gyp53
-rw-r--r--ui/keyboard/keyboard_controller.cc172
-rw-r--r--ui/keyboard/keyboard_controller.h28
-rw-r--r--ui/keyboard/keyboard_controller_proxy.cc232
-rw-r--r--ui/keyboard/keyboard_controller_proxy.h151
-rw-r--r--ui/keyboard/keyboard_controller_unittest.cc60
-rw-r--r--ui/keyboard/keyboard_layout_manager.cc1
-rw-r--r--ui/keyboard/keyboard_ui.cc47
-rw-r--r--ui/keyboard/keyboard_ui.h94
-rw-r--r--ui/keyboard/keyboard_util.cc99
-rw-r--r--ui/keyboard/keyboard_util.h8
52 files changed, 1066 insertions, 930 deletions
diff --git a/ash/BUILD.gn b/ash/BUILD.gn
index 3d7d2f9..6f5e693 100644
--- a/ash/BUILD.gn
+++ b/ash/BUILD.gn
@@ -47,6 +47,7 @@ component("ash") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/keyboard",
+ "//ui/keyboard:keyboard_with_content",
"//ui/message_center",
"//ui/resources",
"//ui/strings",
@@ -157,6 +158,7 @@ component("ash_with_content") {
"//ui/events",
"//ui/gfx",
"//ui/gfx/geometry",
+ "//ui/keyboard:keyboard_with_content",
"//ui/resources",
"//ui/strings",
"//ui/views",
@@ -251,6 +253,7 @@ static_library("ash_shell_lib") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/keyboard",
+ "//ui/keyboard:keyboard_with_content",
"//ui/message_center",
"//ui/resources",
"//ui/views",
@@ -307,6 +310,7 @@ test("ash_unittests") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/keyboard",
+ "//ui/keyboard:keyboard_with_content",
"//ui/message_center",
"//ui/message_center:test_support",
"//ui/resources",
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 4994964..83fbb9b 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -724,6 +724,8 @@
'test/task_switch_time_tracker_test_api.h',
'test/test_activation_delegate.cc',
'test/test_activation_delegate.h',
+ 'test/test_keyboard_ui.cc',
+ 'test/test_keyboard_ui.h',
'test/test_lock_state_controller_delegate.cc',
'test/test_lock_state_controller_delegate.h',
'test/test_overlay_delegate.cc',
@@ -760,8 +762,6 @@
'test/virtual_keyboard_test_helper.h',
],
'ash_test_support_with_content_sources': [
- 'test/content/keyboard_controller_proxy_stub.cc',
- 'test/content/keyboard_controller_proxy_stub.h',
'test/content/test_shell_content_state.cc',
'test/content/test_shell_content_state.h',
],
@@ -969,6 +969,7 @@
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
'../ui/keyboard/keyboard.gyp:keyboard',
+ '../ui/keyboard/keyboard.gyp:keyboard_with_content',
'../ui/message_center/message_center.gyp:message_center',
'../ui/resources/ui_resources.gyp:ui_resources',
'../ui/strings/ui_strings.gyp:ui_strings',
@@ -1063,6 +1064,7 @@
'../ui/events/events.gyp:events',
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
+ '../ui/keyboard/keyboard.gyp:keyboard_with_content',
'../ui/resources/ui_resources.gyp:ui_resources',
'../ui/strings/ui_strings.gyp:ui_strings',
'../ui/views/controls/webview/webview.gyp:webview',
@@ -1164,6 +1166,7 @@
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
'../ui/keyboard/keyboard.gyp:keyboard',
+ '../ui/keyboard/keyboard.gyp:keyboard_with_content',
'../ui/message_center/message_center.gyp:message_center',
'../ui/message_center/message_center.gyp:message_center_test_support',
'../ui/resources/ui_resources.gyp:ui_resources',
@@ -1264,6 +1267,7 @@
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
'../ui/keyboard/keyboard.gyp:keyboard',
+ '../ui/keyboard/keyboard.gyp:keyboard_with_content',
'../ui/message_center/message_center.gyp:message_center',
'../ui/resources/ui_resources.gyp:ui_resources',
'../ui/views/examples/examples.gyp:views_examples_lib',
diff --git a/ash/content/shell_content_state.cc b/ash/content/shell_content_state.cc
index d40ba6d..990c27c 100644
--- a/ash/content/shell_content_state.cc
+++ b/ash/content/shell_content_state.cc
@@ -5,6 +5,7 @@
#include "ash/content/shell_content_state.h"
#include "base/logging.h"
+#include "ui/keyboard/content/keyboard.h"
namespace ash {
@@ -30,7 +31,13 @@ void ShellContentState::DestroyInstance() {
instance_ = nullptr;
}
-ShellContentState::ShellContentState() {}
+ShellContentState::ShellContentState() {
+// The keyboard system must be initialized before the RootWindowController is
+// created.
+#if defined(OS_CHROMEOS)
+ keyboard::InitializeKeyboard();
+#endif
+}
ShellContentState::~ShellContentState() {}
} // namespace ash
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc
index 923fdce..e0f9ecc 100644
--- a/ash/root_window_controller_unittest.cc
+++ b/ash/root_window_controller_unittest.cc
@@ -32,8 +32,8 @@
#include "ui/base/ime/text_input_client.h"
#include "ui/events/test/event_generator.h"
#include "ui/events/test/test_event_handler.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_switches.h"
+#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/widget/widget.h"
@@ -770,8 +770,8 @@ TEST_F(VirtualKeyboardRootWindowControllerTest,
ASSERT_TRUE(keyboard_container);
keyboard_container->Show();
- aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()->
- proxy()->GetKeyboardWindow();
+ aura::Window* keyboard_window =
+ keyboard::KeyboardController::GetInstance()->ui()->GetKeyboardWindow();
keyboard_container->AddChild(keyboard_window);
keyboard_window->set_owned_by_parent(false);
keyboard_window->SetBounds(gfx::Rect());
@@ -824,7 +824,7 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) {
keyboard_container->Show();
keyboard::KeyboardController* controller =
keyboard::KeyboardController::GetInstance();
- aura::Window* keyboard_window = controller->proxy()->GetKeyboardWindow();
+ aura::Window* keyboard_window = controller->ui()->GetKeyboardWindow();
keyboard_container->AddChild(keyboard_window);
keyboard_window->set_owned_by_parent(false);
keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds(
@@ -855,8 +855,8 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) {
ASSERT_TRUE(keyboard_container);
keyboard_container->Show();
- aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()->
- proxy()->GetKeyboardWindow();
+ aura::Window* keyboard_window =
+ keyboard::KeyboardController::GetInstance()->ui()->GetKeyboardWindow();
keyboard_container->AddChild(keyboard_window);
keyboard_window->set_owned_by_parent(false);
keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds(
@@ -893,10 +893,10 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) {
TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) {
keyboard::KeyboardController* keyboard_controller =
keyboard::KeyboardController::GetInstance();
- keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy();
+ keyboard::KeyboardUI* ui = keyboard_controller->ui();
MockTextInputClient text_input_client;
- ui::InputMethod* input_method = proxy->GetInputMethod();
+ ui::InputMethod* input_method = ui->GetInputMethod();
ASSERT_TRUE(input_method);
input_method->SetFocusedTextInputClient(&text_input_client);
@@ -907,13 +907,13 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) {
keyboard_container->Show();
const int keyboard_height = 100;
- aura::Window* keyboard_window =proxy->GetKeyboardWindow();
+ aura::Window* keyboard_window = ui->GetKeyboardWindow();
keyboard_container->AddChild(keyboard_window);
keyboard_window->set_owned_by_parent(false);
keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds(
root_window->bounds(), keyboard_height));
- proxy->EnsureCaretInWorkArea();
+ ui->EnsureCaretInWorkArea();
ASSERT_EQ(root_window->bounds().width(),
text_input_client.visible_rect().width());
ASSERT_EQ(root_window->bounds().height() - keyboard_height,
@@ -929,7 +929,7 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) {
UpdateDisplay("800x600");
keyboard::KeyboardController* keyboard_controller =
keyboard::KeyboardController::GetInstance();
- keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy();
+ keyboard::KeyboardUI* ui = keyboard_controller->ui();
aura::Window* root_window = Shell::GetPrimaryRootWindow();
aura::Window* keyboard_container =
@@ -938,7 +938,7 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) {
keyboard_container->Show();
const int keyboard_height = 200;
- aura::Window* keyboard_window = proxy->GetKeyboardWindow();
+ aura::Window* keyboard_window = ui->GetKeyboardWindow();
keyboard_container->AddChild(keyboard_window);
keyboard_window->set_owned_by_parent(false);
gfx::Rect keyboard_bounds = keyboard::FullWidthKeyboardBoundsFromRootBounds(
@@ -1027,7 +1027,7 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, MAYBE_DisplayRotation) {
keyboard::KeyboardController* keyboard_controller =
keyboard::KeyboardController::GetInstance();
keyboard_controller->ShowKeyboard(false);
- keyboard_controller->proxy()->GetKeyboardWindow()->SetBounds(
+ keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
gfx::Rect(0, 400, 800, 200));
EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
diff --git a/ash/shell.cc b/ash/shell.cc
index 20f464d..72eb8eb 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -96,7 +96,6 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/screen.h"
-#include "ui/keyboard/keyboard.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_util.h"
@@ -959,12 +958,6 @@ void Shell::Init(const ShellInitParams& init_params) {
keyboard_metrics_filter_.reset(new KeyboardUMAEventFilter);
AddPreTargetHandler(keyboard_metrics_filter_.get());
- // The keyboard system must be initialized before the RootWindowController is
- // created.
-#if defined(OS_CHROMEOS)
- keyboard::InitializeKeyboard();
-#endif
-
#if defined(OS_CHROMEOS)
sticky_keys_controller_.reset(new StickyKeysController);
#endif
@@ -1105,10 +1098,8 @@ void Shell::InitKeyboard() {
keyboard::KeyboardController::GetInstance());
}
}
- keyboard::KeyboardControllerProxy* proxy =
- delegate_->CreateKeyboardControllerProxy();
keyboard::KeyboardController::ResetInstance(
- new keyboard::KeyboardController(proxy));
+ new keyboard::KeyboardController(delegate_->CreateKeyboardUI()));
}
}
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index db062e0..7618cd7 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -18,7 +18,7 @@
#include "ash/shell/toplevel_window.h"
#include "ash/shell_window_ids.h"
#include "ash/system/tray/default_system_tray_delegate.h"
-#include "ash/test/content/keyboard_controller_proxy_stub.h"
+#include "ash/test/test_keyboard_ui.h"
#include "ash/wm/window_state.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
@@ -187,9 +187,8 @@ void ShellDelegateImpl::Exit() {
base::MessageLoopForUI::current()->Quit();
}
-keyboard::KeyboardControllerProxy*
- ShellDelegateImpl::CreateKeyboardControllerProxy() {
- return new KeyboardControllerProxyStub();
+keyboard::KeyboardUI* ShellDelegateImpl::CreateKeyboardUI() {
+ return new TestKeyboardUI;
}
void ShellDelegateImpl::VirtualKeyboardActivated(bool activated) {
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index 4f0e3e4..acab404 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -11,7 +11,7 @@
#include "base/compiler_specific.h"
namespace keyboard {
-class KeyboardControllerProxy;
+class KeyboardUI;
}
namespace ash {
@@ -37,7 +37,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
void PreInit() override;
void PreShutdown() override;
void Exit() override;
- keyboard::KeyboardControllerProxy* CreateKeyboardControllerProxy() override;
+ keyboard::KeyboardUI* CreateKeyboardUI() override;
void VirtualKeyboardActivated(bool activated) override;
void AddVirtualKeyboardStateObserver(
VirtualKeyboardStateObserver* observer) override;
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index a366862..f2c3971 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -38,7 +38,7 @@ class Widget;
}
namespace keyboard {
-class KeyboardControllerProxy;
+class KeyboardUI;
}
namespace ash {
@@ -107,9 +107,8 @@ class ASH_EXPORT ShellDelegate {
// Invoked when the user uses Ctrl-Shift-Q to close chrome.
virtual void Exit() = 0;
- // Create a shell-specific keyboard::KeyboardControllerProxy
- virtual keyboard::KeyboardControllerProxy*
- CreateKeyboardControllerProxy() = 0;
+ // Create a shell-specific keyboard::KeyboardUI
+ virtual keyboard::KeyboardUI* CreateKeyboardUI() = 0;
// Called when virtual keyboard has been activated/deactivated.
virtual void VirtualKeyboardActivated(bool activated) = 0;
diff --git a/ash/test/content/keyboard_controller_proxy_stub.cc b/ash/test/content/keyboard_controller_proxy_stub.cc
deleted file mode 100644
index 255c61f..0000000
--- a/ash/test/content/keyboard_controller_proxy_stub.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/test/content/keyboard_controller_proxy_stub.h"
-
-#include "ash/content/shell_content_state.h"
-#include "ash/shell.h"
-#include "ash/shell_delegate.h"
-#include "ash/wm/window_util.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/base/ime/mock_input_method.h"
-
-namespace ash {
-
-KeyboardControllerProxyStub::KeyboardControllerProxyStub()
- : keyboard::KeyboardControllerProxy(ShellContentState::GetInstance()
- ->GetActiveBrowserContext()) {}
-
-KeyboardControllerProxyStub::~KeyboardControllerProxyStub() {}
-
-bool KeyboardControllerProxyStub::HasKeyboardWindow() const {
- return keyboard_;
-}
-
-aura::Window* KeyboardControllerProxyStub::GetKeyboardWindow() {
- if (!keyboard_) {
- keyboard_.reset(new aura::Window(&delegate_));
- keyboard_->Init(ui::LAYER_NOT_DRAWN);
- }
- return keyboard_.get();
-}
-
-ui::InputMethod* KeyboardControllerProxyStub::GetInputMethod() {
- aura::Window* active_window = wm::GetActiveWindow();
- aura::Window* root_window = active_window ? active_window->GetRootWindow()
- : Shell::GetPrimaryRootWindow();
- return root_window->GetHost()->GetInputMethod();
-}
-
-void KeyboardControllerProxyStub::RequestAudioInput(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) {}
-
-void KeyboardControllerProxyStub::LoadSystemKeyboard() {}
-
-void KeyboardControllerProxyStub::ReloadKeyboardIfNeeded() {}
-
-} // namespace ash
diff --git a/ash/test/content/keyboard_controller_proxy_stub.h b/ash/test/content/keyboard_controller_proxy_stub.h
deleted file mode 100644
index af1425d..0000000
--- a/ash/test/content/keyboard_controller_proxy_stub.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_TEST_CONTENT_KEYBOARD_CONTROLLER_PROXY_STUB_H_
-#define ASH_TEST_CONTENT_KEYBOARD_CONTROLLER_PROXY_STUB_H_
-
-#include "ui/aura/test/test_window_delegate.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
-
-namespace aura {
-class Window;
-} // namespace aura
-
-namespace ash {
-
-// Stub implementation of KeyboardControllerProxy
-class KeyboardControllerProxyStub : public keyboard::KeyboardControllerProxy {
- public:
- KeyboardControllerProxyStub();
- ~KeyboardControllerProxyStub() override;
-
- bool HasKeyboardWindow() const override;
- aura::Window* GetKeyboardWindow() override;
-
- private:
- // Overridden from keyboard::KeyboardControllerProxy:
- ui::InputMethod* GetInputMethod() override;
- void RequestAudioInput(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) override;
- void LoadSystemKeyboard() override;
- void ReloadKeyboardIfNeeded() override;
-
- aura::test::TestWindowDelegate delegate_;
- scoped_ptr<aura::Window> keyboard_;
- DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxyStub);
-};
-
-} // namespace ash
-
-#endif // ASH_TEST_CONTENT_KEYBOARD_CONTROLLER_PROXY_STUB_H_
diff --git a/ash/test/test_keyboard_ui.cc b/ash/test/test_keyboard_ui.cc
new file mode 100644
index 0000000..b99266c
--- /dev/null
+++ b/ash/test/test_keyboard_ui.cc
@@ -0,0 +1,43 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/test/test_keyboard_ui.h"
+
+#include "ash/shell.h"
+#include "ash/shell_delegate.h"
+#include "ash/wm/window_util.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/base/ime/mock_input_method.h"
+
+namespace ash {
+
+TestKeyboardUI::TestKeyboardUI() {}
+TestKeyboardUI::~TestKeyboardUI() {}
+
+bool TestKeyboardUI::HasKeyboardWindow() const {
+ return keyboard_;
+}
+
+aura::Window* TestKeyboardUI::GetKeyboardWindow() {
+ if (!keyboard_) {
+ keyboard_.reset(new aura::Window(&delegate_));
+ keyboard_->Init(ui::LAYER_NOT_DRAWN);
+ }
+ return keyboard_.get();
+}
+
+ui::InputMethod* TestKeyboardUI::GetInputMethod() {
+ aura::Window* active_window = wm::GetActiveWindow();
+ aura::Window* root_window = active_window ? active_window->GetRootWindow()
+ : Shell::GetPrimaryRootWindow();
+ return root_window->GetHost()->GetInputMethod();
+}
+
+void TestKeyboardUI::SetUpdateInputType(ui::TextInputType type) {}
+void TestKeyboardUI::ReloadKeyboardIfNeeded() {}
+void TestKeyboardUI::InitInsets(const gfx::Rect& keyboard_bounds) {}
+void TestKeyboardUI::ResetInsets() {}
+
+} // namespace ash
diff --git a/ash/test/test_keyboard_ui.h b/ash/test/test_keyboard_ui.h
new file mode 100644
index 0000000..d1c1f75
--- /dev/null
+++ b/ash/test/test_keyboard_ui.h
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_TEST_TEST_KEYBOARD_UI_H_
+#define ASH_TEST_TEST_KEYBOARD_UI_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/aura/test/test_window_delegate.h"
+#include "ui/keyboard/keyboard_ui.h"
+
+namespace aura {
+class Window;
+} // namespace aura
+
+namespace ash {
+
+// Stub implementation of keyboard::KeyboardUI
+class TestKeyboardUI : public keyboard::KeyboardUI {
+ public:
+ TestKeyboardUI();
+ ~TestKeyboardUI() override;
+
+ bool HasKeyboardWindow() const override;
+ aura::Window* GetKeyboardWindow() override;
+
+ private:
+ // Overridden from keyboard::KeyboardUI:
+ ui::InputMethod* GetInputMethod() override;
+ void SetUpdateInputType(ui::TextInputType type) override;
+ void ReloadKeyboardIfNeeded() override;
+ void InitInsets(const gfx::Rect& keyboard_bounds) override;
+ void ResetInsets() override;
+
+ aura::test::TestWindowDelegate delegate_;
+ scoped_ptr<aura::Window> keyboard_;
+ DISALLOW_COPY_AND_ASSIGN(TestKeyboardUI);
+};
+
+} // namespace ash
+
+#endif // ASH_TEST_TEST_KEYBOARD_UI_H_
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 8eb4c2a..d601cde 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -13,7 +13,7 @@
#include "ash/session/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
-#include "ash/test/content/keyboard_controller_proxy_stub.h"
+#include "ash/test/test_keyboard_ui.h"
#include "ash/test/test_session_state_delegate.h"
#include "ash/test/test_shelf_delegate.h"
#include "ash/test/test_system_tray_delegate.h"
@@ -130,9 +130,8 @@ void TestShellDelegate::Exit() {
num_exit_requests_++;
}
-keyboard::KeyboardControllerProxy*
- TestShellDelegate::CreateKeyboardControllerProxy() {
- return new KeyboardControllerProxyStub();
+keyboard::KeyboardUI* TestShellDelegate::CreateKeyboardUI() {
+ return new TestKeyboardUI;
}
void TestShellDelegate::VirtualKeyboardActivated(bool activated) {
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 3cbf58d..3bf7cef 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -15,7 +15,7 @@
#include "base/observer_list.h"
namespace keyboard {
-class KeyboardControllerProxy;
+class KeyboardUI;
}
namespace ash {
@@ -41,7 +41,7 @@ class TestShellDelegate : public ShellDelegate {
void PreInit() override;
void PreShutdown() override;
void Exit() override;
- keyboard::KeyboardControllerProxy* CreateKeyboardControllerProxy() override;
+ keyboard::KeyboardUI* CreateKeyboardUI() override;
void VirtualKeyboardActivated(bool activated) override;
void AddVirtualKeyboardStateObserver(
VirtualKeyboardStateObserver* observer) override;
diff --git a/ash/wm/always_on_top_controller_unittest.cc b/ash/wm/always_on_top_controller_unittest.cc
index f2db7e0..2e23be8 100644
--- a/ash/wm/always_on_top_controller_unittest.cc
+++ b/ash/wm/always_on_top_controller_unittest.cc
@@ -11,8 +11,8 @@
#include "ash/wm/workspace/workspace_layout_manager.h"
#include "base/command_line.h"
#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_switches.h"
+#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
namespace ash {
@@ -74,8 +74,8 @@ TEST_F(VirtualKeyboardAlwaysOnTopControllerTest, NotifyKeyboardBoundsChanged) {
Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer);
ASSERT_TRUE(keyboard_container);
keyboard_container->Show();
- keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy();
- aura::Window* keyboard_window = proxy->GetKeyboardWindow();
+ aura::Window* keyboard_window =
+ keyboard_controller->ui()->GetKeyboardWindow();
keyboard_container->AddChild(keyboard_window);
keyboard_window->set_owned_by_parent(false);
const int kKeyboardHeight = 200;
diff --git a/ash/wm/lock_layout_manager_unittest.cc b/ash/wm/lock_layout_manager_unittest.cc
index a210a9b..3f5ab9f 100644
--- a/ash/wm/lock_layout_manager_unittest.cc
+++ b/ash/wm/lock_layout_manager_unittest.cc
@@ -15,8 +15,8 @@
#include "ui/aura/window.h"
#include "ui/gfx/screen.h"
#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_switches.h"
+#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -91,8 +91,8 @@ class LockLayoutManagerTest : public AshTestBase {
if (show) {
keyboard->ShowKeyboard(true);
- if (keyboard->proxy()->GetKeyboardWindow()->bounds().height() == 0) {
- keyboard->proxy()->GetKeyboardWindow()->SetBounds(
+ if (keyboard->ui()->GetKeyboardWindow()->bounds().height() == 0) {
+ keyboard->ui()->GetKeyboardWindow()->SetBounds(
keyboard::FullWidthKeyboardBoundsFromRootBounds(
Shell::GetPrimaryRootWindow()->bounds(),
kVirtualKeyboardHeight));
@@ -231,8 +231,9 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) {
primary_display = Shell::GetScreen()->GetPrimaryDisplay();
screen_bounds = primary_display.bounds();
gfx::Rect target_bounds(screen_bounds);
- target_bounds.set_height(target_bounds.height() -
- keyboard->proxy()->GetKeyboardWindow()->bounds().height());
+ target_bounds.set_height(
+ target_bounds.height() -
+ keyboard->ui()->GetKeyboardWindow()->bounds().height());
EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString());
ShowKeyboard(false);
diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc
index 6229587..7273f6f 100644
--- a/ash/wm/system_modal_container_layout_manager_unittest.cc
+++ b/ash/wm/system_modal_container_layout_manager_unittest.cc
@@ -21,8 +21,8 @@
#include "ui/events/test/event_generator.h"
#include "ui/gfx/screen.h"
#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_switches.h"
+#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/views/test/capture_tracking_view.h"
#include "ui/views/widget/widget.h"
@@ -180,8 +180,8 @@ class SystemModalContainerLayoutManagerTest : public AshTestBase {
if (show) {
keyboard->ShowKeyboard(true);
- if (keyboard->proxy()->GetKeyboardWindow()->bounds().height() == 0) {
- keyboard->proxy()->GetKeyboardWindow()->SetBounds(
+ if (keyboard->ui()->GetKeyboardWindow()->bounds().height() == 0) {
+ keyboard->ui()->GetKeyboardWindow()->SetBounds(
keyboard::FullWidthKeyboardBoundsFromRootBounds(
Shell::GetPrimaryRootWindow()->bounds(), 100));
}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 3c9cc5a..36990e6 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -569,6 +569,7 @@ source_set("browser") {
"//ui/aura",
"//ui/compositor",
"//ui/keyboard",
+ "//ui/keyboard:keyboard_with_content",
]
}
if (ui_compositor_image_transport) {
diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn
index a64a023..aa29d09 100644
--- a/chrome/browser/extensions/BUILD.gn
+++ b/chrome/browser/extensions/BUILD.gn
@@ -118,6 +118,7 @@ source_set("extensions") {
if (use_aura) {
deps += [
"//ui/keyboard",
+ "//ui/keyboard:keyboard_with_content",
"//ui/keyboard:resources",
]
}
diff --git a/chrome/browser/extensions/chrome_component_extension_resource_manager.cc b/chrome/browser/extensions/chrome_component_extension_resource_manager.cc
index 969069a..58bcf1e 100644
--- a/chrome/browser/extensions/chrome_component_extension_resource_manager.cc
+++ b/chrome/browser/extensions/chrome_component_extension_resource_manager.cc
@@ -17,7 +17,7 @@
#endif
#if defined(USE_AURA)
-#include "ui/keyboard/keyboard_util.h"
+#include "ui/keyboard/content/keyboard_content_util.h"
#endif
namespace extensions {
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index 8811af5..7b6a902 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -263,6 +263,7 @@ source_set("ui") {
"//ash/resources",
"//ui/aura",
"//ui/keyboard",
+ "//ui/keyboard:keyboard_with_content",
"//ui/keyboard:resources",
"//ui/wm",
]
diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc b/chrome/browser/ui/ash/chrome_keyboard_ui.cc
index af8563c..24f0fe3 100644
--- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc
+++ b/chrome/browser/ui/ash/chrome_keyboard_ui.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h"
+#include "chrome/browser/ui/ash/chrome_keyboard_ui.h"
#include "ash/shell.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
@@ -107,25 +107,23 @@ class AshKeyboardControllerObserver
} // namespace
-AshKeyboardControllerProxy::AshKeyboardControllerProxy(
- content::BrowserContext* context)
- : keyboard::KeyboardControllerProxy(context) {
-}
+ChromeKeyboardUI::ChromeKeyboardUI(content::BrowserContext* context)
+ : keyboard::KeyboardUIContent(context) {}
-AshKeyboardControllerProxy::~AshKeyboardControllerProxy() {
+ChromeKeyboardUI::~ChromeKeyboardUI() {
DCHECK(!keyboard_controller());
}
-ui::InputMethod* AshKeyboardControllerProxy::GetInputMethod() {
+ui::InputMethod* ChromeKeyboardUI::GetInputMethod() {
aura::Window* root_window = ash::Shell::GetTargetRootWindow();
DCHECK(root_window);
return root_window->GetHost()->GetInputMethod();
}
-void AshKeyboardControllerProxy::RequestAudioInput(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) {
+void ChromeKeyboardUI::RequestAudioInput(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) {
const extensions::Extension* extension = NULL;
GURL origin(request.security_origin);
if (origin.SchemeIs(extensions::kExtensionScheme)) {
@@ -139,29 +137,27 @@ void AshKeyboardControllerProxy::RequestAudioInput(
web_contents, request, callback, extension);
}
-void AshKeyboardControllerProxy::SetupWebContents(
- content::WebContents* contents) {
+void ChromeKeyboardUI::SetupWebContents(content::WebContents* contents) {
extensions::SetViewType(contents, extensions::VIEW_TYPE_VIRTUAL_KEYBOARD);
extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
contents);
Observe(contents);
}
-void AshKeyboardControllerProxy::SetController(
- keyboard::KeyboardController* controller) {
+void ChromeKeyboardUI::SetController(keyboard::KeyboardController* controller) {
// During KeyboardController destruction, controller can be set to null.
if (!controller) {
DCHECK(keyboard_controller());
keyboard_controller()->RemoveObserver(observer_.get());
- KeyboardControllerProxy::SetController(nullptr);
+ KeyboardUIContent::SetController(nullptr);
return;
}
- KeyboardControllerProxy::SetController(controller);
+ KeyboardUIContent::SetController(controller);
observer_.reset(new AshKeyboardControllerObserver(browser_context()));
keyboard_controller()->AddObserver(observer_.get());
}
-void AshKeyboardControllerProxy::RenderViewCreated(
+void ChromeKeyboardUI::RenderViewCreated(
content::RenderViewHost* render_view_host) {
content::HostZoomMap* zoom_map =
content::HostZoomMap::GetDefaultForBrowserContext(browser_context());
@@ -171,17 +167,16 @@ void AshKeyboardControllerProxy::RenderViewCreated(
zoom_map->SetTemporaryZoomLevel(render_process_id, render_view_id, 0);
}
-void AshKeyboardControllerProxy::ShowKeyboardContainer(
- aura::Window* container) {
+void ChromeKeyboardUI::ShowKeyboardContainer(aura::Window* container) {
// TODO(bshe): Implement logic to decide which root window should display
// virtual keyboard. http://crbug.com/303429
if (container->GetRootWindow() != ash::Shell::GetPrimaryRootWindow())
NOTIMPLEMENTED();
- KeyboardControllerProxy::ShowKeyboardContainer(container);
+ KeyboardUIContent::ShowKeyboardContainer(container);
}
-void AshKeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) {
+void ChromeKeyboardUI::SetUpdateInputType(ui::TextInputType type) {
// TODO(bshe): Need to check the affected window's profile once multi-profile
// is supported.
extensions::EventRouter* router =
diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.h b/chrome/browser/ui/ash/chrome_keyboard_ui.h
index d78d974..d241324 100644
--- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.h
+++ b/chrome/browser/ui/ash/chrome_keyboard_ui.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_
-#define CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_
+#ifndef CHROME_BROWSER_UI_ASH_CHROME_KEYBOARD_UI_H_
+#define CHROME_BROWSER_UI_ASH_CHROME_KEYBOARD_UI_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/web_contents_observer.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
+#include "ui/keyboard/content/keyboard_ui_content.h"
namespace content {
class BrowserContext;
@@ -29,14 +29,13 @@ namespace ui {
class InputMethod;
}
-// Subclass of KeyboardControllerProxy. It is used by KeyboardController to get
+// Subclass of KeyboardUIContent. It is used by KeyboardController to get
// access to the virtual keyboard window and setup Chrome extension functions.
-class AshKeyboardControllerProxy
- : public keyboard::KeyboardControllerProxy,
- public content::WebContentsObserver {
+class ChromeKeyboardUI : public keyboard::KeyboardUIContent,
+ public content::WebContentsObserver {
public:
- explicit AshKeyboardControllerProxy(content::BrowserContext* context);
- ~AshKeyboardControllerProxy() override;
+ explicit ChromeKeyboardUI(content::BrowserContext* context);
+ ~ChromeKeyboardUI() override;
private:
// keyboard::KeyboardControllerProxy overrides
@@ -63,7 +62,7 @@ class AshKeyboardControllerProxy
scoped_ptr<keyboard::KeyboardControllerObserver> observer_;
- DISALLOW_COPY_AND_ASSIGN(AshKeyboardControllerProxy);
+ DISALLOW_COPY_AND_ASSIGN(ChromeKeyboardUI);
};
-#endif // CHROME_BROWSER_UI_ASH_ASH_KEYBOARD_CONTROLLER_PROXY_H_
+#endif // CHROME_BROWSER_UI_ASH_CHROME_KEYBOARD_UI_H_
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc
index 9cdec31..54fea49 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/app_list/app_list_view_delegate.h"
#include "chrome/browser/ui/ash/app_list/app_list_service_ash.h"
-#include "chrome/browser/ui/ash/ash_keyboard_controller_proxy.h"
+#include "chrome/browser/ui/ash/chrome_keyboard_ui.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
#include "chrome/browser/ui/ash/session_util.h"
@@ -193,10 +193,8 @@ gfx::Image ChromeShellDelegate::GetDeprecatedAcceleratorImage() const {
IDR_BLUETOOTH_KEYBOARD);
}
-keyboard::KeyboardControllerProxy*
- ChromeShellDelegate::CreateKeyboardControllerProxy() {
- return new AshKeyboardControllerProxy(
- ProfileManager::GetActiveUserProfile());
+keyboard::KeyboardUI* ChromeShellDelegate::CreateKeyboardUI() {
+ return new ChromeKeyboardUI(ProfileManager::GetActiveUserProfile());
}
void ChromeShellDelegate::VirtualKeyboardActivated(bool activated) {
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h
index b5ed15cb..e069b71 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.h
@@ -28,7 +28,7 @@ class WebContents;
}
namespace keyboard {
-class KeyboardControllerProxy;
+class KeyboardUI;
}
#if defined(OS_CHROMEOS)
@@ -58,7 +58,7 @@ class ChromeShellDelegate : public ash::ShellDelegate,
void PreInit() override;
void PreShutdown() override;
void Exit() override;
- keyboard::KeyboardControllerProxy* CreateKeyboardControllerProxy() override;
+ keyboard::KeyboardUI* CreateKeyboardUI() override;
void VirtualKeyboardActivated(bool activated) override;
void AddVirtualKeyboardStateObserver(
ash::VirtualKeyboardStateObserver* observer) override;
diff --git a/chrome/browser/ui/ash/keyboard_controller_browsertest.cc b/chrome/browser/ui/ash/keyboard_controller_browsertest.cc
index e8a2e9a..8635c41 100644
--- a/chrome/browser/ui/ash/keyboard_controller_browsertest.cc
+++ b/chrome/browser/ui/ash/keyboard_controller_browsertest.cc
@@ -9,10 +9,10 @@
#include "ui/base/ime/dummy_text_input_client.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/input_method_factory.h"
-#include "ui/keyboard/keyboard_constants.h"
+#include "ui/keyboard/content/keyboard_constants.h"
#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_switches.h"
+#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
namespace {
@@ -35,24 +35,24 @@ class VirtualKeyboardWebContentTest : public InProcessBrowserTest {
keyboard::switches::kEnableVirtualKeyboard);
}
- keyboard::KeyboardControllerProxy* proxy() {
- return keyboard::KeyboardController::GetInstance()->proxy();
+ keyboard::KeyboardUI* ui() {
+ return keyboard::KeyboardController::GetInstance()->ui();
}
protected:
void FocusEditableNodeAndShowKeyboard(const gfx::Rect& init_bounds) {
client.reset(new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT));
- ui::InputMethod* input_method = proxy()->GetInputMethod();
+ ui::InputMethod* input_method = ui()->GetInputMethod();
input_method->SetFocusedTextInputClient(client.get());
input_method->ShowImeIfNeeded();
// Mock window.resizeTo that is expected to be called after navigate to a
// new virtual keyboard.
- proxy()->GetKeyboardWindow()->SetBounds(init_bounds);
+ ui()->GetKeyboardWindow()->SetBounds(init_bounds);
}
void FocusNonEditableNode() {
client.reset(new ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_NONE));
- ui::InputMethod* input_method = proxy()->GetInputMethod();
+ ui::InputMethod* input_method = ui()->GetInputMethod();
input_method->SetFocusedTextInputClient(client.get());
}
@@ -62,7 +62,7 @@ class VirtualKeyboardWebContentTest : public InProcessBrowserTest {
keyboard::KeyboardController::GetInstance()->Reload();
// Mock window.resizeTo that is expected to be called after navigate to a
// new virtual keyboard.
- proxy()->GetKeyboardWindow()->SetBounds(init_bounds);
+ ui()->GetKeyboardWindow()->SetBounds(init_bounds);
}
bool IsKeyboardVisible() const {
@@ -120,7 +120,7 @@ IN_PROC_BROWSER_TEST_F(VirtualKeyboardWebContentTest,
keyboard_bounds.height() + keyboard_bounds.y());
controller->SetKeyboardMode(keyboard::FLOATING);
// Move keyboard to a random place.
- proxy()->GetKeyboardWindow()->SetBounds(gfx::Rect(50, 50, 50, 50));
+ ui()->GetKeyboardWindow()->SetBounds(gfx::Rect(50, 50, 50, 50));
EXPECT_EQ(gfx::Rect(50, 50, 50, 50),
controller->GetContainerWindow()->bounds());
diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
index 1f8020c..37851a8 100644
--- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
+++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
@@ -17,7 +17,7 @@
#include "ui/aura/env.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/screen_type_delegate.h"
-#include "ui/keyboard/keyboard.h"
+#include "ui/keyboard/content/keyboard.h"
#include "ui/keyboard/keyboard_controller.h"
#if defined(OS_CHROMEOS)
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index c164dc6..5b8e787 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3563,6 +3563,7 @@
'../ui/aura/aura.gyp:aura',
'../ui/compositor/compositor.gyp:compositor',
'../ui/keyboard/keyboard.gyp:keyboard',
+ '../ui/keyboard/keyboard.gyp:keyboard_with_content',
],
}],
['ui_compositor_image_transport==1', {
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 5c246dc..4c91c05 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -1041,6 +1041,7 @@
['use_aura==1', {
'dependencies': [
'../ui/keyboard/keyboard.gyp:keyboard',
+ '../ui/keyboard/keyboard.gyp:keyboard_with_content',
'../ui/keyboard/keyboard.gyp:keyboard_resources',
],
}],
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index a12430c..4a3f45a 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -512,12 +512,12 @@
'browser/ui/ash/app_sync_ui_state_observer.h',
'browser/ui/ash/ash_init.cc',
'browser/ui/ash/ash_init.h',
- 'browser/ui/ash/ash_keyboard_controller_proxy.cc',
- 'browser/ui/ash/ash_keyboard_controller_proxy.h',
'browser/ui/ash/ash_util.cc',
'browser/ui/ash/ash_util.h',
'browser/ui/ash/cast_config_delegate_chromeos.cc',
'browser/ui/ash/cast_config_delegate_chromeos.h',
+ 'browser/ui/ash/chrome_keyboard_ui.cc',
+ 'browser/ui/ash/chrome_keyboard_ui.h',
'browser/ui/ash/chrome_launcher_prefs.cc',
'browser/ui/ash/chrome_launcher_prefs.h',
'browser/ui/ash/chrome_new_window_delegate.cc',
@@ -2973,6 +2973,7 @@
'../ash/ash_resources.gyp:ash_resources',
'../ui/aura/aura.gyp:aura',
'../ui/keyboard/keyboard.gyp:keyboard',
+ '../ui/keyboard/keyboard.gyp:keyboard_with_content',
'../ui/keyboard/keyboard.gyp:keyboard_resources',
'../ui/wm/wm.gyp:wm',
],
diff --git a/chrome/common/extensions/chrome_manifest_url_handlers.cc b/chrome/common/extensions/chrome_manifest_url_handlers.cc
index 8905ae7..cf3d546 100644
--- a/chrome/common/extensions/chrome_manifest_url_handlers.cc
+++ b/chrome/common/extensions/chrome_manifest_url_handlers.cc
@@ -21,7 +21,7 @@
#include "extensions/common/permissions/api_permission.h"
#if defined(USE_AURA)
-#include "ui/keyboard/keyboard_constants.h"
+#include "ui/keyboard/content/keyboard_constants.h"
#endif
namespace extensions {
diff --git a/ui/keyboard/BUILD.gn b/ui/keyboard/BUILD.gn
index a62fc8b..4600fbc 100644
--- a/ui/keyboard/BUILD.gn
+++ b/ui/keyboard/BUILD.gn
@@ -9,20 +9,16 @@ import("//tools/grit/grit_rule.gni")
component("keyboard") {
sources = [
- "keyboard.cc",
- "keyboard.h",
- "keyboard_constants.cc",
- "keyboard_constants.h",
"keyboard_controller.cc",
"keyboard_controller.h",
"keyboard_controller_observer.h",
- "keyboard_controller_proxy.cc",
- "keyboard_controller_proxy.h",
"keyboard_export.h",
"keyboard_layout_manager.cc",
"keyboard_layout_manager.h",
"keyboard_switches.cc",
"keyboard_switches.h",
+ "keyboard_ui.cc",
+ "keyboard_ui.h",
"keyboard_util.cc",
"keyboard_util.h",
]
@@ -30,13 +26,48 @@ component("keyboard") {
defines = [ "KEYBOARD_IMPLEMENTATION" ]
deps = [
+ "//base",
+ "//base/third_party/dynamic_annotations",
+ "//media",
+ "//skia",
+ "//ui/aura",
+ "//ui/base",
+ "//ui/base/ime",
+ "//ui/compositor",
+ "//ui/events",
+ "//ui/events:dom_keycode_converter",
+ "//ui/events:events_base",
+ "//ui/gfx",
+ "//ui/gfx/geometry",
+ ]
+
+ if (use_ozone) {
+ deps += [ "//ui/ozone" ]
+ }
+}
+
+component("keyboard_with_content") {
+ sources = [
+ "content/keyboard.cc",
+ "content/keyboard.h",
+ "content/keyboard_constants.cc",
+ "content/keyboard_constants.h",
+ "content/keyboard_content_util.cc",
+ "content/keyboard_content_util.h",
+ "content/keyboard_ui_content.cc",
+ "content/keyboard_ui_content.h",
+ ]
+
+ defines = [ "KEYBOARD_IMPLEMENTATION" ]
+
+ deps = [
+ ":keyboard",
":resources",
"//base",
"//base/third_party/dynamic_annotations",
"//content/public/browser",
"//content/public/common",
"//ipc",
- "//media",
"//skia",
"//ui/aura",
"//ui/base",
@@ -50,10 +81,6 @@ component("keyboard") {
"//ui/wm",
"//url",
]
-
- if (use_ozone) {
- deps += [ "//ui/ozone" ]
- }
}
grit("resources_grit") {
@@ -111,8 +138,6 @@ test("keyboard_unittests") {
"//base",
"//base/allocator",
"//base/test:test_support",
- "//content",
- "//media",
"//skia",
"//testing/gtest",
"//ui/aura:test_support",
@@ -124,8 +149,6 @@ test("keyboard_unittests") {
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl",
- "//ui/resources:ui_test_pak",
"//ui/wm",
- "//url",
]
}
diff --git a/ui/keyboard/content/DEPS b/ui/keyboard/content/DEPS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ui/keyboard/content/DEPS
diff --git a/ui/keyboard/keyboard.cc b/ui/keyboard/content/keyboard.cc
index 4e26637..4f7da4d 100644
--- a/ui/keyboard/keyboard.cc
+++ b/ui/keyboard/content/keyboard.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/keyboard/keyboard.h"
+#include "ui/keyboard/content/keyboard.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
diff --git a/ui/keyboard/keyboard.h b/ui/keyboard/content/keyboard.h
index 0878b7b..0878b7b 100644
--- a/ui/keyboard/keyboard.h
+++ b/ui/keyboard/content/keyboard.h
diff --git a/ui/keyboard/keyboard_constants.cc b/ui/keyboard/content/keyboard_constants.cc
index b13a604..449f96f 100644
--- a/ui/keyboard/keyboard_constants.cc
+++ b/ui/keyboard/content/keyboard_constants.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/keyboard/keyboard_constants.h"
+#include "ui/keyboard/content/keyboard_constants.h"
namespace keyboard {
diff --git a/ui/keyboard/keyboard_constants.h b/ui/keyboard/content/keyboard_constants.h
index 75607c1..6c4e661 100644
--- a/ui/keyboard/keyboard_constants.h
+++ b/ui/keyboard/content/keyboard_constants.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_KEYBOARD_KEYBOARD_CONSTANTS_H_
-#define UI_KEYBOARD_KEYBOARD_CONSTANTS_H_
+#ifndef UI_KEYBOARD_CONTENT_KEYBOARD_CONSTANTS_H_
+#define UI_KEYBOARD_CONTENT_KEYBOARD_CONSTANTS_H_
#include "ui/keyboard/keyboard_export.h"
@@ -17,4 +17,4 @@ KEYBOARD_EXPORT extern const char kKeyboardHost[];
} // namespace keyboard
-#endif // UI_KEYBOARD_KEYBOARD_CONSTANTS_H_
+#endif // UI_KEYBOARD_CONTENT_KEYBOARD_CONSTANTS_H_
diff --git a/ui/keyboard/content/keyboard_content_util.cc b/ui/keyboard/content/keyboard_content_util.cc
new file mode 100644
index 0000000..48bb08a
--- /dev/null
+++ b/ui/keyboard/content/keyboard_content_util.cc
@@ -0,0 +1,108 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/keyboard/content/keyboard_content_util.h"
+
+#include "base/lazy_instance.h"
+#include "grit/keyboard_resources.h"
+#include "grit/keyboard_resources_map.h"
+#include "url/gurl.h"
+
+namespace keyboard {
+namespace {
+
+base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+void SetOverrideContentUrl(const GURL& url) {
+ g_override_content_url.Get() = url;
+}
+
+const GURL& GetOverrideContentUrl() {
+ return g_override_content_url.Get();
+}
+
+const GritResourceMap* GetKeyboardExtensionResources(size_t* size) {
+ // This looks a lot like the contents of a resource map; however it is
+ // necessary to have a custom path for the extension path, so the resource
+ // map cannot be used directly.
+ static const GritResourceMap kKeyboardResources[] = {
+ {"keyboard/locales/en.js", IDR_KEYBOARD_LOCALES_EN},
+ {"keyboard/config/emoji.js", IDR_KEYBOARD_CONFIG_EMOJI},
+ {"keyboard/config/hwt.js", IDR_KEYBOARD_CONFIG_HWT},
+ {"keyboard/config/us.js", IDR_KEYBOARD_CONFIG_US},
+ {"keyboard/emoji.css", IDR_KEYBOARD_CSS_EMOJI},
+ {"keyboard/images/3dots.png", IDR_KEYBOARD_IMAGES_3_DOTS},
+ {"keyboard/images/back_to_keyboard.png",
+ IDR_KEYBOARD_IMAGES_BACK_TO_KEYBOARD},
+ {"keyboard/images/backspace.png", IDR_KEYBOARD_IMAGES_BACKSPACE},
+ {"keyboard/images/car.png", IDR_KEYBOARD_IMAGES_CAR},
+ {"keyboard/images/check.png", IDR_KEYBOARD_IMAGES_CHECK},
+ {"keyboard/images/check_in_menu.png", IDR_KEYBOARD_IMAGES_CHECK_IN_MENU},
+ {"keyboard/images/compact.png", IDR_KEYBOARD_IMAGES_COMPACT},
+ {"keyboard/images/down.png", IDR_KEYBOARD_IMAGES_DOWN},
+ {"keyboard/images/emoji.png", IDR_KEYBOARD_IMAGES_EMOJI},
+ {"keyboard/images/emoji_car.png", IDR_KEYBOARD_IMAGES_EMOJI_CAR},
+ {"keyboard/images/emoji_crown.png", IDR_KEYBOARD_IMAGES_EMOJI_CROWN},
+ {"keyboard/images/emoji_emoticon.png",
+ IDR_KEYBOARD_IMAGES_EMOJI_EMOTICON},
+ {"keyboard/images/emoji_flower.png", IDR_KEYBOARD_IMAGES_EMOJI_FLOWER},
+ {"keyboard/images/emoji_hot.png", IDR_KEYBOARD_IMAGES_EMOJI_HOT},
+ {"keyboard/images/emoji_recent.png", IDR_KEYBOARD_IMAGES_EMOJI_RECENT},
+ {"keyboard/images/emoji_shape.png", IDR_KEYBOARD_IMAGES_EMOJI_SHAPE},
+ {"keyboard/images/emoji_cat_items.png", IDR_KEYBOARD_IMAGES_CAT},
+ {"keyboard/images/emoticon.png", IDR_KEYBOARD_IMAGES_EMOTICON},
+ {"keyboard/images/enter.png", IDR_KEYBOARD_IMAGES_RETURN},
+ {"keyboard/images/error.png", IDR_KEYBOARD_IMAGES_ERROR},
+ {"keyboard/images/favorit.png", IDR_KEYBOARD_IMAGES_FAVORITE},
+ {"keyboard/images/flower.png", IDR_KEYBOARD_IMAGES_FLOWER},
+ {"keyboard/images/globe.png", IDR_KEYBOARD_IMAGES_GLOBE},
+ {"keyboard/images/hide.png", IDR_KEYBOARD_IMAGES_HIDE},
+ {"keyboard/images/hidekeyboard.png", IDR_KEYBOARD_IMAGES_HIDE_KEYBOARD},
+ {"keyboard/images/keyboard.svg", IDR_KEYBOARD_IMAGES_KEYBOARD},
+ {"keyboard/images/left.png", IDR_KEYBOARD_IMAGES_LEFT},
+ {"keyboard/images/penci.png", IDR_KEYBOARD_IMAGES_PENCIL},
+ {"keyboard/images/recent.png", IDR_KEYBOARD_IMAGES_RECENT},
+ {"keyboard/images/regular_size.png", IDR_KEYBOARD_IMAGES_FULLSIZE},
+ {"keyboard/images/menu.png", IDR_KEYBOARD_IMAGES_MENU},
+ {"keyboard/images/pencil.png", IDR_KEYBOARD_IMAGES_PENCIL},
+ {"keyboard/images/right.png", IDR_KEYBOARD_IMAGES_RIGHT},
+ {"keyboard/images/search.png", IDR_KEYBOARD_IMAGES_SEARCH},
+ {"keyboard/images/select_right.png", IDR_KEYBOARD_IMAGES_SELECT_RIGHT},
+ {"keyboard/images/select_left.png", IDR_KEYBOARD_IMAGES_SELECT_LEFT},
+ {"keyboard/images/setting.png", IDR_KEYBOARD_IMAGES_SETTINGS},
+ {"keyboard/images/shift.png", IDR_KEYBOARD_IMAGES_SHIFT},
+ {"keyboard/images/space.png", IDR_KEYBOARD_IMAGES_SPACE},
+ {"keyboard/images/tab.png", IDR_KEYBOARD_IMAGES_TAB},
+ {"keyboard/images/tab_in_fullsize.png",
+ IDR_KEYBOARD_IMAGES_TAB_IN_FULLSIZE},
+ {"keyboard/images/triangle.png", IDR_KEYBOARD_IMAGES_TRIANGLE},
+ {"keyboard/images/up.png", IDR_KEYBOARD_IMAGES_UP},
+ {"keyboard/index.html", IDR_KEYBOARD_INDEX},
+ {"keyboard/inputview_adapter.js", IDR_KEYBOARD_INPUTVIEW_ADAPTER},
+ {"keyboard/inputview.css", IDR_KEYBOARD_INPUTVIEW_CSS},
+ {"keyboard/inputview.js", IDR_KEYBOARD_INPUTVIEW_JS},
+ {"keyboard/inputview_layouts/101kbd.js", IDR_KEYBOARD_LAYOUTS_101},
+ {"keyboard/inputview_layouts/compactkbd-qwerty.js",
+ IDR_KEYBOARD_LAYOUTS_COMPACT_QWERTY},
+ {"keyboard/inputview_layouts/compactkbd-numberpad.js",
+ IDR_KEYBOARD_LAYOUTS_COMPACT_NUMBERPAD},
+ {"keyboard/inputview_layouts/emoji.js", IDR_KEYBOARD_LAYOUTS_EMOJI},
+ {"keyboard/inputview_layouts/handwriting.js", IDR_KEYBOARD_LAYOUTS_HWT},
+ {"keyboard/manifest.json", IDR_KEYBOARD_MANIFEST},
+ {"keyboard/sounds/keypress-delete.wav",
+ IDR_KEYBOARD_SOUNDS_KEYPRESS_DELETE},
+ {"keyboard/sounds/keypress-return.wav",
+ IDR_KEYBOARD_SOUNDS_KEYPRESS_RETURN},
+ {"keyboard/sounds/keypress-spacebar.wav",
+ IDR_KEYBOARD_SOUNDS_KEYPRESS_SPACEBAR},
+ {"keyboard/sounds/keypress-standard.wav",
+ IDR_KEYBOARD_SOUNDS_KEYPRESS_STANDARD},
+ };
+ *size = arraysize(kKeyboardResources);
+ return kKeyboardResources;
+}
+
+} // namespace keyboard \ No newline at end of file
diff --git a/ui/keyboard/content/keyboard_content_util.h b/ui/keyboard/content/keyboard_content_util.h
new file mode 100644
index 0000000..65314be
--- /dev/null
+++ b/ui/keyboard/content/keyboard_content_util.h
@@ -0,0 +1,31 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_KEYBOARD_CONTENT_KEYBOARD_COTNENT_UTIL_H_
+#define UI_KEYBOARD_CONTENT_KEYBOARD_COTNENT_UTIL_H_
+
+#include "base/strings/string16.h"
+#include "ui/keyboard/keyboard_export.h"
+
+class GURL;
+
+struct GritResourceMap;
+
+namespace keyboard {
+
+// Sets the override content url.
+// This is used by for input view for extension IMEs.
+KEYBOARD_EXPORT void SetOverrideContentUrl(const GURL& url);
+
+// Gets the override content url.
+KEYBOARD_EXPORT const GURL& GetOverrideContentUrl();
+
+// Get the list of keyboard resources. |size| is populated with the number of
+// resources in the returned array.
+KEYBOARD_EXPORT const GritResourceMap* GetKeyboardExtensionResources(
+ size_t* size);
+
+} // namespace keyboard
+
+#endif // UI_KEYBOARD_CONTENT_KEYBOARD_COTNENT_UTIL_H_
diff --git a/ui/keyboard/content/keyboard_ui_content.cc b/ui/keyboard/content/keyboard_ui_content.cc
new file mode 100644
index 0000000..010abde
--- /dev/null
+++ b/ui/keyboard/content/keyboard_ui_content.cc
@@ -0,0 +1,321 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/keyboard/content/keyboard_ui_content.h"
+
+#include "base/command_line.h"
+#include "base/values.h"
+#include "content/public/browser/render_widget_host.h"
+#include "content/public/browser/render_widget_host_iterator.h"
+#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/site_instance.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/common/bindings_policy.h"
+#include "ui/aura/layout_manager.h"
+#include "ui/aura/window.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/text_input_client.h"
+#include "ui/keyboard/content/keyboard_constants.h"
+#include "ui/keyboard/keyboard_controller.h"
+#include "ui/keyboard/keyboard_switches.h"
+#include "ui/keyboard/keyboard_util.h"
+#include "ui/wm/core/shadow.h"
+
+namespace {
+
+// The WebContentsDelegate for the keyboard.
+// The delegate deletes itself when the keyboard is destroyed.
+class KeyboardContentsDelegate : public content::WebContentsDelegate,
+ public content::WebContentsObserver {
+ public:
+ explicit KeyboardContentsDelegate(keyboard::KeyboardUIContent* ui)
+ : ui_(ui) {}
+ ~KeyboardContentsDelegate() override {}
+
+ private:
+ // Overridden from content::WebContentsDelegate:
+ content::WebContents* OpenURLFromTab(
+ content::WebContents* source,
+ const content::OpenURLParams& params) override {
+ source->GetController().LoadURL(
+ params.url, params.referrer, params.transition, params.extra_headers);
+ Observe(source);
+ return source;
+ }
+
+ bool CanDragEnter(content::WebContents* source,
+ const content::DropData& data,
+ blink::WebDragOperationsMask operations_allowed) override {
+ return false;
+ }
+
+ bool ShouldCreateWebContents(
+ content::WebContents* web_contents,
+ int route_id,
+ int main_frame_route_id,
+ WindowContainerType window_container_type,
+ const std::string& frame_name,
+ const GURL& target_url,
+ const std::string& partition_id,
+ content::SessionStorageNamespace* session_storage_namespace) override {
+ return false;
+ }
+
+ bool IsPopupOrPanel(const content::WebContents* source) const override {
+ return true;
+ }
+
+ void MoveContents(content::WebContents* source,
+ const gfx::Rect& pos) override {
+ aura::Window* keyboard = ui_->GetKeyboardWindow();
+ // keyboard window must have been added to keyboard container window at this
+ // point. Otherwise, wrong keyboard bounds is used and may cause problem as
+ // described in crbug.com/367788.
+ DCHECK(keyboard->parent());
+ // keyboard window bounds may not set to |pos| after this call. If keyboard
+ // is in FULL_WIDTH mode, only the height of keyboard window will be
+ // changed.
+ keyboard->SetBounds(pos);
+ }
+
+ // Overridden from content::WebContentsDelegate:
+ void RequestMediaAccessPermission(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) override {
+ ui_->RequestAudioInput(web_contents, request, callback);
+ }
+
+ // Overridden from content::WebContentsObserver:
+ void WebContentsDestroyed() override { delete this; }
+
+ keyboard::KeyboardUIContent* ui_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate);
+};
+
+} // namespace
+
+namespace keyboard {
+
+class WindowBoundsChangeObserver : public aura::WindowObserver {
+ public:
+ explicit WindowBoundsChangeObserver(KeyboardUIContent* ui) : ui_(ui) {}
+ ~WindowBoundsChangeObserver() override {}
+
+ void AddObservedWindow(aura::Window* window) {
+ if (!window->HasObserver(this)) {
+ window->AddObserver(this);
+ observed_windows_.insert(window);
+ }
+ }
+ void RemoveAllObservedWindows() {
+ for (std::set<aura::Window*>::iterator it = observed_windows_.begin();
+ it != observed_windows_.end(); ++it)
+ (*it)->RemoveObserver(this);
+ observed_windows_.clear();
+ }
+
+ private:
+ void OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {
+ ui_->UpdateInsetsForWindow(window);
+ }
+ void OnWindowDestroyed(aura::Window* window) override {
+ if (window->HasObserver(this))
+ window->RemoveObserver(this);
+ observed_windows_.erase(window);
+ }
+
+ KeyboardUIContent* ui_;
+ std::set<aura::Window*> observed_windows_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowBoundsChangeObserver);
+};
+
+KeyboardUIContent::KeyboardUIContent(content::BrowserContext* context)
+ : browser_context_(context),
+ default_url_(kKeyboardURL),
+ window_bounds_observer_(new WindowBoundsChangeObserver(this)) {
+}
+
+KeyboardUIContent::~KeyboardUIContent() {
+ ResetInsets();
+}
+
+void KeyboardUIContent::LoadSystemKeyboard() {
+ DCHECK(keyboard_contents_);
+ if (keyboard_contents_->GetURL() != default_url_) {
+ // TODO(bshe): The height of system virtual keyboard and IME virtual
+ // keyboard may different. The height needs to be restored too.
+ LoadContents(default_url_);
+ }
+}
+
+void KeyboardUIContent::UpdateInsetsForWindow(aura::Window* window) {
+ aura::Window* keyboard_window = GetKeyboardWindow();
+ scoped_ptr<content::RenderWidgetHostIterator> widgets(
+ content::RenderWidgetHost::GetRenderWidgetHosts());
+ while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
+ content::RenderWidgetHostView* view = widget->GetView();
+ if (view && window->Contains(view->GetNativeView())) {
+ gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen();
+ gfx::Rect intersect =
+ gfx::IntersectRects(window_bounds, keyboard_window->bounds());
+ int overlap = ShouldEnableInsets(window) ? intersect.height() : 0;
+ if (overlap > 0 && overlap < window_bounds.height())
+ view->SetInsets(gfx::Insets(0, 0, overlap, 0));
+ else
+ view->SetInsets(gfx::Insets());
+ return;
+ }
+ }
+}
+
+aura::Window* KeyboardUIContent::GetKeyboardWindow() {
+ if (!keyboard_contents_) {
+ content::BrowserContext* context = browser_context();
+ keyboard_contents_.reset(content::WebContents::Create(
+ content::WebContents::CreateParams(context,
+ content::SiteInstance::CreateForURL(context,
+ GetVirtualKeyboardUrl()))));
+ keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this));
+ SetupWebContents(keyboard_contents_.get());
+ LoadContents(GetVirtualKeyboardUrl());
+ keyboard_contents_->GetNativeView()->AddObserver(this);
+ }
+
+ return keyboard_contents_->GetNativeView();
+}
+
+bool KeyboardUIContent::HasKeyboardWindow() const {
+ return keyboard_contents_;
+}
+
+void KeyboardUIContent::ReloadKeyboardIfNeeded() {
+ DCHECK(keyboard_contents_);
+ if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) {
+ if (keyboard_contents_->GetURL().GetOrigin() !=
+ GetVirtualKeyboardUrl().GetOrigin()) {
+ // Sets keyboard window rectangle to 0 and close current page before
+ // navigate to a keyboard in a different extension. This keeps the UX the
+ // same as Android. Note we need to explicitly close current page as it
+ // might try to resize keyboard window in javascript on a resize event.
+ GetKeyboardWindow()->SetBounds(gfx::Rect());
+ keyboard_contents_->ClosePage();
+ keyboard_controller()->SetKeyboardMode(FULL_WIDTH);
+ }
+ LoadContents(GetVirtualKeyboardUrl());
+ }
+}
+
+void KeyboardUIContent::InitInsets(const gfx::Rect& new_bounds) {
+ // Adjust the height of the viewport for visible windows on the primary
+ // display.
+ // TODO(kevers): Add EnvObserver to properly initialize insets if a
+ // window is created while the keyboard is visible.
+ scoped_ptr<content::RenderWidgetHostIterator> widgets(
+ content::RenderWidgetHost::GetRenderWidgetHosts());
+ aura::Window* keyboard_window = GetKeyboardWindow();
+ aura::Window* root_window = keyboard_window->GetRootWindow();
+ while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
+ content::RenderWidgetHostView* view = widget->GetView();
+ // Can be NULL, e.g. if the RenderWidget is being destroyed or
+ // the render process crashed.
+ if (view) {
+ aura::Window* window = view->GetNativeView();
+ // If virtual keyboard failed to load, a widget that displays error
+ // message will be created and adds as a child of the virtual keyboard
+ // window. We want to avoid add BoundsChangedObserver to that window.
+ if (!keyboard_window->Contains(window) &&
+ window->GetRootWindow() == root_window) {
+ gfx::Rect window_bounds = window->GetBoundsInScreen();
+ gfx::Rect intersect = gfx::IntersectRects(window_bounds,
+ new_bounds);
+ int overlap = intersect.height();
+ if (overlap > 0 && overlap < window_bounds.height())
+ view->SetInsets(gfx::Insets(0, 0, overlap, 0));
+ else
+ view->SetInsets(gfx::Insets());
+ AddBoundsChangedObserver(window);
+ }
+ }
+ }
+}
+
+void KeyboardUIContent::ResetInsets() {
+ const gfx::Insets insets;
+ scoped_ptr<content::RenderWidgetHostIterator> widgets(
+ content::RenderWidgetHost::GetRenderWidgetHosts());
+ while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
+ content::RenderWidgetHostView* view = widget->GetView();
+ if (view)
+ view->SetInsets(insets);
+ }
+ window_bounds_observer_->RemoveAllObservedWindows();
+}
+
+void KeyboardUIContent::SetupWebContents(content::WebContents* contents) {
+}
+
+void KeyboardUIContent::OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
+ if (!shadow_) {
+ shadow_.reset(new wm::Shadow());
+ shadow_->Init(wm::Shadow::STYLE_ACTIVE);
+ shadow_->layer()->SetVisible(true);
+ DCHECK(keyboard_contents_->GetNativeView()->parent());
+ keyboard_contents_->GetNativeView()->parent()->layer()->Add(
+ shadow_->layer());
+ }
+
+ shadow_->SetContentBounds(new_bounds);
+}
+
+void KeyboardUIContent::OnWindowDestroyed(aura::Window* window) {
+ window->RemoveObserver(this);
+}
+
+void KeyboardUIContent::LoadContents(const GURL& url) {
+ if (keyboard_contents_) {
+ content::OpenURLParams params(
+ url,
+ content::Referrer(),
+ SINGLETON_TAB,
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ false);
+ keyboard_contents_->OpenURL(params);
+ }
+}
+
+const GURL& KeyboardUIContent::GetVirtualKeyboardUrl() {
+ if (keyboard::IsInputViewEnabled()) {
+ const GURL& override_url = GetOverrideContentUrl();
+ return override_url.is_valid() ? override_url : default_url_;
+ } else {
+ return default_url_;
+ }
+}
+
+bool KeyboardUIContent::ShouldEnableInsets(aura::Window* window) {
+ aura::Window* keyboard_window = GetKeyboardWindow();
+ return (keyboard_window->GetRootWindow() == window->GetRootWindow() &&
+ keyboard::IsKeyboardOverscrollEnabled() &&
+ keyboard_window->IsVisible() &&
+ keyboard_controller()->keyboard_visible());
+}
+
+void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) {
+ aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr;
+ if (target_window)
+ window_bounds_observer_->AddObservedWindow(target_window);
+}
+
+} // namespace keyboard
diff --git a/ui/keyboard/content/keyboard_ui_content.h b/ui/keyboard/content/keyboard_ui_content.h
new file mode 100644
index 0000000..1c6fc25
--- /dev/null
+++ b/ui/keyboard/content/keyboard_ui_content.h
@@ -0,0 +1,127 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_KEYBOARD_CONTENT_KEYBOARD_UI_CONTENT_H_
+#define UI_KEYBOARD_CONTENT_KEYBOARD_UI_CONTENT_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "content/public/common/media_stream_request.h"
+#include "ui/aura/window_observer.h"
+#include "ui/base/ime/text_input_type.h"
+#include "ui/keyboard/keyboard_export.h"
+#include "ui/keyboard/keyboard_ui.h"
+
+namespace aura {
+class Window;
+}
+namespace content {
+class BrowserContext;
+class SiteInstance;
+class WebContents;
+}
+namespace gfx {
+class Rect;
+}
+namespace ui {
+class InputMethod;
+}
+namespace wm {
+class Shadow;
+}
+
+namespace keyboard {
+
+class KeyboardController;
+class WindowBoundsChangeObserver;
+
+// An implementation of KeyboardUI that uses a content::WebContents to implement
+//the keyboard.
+class KEYBOARD_EXPORT KeyboardUIContent : public KeyboardUI,
+ public aura::WindowObserver {
+ public:
+ class TestApi {
+ public:
+ explicit TestApi(KeyboardUIContent* ui) : ui_(ui) {}
+
+ const content::WebContents* keyboard_contents() {
+ return ui_->keyboard_contents_.get();
+ }
+
+ private:
+ KeyboardUIContent* ui_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestApi);
+ };
+
+ explicit KeyboardUIContent(content::BrowserContext* context);
+ ~KeyboardUIContent() override;
+
+ // Requests the audio input from microphone for speech input.
+ virtual void RequestAudioInput(content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) = 0;
+
+ // Loads system virtual keyboard. Noop if the current virtual keyboard is
+ // system virtual keyboard.
+ virtual void LoadSystemKeyboard();
+
+ // Called when a window being observed changes bounds, to update its insets.
+ void UpdateInsetsForWindow(aura::Window* window);
+
+ // Overridden from KeyboardUI:
+ aura::Window* GetKeyboardWindow() override;
+ bool HasKeyboardWindow() const override;
+ void ReloadKeyboardIfNeeded() override;
+ void InitInsets(const gfx::Rect& new_bounds) override;
+ void ResetInsets() override;
+
+ protected:
+ // The implementation can choose to setup the WebContents before the virtual
+ // keyboard page is loaded (e.g. install a WebContentsObserver).
+ // SetupWebContents() is called right after creating the WebContents, before
+ // loading the keyboard page.
+ virtual void SetupWebContents(content::WebContents* contents);
+
+ // aura::WindowObserver overrides:
+ void OnWindowBoundsChanged(aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override;
+ void OnWindowDestroyed(aura::Window* window) override;
+
+ content::BrowserContext* browser_context() { return browser_context_; }
+
+ private:
+ friend class TestApi;
+
+ // Loads the web contents for the given |url|.
+ void LoadContents(const GURL& url);
+
+ // Gets the virtual keyboard URL (either the default URL or IME override URL).
+ const GURL& GetVirtualKeyboardUrl();
+
+ // Determines whether a particular window should have insets for overscroll.
+ bool ShouldEnableInsets(aura::Window* window);
+
+ // Adds an observer for tracking changes to a window size or
+ // position while the keyboard is displayed. Any window repositioning
+ // invalidates insets for overscrolling.
+ void AddBoundsChangedObserver(aura::Window* window);
+
+ // The BrowserContext to use for creating the WebContents hosting the
+ // keyboard.
+ content::BrowserContext* browser_context_;
+
+ const GURL default_url_;
+
+ scoped_ptr<content::WebContents> keyboard_contents_;
+ scoped_ptr<wm::Shadow> shadow_;
+
+ scoped_ptr<WindowBoundsChangeObserver> window_bounds_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyboardUIContent);
+};
+
+} // namespace keyboard
+
+#endif // UI_KEYBOARD_CONTENT_KEYBOARD_UI_CONTENT_H_ \ No newline at end of file
diff --git a/ui/keyboard/keyboard.gyp b/ui/keyboard/keyboard.gyp
index 2f4fcdd..96fc1fd 100644
--- a/ui/keyboard/keyboard.gyp
+++ b/ui/keyboard/keyboard.gyp
@@ -49,11 +49,8 @@
'dependencies': [
'../../base/base.gyp:base',
'../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '../../content/content.gyp:content_browser',
- '../../ipc/ipc.gyp:ipc',
'../../media/media.gyp:media',
'../../skia/skia.gyp:skia',
- '../../url/url.gyp:url_lib',
'../aura/aura.gyp:aura',
'../base/ime/ui_base_ime.gyp:ui_base_ime',
'../base/ui_base.gyp:ui_base',
@@ -63,27 +60,22 @@
'../events/events.gyp:events_base',
'../gfx/gfx.gyp:gfx',
'../gfx/gfx.gyp:gfx_geometry',
- '../wm/wm.gyp:wm',
'keyboard_resources',
],
'defines': [
'KEYBOARD_IMPLEMENTATION',
],
'sources': [
- 'keyboard.cc',
- 'keyboard.h',
- 'keyboard_constants.cc',
- 'keyboard_constants.h',
'keyboard_controller.cc',
'keyboard_controller.h',
'keyboard_controller_observer.h',
- 'keyboard_controller_proxy.cc',
- 'keyboard_controller_proxy.h',
'keyboard_export.h',
'keyboard_layout_manager.cc',
'keyboard_layout_manager.h',
'keyboard_switches.cc',
'keyboard_switches.h',
+ 'keyboard_ui.cc',
+ 'keyboard_ui.h',
'keyboard_util.cc',
'keyboard_util.h',
],
@@ -96,15 +88,51 @@
],
},
{
+ # GN version: //ui/keyboard:keyboard_with_content
+ 'target_name': 'keyboard_with_content',
+ 'type': '<(component)',
+ 'dependencies': [
+ 'keyboard',
+ '../../base/base.gyp:base',
+ '../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../../content/content.gyp:content_browser',
+ '../../ipc/ipc.gyp:ipc',
+ '../../skia/skia.gyp:skia',
+ '../../url/url.gyp:url_lib',
+ '../aura/aura.gyp:aura',
+ '../base/ime/ui_base_ime.gyp:ui_base_ime',
+ '../base/ui_base.gyp:ui_base',
+ '../compositor/compositor.gyp:compositor',
+ '../events/events.gyp:dom_keycode_converter',
+ '../events/events.gyp:events',
+ '../events/events.gyp:events_base',
+ '../gfx/gfx.gyp:gfx',
+ '../gfx/gfx.gyp:gfx_geometry',
+ '../wm/wm.gyp:wm',
+ 'keyboard_resources',
+ ],
+ 'defines': [
+ 'KEYBOARD_IMPLEMENTATION',
+ ],
+ 'sources': [
+ 'content/keyboard.cc',
+ 'content/keyboard.h',
+ 'content/keyboard_constants.cc',
+ 'content/keyboard_constants.h',
+ 'content/keyboard_content_util.cc',
+ 'content/keyboard_content_util.h',
+ 'content/keyboard_ui_content.cc',
+ 'content/keyboard_ui_content.h',
+ ],
+ },
+ {
'target_name': 'keyboard_unittests',
'type': '<(gtest_target_type)',
'dependencies': [
'../../base/base.gyp:base',
'../../base/base.gyp:test_support_base',
- '../../content/content.gyp:content',
'../../skia/skia.gyp:skia',
'../../testing/gtest.gyp:gtest',
- '../../url/url.gyp:url_lib',
'../aura/aura.gyp:aura',
'../aura/aura.gyp:aura_test_support',
'../base/ime/ui_base_ime.gyp:ui_base_ime',
@@ -113,7 +141,6 @@
'../compositor/compositor.gyp:compositor_test_support',
'../gfx/gfx.gyp:gfx',
'../gfx/gfx.gyp:gfx_geometry',
- '../resources/ui_resources.gyp:ui_test_pak',
'../wm/wm.gyp:wm',
'keyboard',
],
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc
index 1be0200..a50f7c7 100644
--- a/ui/keyboard/keyboard_controller.cc
+++ b/ui/keyboard/keyboard_controller.cc
@@ -8,9 +8,6 @@
#include "base/bind.h"
#include "base/command_line.h"
-#include "content/public/browser/render_widget_host.h"
-#include "content/public/browser/render_widget_host_iterator.h"
-#include "content/public/browser/render_widget_host_view.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
@@ -24,10 +21,9 @@
#include "ui/gfx/path.h"
#include "ui/gfx/skia_util.h"
#include "ui/keyboard/keyboard_controller_observer.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_layout_manager.h"
+#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
-#include "ui/wm/core/masked_window_targeter.h"
#if defined(OS_CHROMEOS)
#include "base/process/launch.h"
@@ -161,52 +157,11 @@ void CallbackAnimationObserver::OnLayerAnimationAborted(
animator_->RemoveObserver(this);
}
-class WindowBoundsChangeObserver : public aura::WindowObserver {
- public:
- void OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) override;
- void OnWindowDestroyed(aura::Window* window) override;
-
- void AddObservedWindow(aura::Window* window);
- void RemoveAllObservedWindows();
-
- private:
- std::set<aura::Window*> observed_windows_;
-};
-
-void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) {
- KeyboardController* controller = KeyboardController::GetInstance();
- if (controller)
- controller->UpdateWindowInsets(window);
-}
-
-void WindowBoundsChangeObserver::OnWindowDestroyed(aura::Window* window) {
- if (window->HasObserver(this))
- window->RemoveObserver(this);
- observed_windows_.erase(window);
-}
-
-void WindowBoundsChangeObserver::AddObservedWindow(aura::Window* window) {
- if (!window->HasObserver(this)) {
- window->AddObserver(this);
- observed_windows_.insert(window);
- }
-}
-
-void WindowBoundsChangeObserver::RemoveAllObservedWindows() {
- for (std::set<aura::Window*>::iterator it = observed_windows_.begin();
- it != observed_windows_.end(); ++it)
- (*it)->RemoveObserver(this);
- observed_windows_.clear();
-}
-
// static
KeyboardController* KeyboardController::instance_ = NULL;
-KeyboardController::KeyboardController(KeyboardControllerProxy* proxy)
- : proxy_(proxy),
+KeyboardController::KeyboardController(KeyboardUI* ui)
+ : ui_(ui),
input_method_(NULL),
keyboard_visible_(false),
show_on_resize_(false),
@@ -214,11 +169,10 @@ KeyboardController::KeyboardController(KeyboardControllerProxy* proxy)
keyboard_mode_(FULL_WIDTH),
type_(ui::TEXT_INPUT_TYPE_NONE),
weak_factory_(this) {
- CHECK(proxy);
- input_method_ = proxy_->GetInputMethod();
+ CHECK(ui);
+ input_method_ = ui_->GetInputMethod();
input_method_->AddObserver(this);
- window_bounds_observer_.reset(new WindowBoundsChangeObserver());
- proxy_->SetController(this);
+ ui_->SetController(this);
}
KeyboardController::~KeyboardController() {
@@ -229,8 +183,7 @@ KeyboardController::~KeyboardController() {
}
if (input_method_)
input_method_->RemoveObserver(this);
- ResetWindowInsets();
- proxy_->SetController(nullptr);
+ ui_->SetController(nullptr);
}
// static
@@ -260,45 +213,14 @@ aura::Window* KeyboardController::GetContainerWindow() {
void KeyboardController::NotifyKeyboardBoundsChanging(
const gfx::Rect& new_bounds) {
current_keyboard_bounds_ = new_bounds;
- if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) {
+ if (ui_->HasKeyboardWindow() && ui_->GetKeyboardWindow()->IsVisible()) {
FOR_EACH_OBSERVER(KeyboardControllerObserver,
observer_list_,
OnKeyboardBoundsChanging(new_bounds));
- if (keyboard::IsKeyboardOverscrollEnabled()) {
- // Adjust the height of the viewport for visible windows on the primary
- // display.
- // TODO(kevers): Add EnvObserver to properly initialize insets if a
- // window is created while the keyboard is visible.
- scoped_ptr<content::RenderWidgetHostIterator> widgets(
- content::RenderWidgetHost::GetRenderWidgetHosts());
- aura::Window* keyboard_window = proxy_->GetKeyboardWindow();
- aura::Window* root_window = keyboard_window->GetRootWindow();
- while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
- content::RenderWidgetHostView* view = widget->GetView();
- // Can be NULL, e.g. if the RenderWidget is being destroyed or
- // the render process crashed.
- if (view) {
- aura::Window* window = view->GetNativeView();
- // If virtual keyboard failed to load, a widget that displays error
- // message will be created and adds as a child of the virtual keyboard
- // window. We want to avoid add BoundsChangedObserver to that window.
- if (!keyboard_window->Contains(window) &&
- window->GetRootWindow() == root_window) {
- gfx::Rect window_bounds = window->GetBoundsInScreen();
- gfx::Rect intersect = gfx::IntersectRects(window_bounds,
- new_bounds);
- int overlap = intersect.height();
- if (overlap > 0 && overlap < window_bounds.height())
- view->SetInsets(gfx::Insets(0, 0, overlap, 0));
- else
- view->SetInsets(gfx::Insets());
- AddBoundsChangedObserver(window);
- }
- }
- }
- } else {
- ResetWindowInsets();
- }
+ if (keyboard::IsKeyboardOverscrollEnabled())
+ ui_->InitInsets(new_bounds);
+ else
+ ui_->ResetInsets();
} else {
current_keyboard_bounds_ = gfx::Rect();
}
@@ -373,7 +295,7 @@ void KeyboardController::ShowKeyboard(bool lock) {
void KeyboardController::OnWindowHierarchyChanged(
const HierarchyChangeParams& params) {
if (params.new_parent && params.target == container_.get())
- OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient());
+ OnTextInputStateChanged(ui_->GetInputMethod()->GetTextInputClient());
}
void KeyboardController::OnWindowAddedToRootWindow(aura::Window* window) {
@@ -394,7 +316,7 @@ void KeyboardController::OnWindowBoundsChanged(aura::Window* window,
return;
// Keep the same height when window resize. It gets called when screen
// rotate.
- if (!keyboard_container_initialized() || !proxy_->HasKeyboardWindow())
+ if (!keyboard_container_initialized() || !ui_->HasKeyboardWindow())
return;
int container_height = container_->bounds().height();
@@ -416,11 +338,11 @@ void KeyboardController::OnWindowBoundsChanged(aura::Window* window,
}
void KeyboardController::Reload() {
- if (proxy_->HasKeyboardWindow()) {
+ if (ui_->HasKeyboardWindow()) {
// A reload should never try to show virtual keyboard. If keyboard is not
// visible before reload, it should keep invisible after reload.
show_on_resize_ = false;
- proxy_->ReloadKeyboardIfNeeded();
+ ui_->ReloadKeyboardIfNeeded();
}
}
@@ -448,7 +370,7 @@ void KeyboardController::OnTextInputStateChanged(
weak_factory_.InvalidateWeakPtrs();
keyboard_visible_ = true;
}
- proxy_->SetUpdateInputType(type_);
+ ui_->SetUpdateInputType(type_);
// Do not explicitly show the Virtual keyboard unless it is in the process
// of hiding. Instead, the virtual keyboard is shown in response to a user
// gesture (mouse or touch) that is received while an element has input
@@ -467,53 +389,23 @@ void KeyboardController::OnShowImeIfNeeded() {
ShowKeyboardInternal();
}
-bool KeyboardController::ShouldEnableInsets(aura::Window* window) {
- aura::Window* keyboard_window = proxy_->GetKeyboardWindow();
- return (keyboard_window->GetRootWindow() == window->GetRootWindow() &&
- keyboard::IsKeyboardOverscrollEnabled() &&
- keyboard_window->IsVisible() && keyboard_visible_);
-}
-
-void KeyboardController::UpdateWindowInsets(aura::Window* window) {
- aura::Window* keyboard_window = proxy_->GetKeyboardWindow();
- if (window == keyboard_window)
- return;
-
- scoped_ptr<content::RenderWidgetHostIterator> widgets(
- content::RenderWidgetHost::GetRenderWidgetHosts());
- while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
- content::RenderWidgetHostView* view = widget->GetView();
- if (view && window->Contains(view->GetNativeView())) {
- gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen();
- gfx::Rect intersect =
- gfx::IntersectRects(window_bounds, keyboard_window->bounds());
- int overlap = ShouldEnableInsets(window) ? intersect.height() : 0;
- if (overlap > 0 && overlap < window_bounds.height())
- view->SetInsets(gfx::Insets(0, 0, overlap, 0));
- else
- view->SetInsets(gfx::Insets());
- return;
- }
- }
-}
-
void KeyboardController::ShowKeyboardInternal() {
if (!container_.get())
return;
if (container_->children().empty()) {
keyboard::MarkKeyboardLoadStarted();
- aura::Window* keyboard = proxy_->GetKeyboardWindow();
+ aura::Window* keyboard = ui_->GetKeyboardWindow();
keyboard->Show();
container_->AddChild(keyboard);
keyboard->set_owned_by_parent(false);
}
- proxy_->ReloadKeyboardIfNeeded();
+ ui_->ReloadKeyboardIfNeeded();
if (keyboard_visible_) {
return;
- } else if (proxy_->GetKeyboardWindow()->bounds().height() == 0) {
+ } else if (ui_->GetKeyboardWindow()->bounds().height() == 0) {
show_on_resize_ = true;
return;
}
@@ -559,7 +451,7 @@ void KeyboardController::ShowKeyboardInternal() {
container_animator->AddObserver(animation_observer_.get());
}
- proxy_->ShowKeyboardContainer(container_.get());
+ ui_->ShowKeyboardContainer(container_.get());
{
// Scope the following animation settings as we don't want to animate
@@ -575,18 +467,6 @@ void KeyboardController::ShowKeyboardInternal() {
}
}
-void KeyboardController::ResetWindowInsets() {
- const gfx::Insets insets;
- scoped_ptr<content::RenderWidgetHostIterator> widgets(
- content::RenderWidgetHost::GetRenderWidgetHosts());
- while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
- content::RenderWidgetHostView* view = widget->GetView();
- if (view)
- view->SetInsets(insets);
- }
- window_bounds_observer_->RemoveAllObservedWindows();
-}
-
bool KeyboardController::WillHideKeyboard() const {
return weak_factory_.HasWeakPtrs();
}
@@ -595,17 +475,11 @@ void KeyboardController::ShowAnimationFinished() {
// Notify observers after animation finished to prevent reveal desktop
// background during animation.
NotifyKeyboardBoundsChanging(container_->bounds());
- proxy_->EnsureCaretInWorkArea();
+ ui_->EnsureCaretInWorkArea();
}
void KeyboardController::HideAnimationFinished() {
- proxy_->HideKeyboardContainer(container_.get());
-}
-
-void KeyboardController::AddBoundsChangedObserver(aura::Window* window) {
- aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr;
- if (target_window)
- window_bounds_observer_->AddObservedWindow(target_window);
+ ui_->HideKeyboardContainer(container_.get());
}
} // namespace keyboard
diff --git a/ui/keyboard/keyboard_controller.h b/ui/keyboard/keyboard_controller.h
index a5156bb..5211d0d 100644
--- a/ui/keyboard/keyboard_controller.h
+++ b/ui/keyboard/keyboard_controller.h
@@ -14,7 +14,6 @@
#include "ui/base/ime/text_input_type.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/keyboard/keyboard_export.h"
-#include "url/gurl.h"
namespace aura {
class Window;
@@ -27,9 +26,8 @@ class TextInputClient;
namespace keyboard {
class CallbackAnimationObserver;
-class WindowBoundsChangeObserver;
class KeyboardControllerObserver;
-class KeyboardControllerProxy;
+class KeyboardUI;
// Animation distance.
const int kAnimationDistance = 30;
@@ -58,8 +56,8 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
HIDE_REASON_MANUAL,
};
- // Takes ownership of |proxy|.
- explicit KeyboardController(KeyboardControllerProxy* proxy);
+ // Takes ownership of |ui|.
+ explicit KeyboardController(KeyboardUI* ui);
~KeyboardController() override;
// Returns the container for the keyboard, which is owned by
@@ -88,7 +86,7 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
virtual void AddObserver(KeyboardControllerObserver* observer);
virtual void RemoveObserver(KeyboardControllerObserver* observer);
- KeyboardControllerProxy* proxy() { return proxy_.get(); }
+ KeyboardUI* ui() { return ui_.get(); }
void set_lock_keyboard(bool lock) { lock_keyboard_ = lock; }
@@ -119,12 +117,6 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
return current_keyboard_bounds_;
}
- // Determines whether a particular window should have insets for overscroll.
- bool ShouldEnableInsets(aura::Window* window);
-
- // Updates insets on web content window
- void UpdateWindowInsets(aura::Window* window);
-
private:
// For access to Observer methods for simulation.
friend class KeyboardControllerTest;
@@ -150,9 +142,6 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// Show virtual keyboard immediately with animation.
void ShowKeyboardInternal();
- // Clears any insets on web content windows.
- void ResetWindowInsets();
-
// Returns true if keyboard is scheduled to hide.
bool WillHideKeyboard() const;
@@ -161,19 +150,12 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
void ShowAnimationFinished();
void HideAnimationFinished();
- // Adds an observer for tracking changes to a window size or
- // position while the keyboard is displayed. Any window repositioning
- // invalidates insets for overscrolling.
- void AddBoundsChangedObserver(aura::Window* window);
-
- scoped_ptr<KeyboardControllerProxy> proxy_;
+ scoped_ptr<KeyboardUI> ui_;
scoped_ptr<aura::Window> container_;
// CallbackAnimationObserver should destructed before container_ because it
// uses container_'s animator.
scoped_ptr<CallbackAnimationObserver> animation_observer_;
- scoped_ptr<WindowBoundsChangeObserver> window_bounds_observer_;
-
ui::InputMethod* input_method_;
bool keyboard_visible_;
bool show_on_resize_;
diff --git a/ui/keyboard/keyboard_controller_proxy.cc b/ui/keyboard/keyboard_controller_proxy.cc
deleted file mode 100644
index 3671b02..0000000
--- a/ui/keyboard/keyboard_controller_proxy.cc
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/keyboard/keyboard_controller_proxy.h"
-
-#include "base/command_line.h"
-#include "base/values.h"
-#include "content/public/browser/site_instance.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_delegate.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/common/bindings_policy.h"
-#include "ui/aura/layout_manager.h"
-#include "ui/aura/window.h"
-#include "ui/base/ime/input_method.h"
-#include "ui/base/ime/text_input_client.h"
-#include "ui/keyboard/keyboard_constants.h"
-#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_switches.h"
-#include "ui/keyboard/keyboard_util.h"
-#include "ui/wm/core/shadow.h"
-
-namespace {
-
-// The WebContentsDelegate for the keyboard.
-// The delegate deletes itself when the keyboard is destroyed.
-class KeyboardContentsDelegate : public content::WebContentsDelegate,
- public content::WebContentsObserver {
- public:
- KeyboardContentsDelegate(keyboard::KeyboardControllerProxy* proxy)
- : proxy_(proxy) {}
- ~KeyboardContentsDelegate() override {}
-
- private:
- // Overridden from content::WebContentsDelegate:
- content::WebContents* OpenURLFromTab(
- content::WebContents* source,
- const content::OpenURLParams& params) override {
- source->GetController().LoadURL(
- params.url, params.referrer, params.transition, params.extra_headers);
- Observe(source);
- return source;
- }
-
- bool CanDragEnter(content::WebContents* source,
- const content::DropData& data,
- blink::WebDragOperationsMask operations_allowed) override {
- return false;
- }
-
- bool ShouldCreateWebContents(
- content::WebContents* web_contents,
- int route_id,
- int main_frame_route_id,
- WindowContainerType window_container_type,
- const std::string& frame_name,
- const GURL& target_url,
- const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override {
- return false;
- }
-
- bool IsPopupOrPanel(const content::WebContents* source) const override {
- return true;
- }
-
- void MoveContents(content::WebContents* source,
- const gfx::Rect& pos) override {
- aura::Window* keyboard = proxy_->GetKeyboardWindow();
- // keyboard window must have been added to keyboard container window at this
- // point. Otherwise, wrong keyboard bounds is used and may cause problem as
- // described in crbug.com/367788.
- DCHECK(keyboard->parent());
- // keyboard window bounds may not set to |pos| after this call. If keyboard
- // is in FULL_WIDTH mode, only the height of keyboard window will be
- // changed.
- keyboard->SetBounds(pos);
- }
-
- // Overridden from content::WebContentsDelegate:
- void RequestMediaAccessPermission(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) override {
- proxy_->RequestAudioInput(web_contents, request, callback);
- }
-
- // Overridden from content::WebContentsObserver:
- void WebContentsDestroyed() override { delete this; }
-
- keyboard::KeyboardControllerProxy* proxy_;
-
- DISALLOW_COPY_AND_ASSIGN(KeyboardContentsDelegate);
-};
-
-} // namespace
-
-namespace keyboard {
-
-KeyboardControllerProxy::KeyboardControllerProxy(
- content::BrowserContext* context)
- : browser_context_(context),
- default_url_(kKeyboardURL),
- keyboard_controller_(nullptr) {
-}
-
-KeyboardControllerProxy::~KeyboardControllerProxy() {
-}
-
-const GURL& KeyboardControllerProxy::GetVirtualKeyboardUrl() {
- if (keyboard::IsInputViewEnabled()) {
- const GURL& override_url = GetOverrideContentUrl();
- return override_url.is_valid() ? override_url : default_url_;
- } else {
- return default_url_;
- }
-}
-
-void KeyboardControllerProxy::LoadContents(const GURL& url) {
- if (keyboard_contents_) {
- content::OpenURLParams params(
- url,
- content::Referrer(),
- SINGLETON_TAB,
- ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
- false);
- keyboard_contents_->OpenURL(params);
- }
-}
-
-aura::Window* KeyboardControllerProxy::GetKeyboardWindow() {
- if (!keyboard_contents_) {
- content::BrowserContext* context = browser_context();
- keyboard_contents_.reset(content::WebContents::Create(
- content::WebContents::CreateParams(context,
- content::SiteInstance::CreateForURL(context,
- GetVirtualKeyboardUrl()))));
- keyboard_contents_->SetDelegate(new KeyboardContentsDelegate(this));
- SetupWebContents(keyboard_contents_.get());
- LoadContents(GetVirtualKeyboardUrl());
- keyboard_contents_->GetNativeView()->AddObserver(this);
- }
-
- return keyboard_contents_->GetNativeView();
-}
-
-bool KeyboardControllerProxy::HasKeyboardWindow() const {
- return keyboard_contents_;
-}
-
-void KeyboardControllerProxy::ShowKeyboardContainer(aura::Window* container) {
- GetKeyboardWindow()->Show();
- container->Show();
-}
-
-void KeyboardControllerProxy::HideKeyboardContainer(aura::Window* container) {
- container->Hide();
- GetKeyboardWindow()->Hide();
-}
-
-void KeyboardControllerProxy::SetUpdateInputType(ui::TextInputType type) {
-}
-
-void KeyboardControllerProxy::EnsureCaretInWorkArea() {
- if (GetInputMethod()->GetTextInputClient()) {
- 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);
- }
-}
-
-void KeyboardControllerProxy::LoadSystemKeyboard() {
- DCHECK(keyboard_contents_);
- if (keyboard_contents_->GetURL() != default_url_) {
- // TODO(bshe): The height of system virtual keyboard and IME virtual
- // keyboard may different. The height needs to be restored too.
- LoadContents(default_url_);
- }
-}
-
-void KeyboardControllerProxy::ReloadKeyboardIfNeeded() {
- DCHECK(keyboard_contents_);
- if (keyboard_contents_->GetURL() != GetVirtualKeyboardUrl()) {
- if (keyboard_contents_->GetURL().GetOrigin() !=
- GetVirtualKeyboardUrl().GetOrigin()) {
- // Sets keyboard window rectangle to 0 and close current page before
- // navigate to a keyboard in a different extension. This keeps the UX the
- // same as Android. Note we need to explicitly close current page as it
- // might try to resize keyboard window in javascript on a resize event.
- GetKeyboardWindow()->SetBounds(gfx::Rect());
- keyboard_contents_->ClosePage();
- keyboard_controller()->SetKeyboardMode(FULL_WIDTH);
- }
- LoadContents(GetVirtualKeyboardUrl());
- }
-}
-
-void KeyboardControllerProxy::SetController(KeyboardController* controller) {
- keyboard_controller_ = controller;
-}
-
-void KeyboardControllerProxy::SetupWebContents(content::WebContents* contents) {
-}
-
-void KeyboardControllerProxy::OnWindowBoundsChanged(
- aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
- if (!shadow_) {
- shadow_.reset(new wm::Shadow());
- shadow_->Init(wm::Shadow::STYLE_ACTIVE);
- shadow_->layer()->SetVisible(true);
- DCHECK(keyboard_contents_->GetNativeView()->parent());
- keyboard_contents_->GetNativeView()->parent()->layer()->Add(
- shadow_->layer());
- }
-
- shadow_->SetContentBounds(new_bounds);
-}
-
-void KeyboardControllerProxy::OnWindowDestroyed(aura::Window* window) {
- window->RemoveObserver(this);
-}
-
-} // namespace keyboard
diff --git a/ui/keyboard/keyboard_controller_proxy.h b/ui/keyboard/keyboard_controller_proxy.h
deleted file mode 100644
index 98051fa..0000000
--- a/ui/keyboard/keyboard_controller_proxy.h
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
-#define UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "content/public/common/media_stream_request.h"
-#include "ui/aura/window_observer.h"
-#include "ui/base/ime/text_input_type.h"
-#include "ui/keyboard/keyboard_export.h"
-
-namespace aura {
-class Window;
-}
-namespace content {
-class BrowserContext;
-class SiteInstance;
-class WebContents;
-}
-namespace gfx {
-class Rect;
-}
-namespace ui {
-class InputMethod;
-}
-namespace wm {
-class Shadow;
-}
-
-namespace keyboard {
-
-class KeyboardController;
-
-// A proxy used by the KeyboardController to get access to the virtual
-// keyboard window.
-class KEYBOARD_EXPORT KeyboardControllerProxy : public aura::WindowObserver {
- public:
- class TestApi {
- public:
- explicit TestApi(KeyboardControllerProxy* proxy) : proxy_(proxy) {}
-
- const content::WebContents* keyboard_contents() {
- return proxy_->keyboard_contents_.get();
- }
-
- private:
- KeyboardControllerProxy* proxy_;
-
- DISALLOW_COPY_AND_ASSIGN(TestApi);
- };
-
- explicit KeyboardControllerProxy(content::BrowserContext* context);
- ~KeyboardControllerProxy() override;
-
- // Gets the virtual keyboard window. Ownership of the returned Window remains
- // with the proxy.
- virtual aura::Window* GetKeyboardWindow();
-
- // Whether the keyboard window is created. The keyboard window is tied to a
- // WebContent so we can just check if the WebContent is created or not.
- virtual bool HasKeyboardWindow() const;
-
- // Gets the InputMethod that will provide notifications about changes in the
- // text input context.
- virtual ui::InputMethod* GetInputMethod() = 0;
-
- // Requests the audio input from microphone for speech input.
- virtual void RequestAudioInput(content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) = 0;
-
- // Shows the container window of the keyboard. The default implementation
- // simply shows the container. An overridden implementation can set up
- // necessary animation, or delay the visibility change as it desires.
- virtual void ShowKeyboardContainer(aura::Window* container);
-
- // Hides the container window of the keyboard. The default implementation
- // simply hides the container. An overridden implementation can set up
- // necesasry animation, or delay the visibility change as it desires.
- virtual void HideKeyboardContainer(aura::Window* container);
-
- // Updates the type of the focused text input box.
- virtual void SetUpdateInputType(ui::TextInputType type);
-
- // Ensures caret in current work area (not occluded by virtual keyboard
- // window).
- virtual void EnsureCaretInWorkArea();
-
- // Loads system virtual keyboard. Noop if the current virtual keyboard is
- // system virtual keyboard.
- virtual void LoadSystemKeyboard();
-
- // Reloads virtual keyboard URL if the current keyboard's web content URL is
- // different. The URL can be different if user switch from password field to
- // any other type input field.
- // At password field, the system virtual keyboard is forced to load even if
- // the current IME provides a customized virtual keyboard. This is needed to
- // prevent IME virtual keyboard logging user's password. Once user switch to
- // other input fields, the virtual keyboard should switch back to the IME
- // provided keyboard, or keep using the system virtual keyboard if IME doesn't
- // provide one.
- virtual void ReloadKeyboardIfNeeded();
-
- // KeyboardController owns KeyboardControllerProxy so KeyboardControllerProxy
- // or its subclasses should not take ownership of the |controller|.
- // |controller| can be null when KeyboardController is destroying.
- virtual void SetController(KeyboardController* controller);
-
- protected:
- // The implementation can choose to setup the WebContents before the virtual
- // keyboard page is loaded (e.g. install a WebContentsObserver).
- // SetupWebContents() is called right after creating the WebContents, before
- // loading the keyboard page.
- virtual void SetupWebContents(content::WebContents* contents);
-
- // aura::WindowObserver overrides:
- void OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) override;
- void OnWindowDestroyed(aura::Window* window) override;
-
- content::BrowserContext* browser_context() { return browser_context_; }
- KeyboardController* keyboard_controller() { return keyboard_controller_; }
-
- private:
- friend class TestApi;
-
- // Loads the web contents for the given |url|.
- void LoadContents(const GURL& url);
-
- // Gets the virtual keyboard URL (either the default URL or IME override URL).
- const GURL& GetVirtualKeyboardUrl();
-
- // The BrowserContext to use for creating the WebContents hosting the
- // keyboard.
- content::BrowserContext* browser_context_;
-
- const GURL default_url_;
- keyboard::KeyboardController* keyboard_controller_;
-
- scoped_ptr<content::WebContents> keyboard_contents_;
- scoped_ptr<wm::Shadow> shadow_;
-
- DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxy);
-};
-
-} // namespace keyboard
-
-#endif // UI_KEYBOARD_KEYBOARD_CONTROLLER_PROXY_H_
diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc
index b30f7a5..5c5cf1c 100644
--- a/ui/keyboard/keyboard_controller_unittest.cc
+++ b/ui/keyboard/keyboard_controller_unittest.cc
@@ -28,7 +28,7 @@
#include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/keyboard/keyboard_controller_observer.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
+#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/wm/core/default_activation_client.h"
@@ -86,18 +86,15 @@ class TestFocusController : public ui::EventHandler {
DISALLOW_COPY_AND_ASSIGN(TestFocusController);
};
-class TestKeyboardControllerProxy : public KeyboardControllerProxy {
+class TestKeyboardUI : public KeyboardUI {
public:
- TestKeyboardControllerProxy(ui::InputMethod* input_method)
- : KeyboardControllerProxy(nullptr),
- input_method_(input_method) {}
-
- ~TestKeyboardControllerProxy() override {
+ TestKeyboardUI(ui::InputMethod* input_method) : input_method_(input_method) {}
+ ~TestKeyboardUI() override {
// Destroy the window before the delegate.
window_.reset();
}
- // Overridden from KeyboardControllerProxy:
+ // Overridden from KeyboardUI:
bool HasKeyboardWindow() const override { return window_; }
aura::Window* GetKeyboardWindow() override {
if (!window_) {
@@ -108,21 +105,17 @@ class TestKeyboardControllerProxy : public KeyboardControllerProxy {
return window_.get();
}
ui::InputMethod* GetInputMethod() override { return input_method_; }
- void RequestAudioInput(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) override {
- return;
- }
- void LoadSystemKeyboard() override{};
- void ReloadKeyboardIfNeeded() override{};
+ void SetUpdateInputType(ui::TextInputType type) override {}
+ void ReloadKeyboardIfNeeded() override {};
+ void InitInsets(const gfx::Rect& keyboard_bounds) override {}
+ void ResetInsets() override {}
private:
scoped_ptr<aura::Window> window_;
aura::test::TestWindowDelegate delegate_;
ui::InputMethod* input_method_;
- DISALLOW_COPY_AND_ASSIGN(TestKeyboardControllerProxy);
+ DISALLOW_COPY_AND_ASSIGN(TestKeyboardUI);
};
// Keeps a count of all the events a window receives.
@@ -169,7 +162,7 @@ class KeyboardContainerObserver : public aura::WindowObserver {
class KeyboardControllerTest : public testing::Test,
public KeyboardControllerObserver {
public:
- KeyboardControllerTest() : number_of_calls_(0), proxy_(nullptr) {}
+ KeyboardControllerTest() : number_of_calls_(0), ui_(nullptr) {}
~KeyboardControllerTest() override {}
void SetUp() override {
@@ -183,9 +176,8 @@ class KeyboardControllerTest : public testing::Test,
aura_test_helper_->SetUp(context_factory);
new wm::DefaultActivationClient(aura_test_helper_->root_window());
focus_controller_.reset(new TestFocusController(root_window()));
- proxy_ = new TestKeyboardControllerProxy(
- aura_test_helper_->host()->GetInputMethod());
- controller_.reset(new KeyboardController(proxy_));
+ ui_ = new TestKeyboardUI(aura_test_helper_->host()->GetInputMethod());
+ controller_.reset(new KeyboardController(ui_));
controller()->AddObserver(this);
}
@@ -198,7 +190,7 @@ class KeyboardControllerTest : public testing::Test,
}
aura::Window* root_window() { return aura_test_helper_->root_window(); }
- KeyboardControllerProxy* proxy() { return proxy_; }
+ KeyboardUI* ui() { return ui_; }
KeyboardController* controller() { return controller_.get(); }
void ShowKeyboard() {
@@ -228,13 +220,13 @@ class KeyboardControllerTest : public testing::Test,
const gfx::Rect& notified_bounds() { return notified_bounds_; }
void SetFocus(ui::TextInputClient* client) {
- ui::InputMethod* input_method = proxy()->GetInputMethod();
+ ui::InputMethod* input_method = ui()->GetInputMethod();
input_method->SetFocusedTextInputClient(client);
if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) {
input_method->ShowImeIfNeeded();
- if (proxy_->GetKeyboardWindow()->bounds().height() == 0) {
+ if (ui_->GetKeyboardWindow()->bounds().height() == 0) {
// Set initial bounds for test keyboard window.
- proxy_->GetKeyboardWindow()->SetBounds(
+ ui_->GetKeyboardWindow()->SetBounds(
FullWidthKeyboardBoundsFromRootBounds(
root_window()->bounds(), kDefaultVirtualKeyboardHeight));
}
@@ -246,7 +238,11 @@ class KeyboardControllerTest : public testing::Test,
}
bool ShouldEnableInsets(aura::Window* window) {
- return controller_->ShouldEnableInsets(window);
+ aura::Window* keyboard_window = ui_->GetKeyboardWindow();
+ return (keyboard_window->GetRootWindow() == window->GetRootWindow() &&
+ keyboard::IsKeyboardOverscrollEnabled() &&
+ keyboard_window->IsVisible() &&
+ controller_->keyboard_visible());
}
base::MessageLoopForUI message_loop_;
@@ -256,7 +252,7 @@ class KeyboardControllerTest : public testing::Test,
private:
int number_of_calls_;
gfx::Rect notified_bounds_;
- KeyboardControllerProxy* proxy_;
+ KeyboardUI* ui_;
scoped_ptr<KeyboardController> controller_;
scoped_ptr<ui::TextInputClient> test_text_input_client_;
DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest);
@@ -264,7 +260,7 @@ class KeyboardControllerTest : public testing::Test,
TEST_F(KeyboardControllerTest, KeyboardSize) {
aura::Window* container(controller()->GetContainerWindow());
- aura::Window* keyboard(proxy()->GetKeyboardWindow());
+ aura::Window* keyboard(ui()->GetKeyboardWindow());
gfx::Rect screen_bounds = root_window()->bounds();
root_window()->AddChild(container);
container->AddChild(keyboard);
@@ -303,7 +299,7 @@ TEST_F(KeyboardControllerTest, KeyboardSize) {
TEST_F(KeyboardControllerTest, FloatingKeyboardSize) {
aura::Window* container(controller()->GetContainerWindow());
- aura::Window* keyboard(proxy()->GetKeyboardWindow());
+ aura::Window* keyboard(ui()->GetKeyboardWindow());
gfx::Rect screen_bounds = root_window()->bounds();
root_window()->AddChild(container);
controller()->SetKeyboardMode(FLOATING);
@@ -413,11 +409,11 @@ TEST_F(KeyboardControllerTest, CheckOverscrollInsetDuringVisibilityChange) {
SetFocus(&no_input_client);
// Insets should not be enabled for new windows while keyboard is in the
// process of hiding when overscroll is enabled.
- EXPECT_FALSE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
+ EXPECT_FALSE(ShouldEnableInsets(ui()->GetKeyboardWindow()));
// Cancel keyboard hide.
SetFocus(&input_client);
// Insets should be enabled for new windows as hide was cancelled.
- EXPECT_TRUE(ShouldEnableInsets(proxy()->GetKeyboardWindow()));
+ EXPECT_TRUE(ShouldEnableInsets(ui()->GetKeyboardWindow()));
}
// Verify switch to FLOATING mode will reset the overscroll or resize and when
@@ -543,7 +539,7 @@ class KeyboardControllerAnimationTest : public KeyboardControllerTest {
}
aura::Window* keyboard_window() {
- return proxy()->GetKeyboardWindow();
+ return ui()->GetKeyboardWindow();
}
private:
diff --git a/ui/keyboard/keyboard_layout_manager.cc b/ui/keyboard/keyboard_layout_manager.cc
index 60c7303..2af8777 100644
--- a/ui/keyboard/keyboard_layout_manager.cc
+++ b/ui/keyboard/keyboard_layout_manager.cc
@@ -6,7 +6,6 @@
#include "ui/compositor/layer_animator.h"
#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_util.h"
namespace keyboard {
diff --git a/ui/keyboard/keyboard_ui.cc b/ui/keyboard/keyboard_ui.cc
new file mode 100644
index 0000000..816933b
--- /dev/null
+++ b/ui/keyboard/keyboard_ui.cc
@@ -0,0 +1,47 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/keyboard/keyboard_ui.h"
+
+#include "ui/aura/window.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/text_input_client.h"
+#include "ui/keyboard/keyboard_controller.h"
+
+namespace keyboard {
+
+KeyboardUI::KeyboardUI() : keyboard_controller_(nullptr) {}
+KeyboardUI::~KeyboardUI() {}
+
+void KeyboardUI::ShowKeyboardContainer(aura::Window* container) {
+ if (HasKeyboardWindow()) {
+ GetKeyboardWindow()->Show();
+ container->Show();
+ }
+}
+
+void KeyboardUI::HideKeyboardContainer(aura::Window* container) {
+ if (HasKeyboardWindow()) {
+ container->Hide();
+ GetKeyboardWindow()->Hide();
+ }
+}
+
+void KeyboardUI::EnsureCaretInWorkArea() {
+ if (GetInputMethod()->GetTextInputClient()) {
+ 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);
+ }
+}
+
+void KeyboardUI::SetController(KeyboardController* controller) {
+ keyboard_controller_ = controller;
+}
+
+} // namespace keyboard
diff --git a/ui/keyboard/keyboard_ui.h b/ui/keyboard/keyboard_ui.h
new file mode 100644
index 0000000..895617ff
--- /dev/null
+++ b/ui/keyboard/keyboard_ui.h
@@ -0,0 +1,94 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_KEYBOARD_KEYBOARD_UI_H_
+#define UI_KEYBOARD_KEYBOARD_UI_H_
+
+#include "base/macros.h"
+#include "ui/base/ime/text_input_type.h"
+#include "ui/keyboard/keyboard_export.h"
+
+namespace aura {
+class Window;
+}
+namespace gfx {
+class Rect;
+}
+namespace ui {
+class InputMethod;
+}
+
+namespace keyboard {
+
+class KeyboardController;
+
+// An interface implemented by an object that implements a keyboard UI.
+class KEYBOARD_EXPORT KeyboardUI {
+ public:
+ KeyboardUI();
+ virtual ~KeyboardUI();
+
+ // Gets the virtual keyboard window. May return null if the window has not yet
+ // been created.
+ virtual aura::Window* GetKeyboardWindow() = 0;
+
+ // Whether the keyboard window has been created.
+ virtual bool HasKeyboardWindow() const = 0;
+
+ // Gets the InputMethod that will provide notifications about changes in the
+ // text input context.
+ virtual ui::InputMethod* GetInputMethod() = 0;
+
+ // Shows the container window of the keyboard. The default implementation
+ // simply shows the container. An overridden implementation can set up
+ // necessary animation, or delay the visibility change as it desires.
+ virtual void ShowKeyboardContainer(aura::Window* container);
+
+ // Hides the container window of the keyboard. The default implementation
+ // simply hides the container. An overridden implementation can set up
+ // necesasry animation, or delay the visibility change as it desires.
+ virtual void HideKeyboardContainer(aura::Window* container);
+
+ // Updates the type of the focused text input box.
+ virtual void SetUpdateInputType(ui::TextInputType type) = 0;
+
+ // Ensures caret in current work area (not occluded by virtual keyboard
+ // window).
+ virtual void EnsureCaretInWorkArea();
+
+ // KeyboardController owns the KeyboardUI instance so KeyboardUI subclasses
+ // should not take ownership of the |controller|. |controller| can be null
+ // when KeyboardController is destroying.
+ virtual void SetController(KeyboardController* controller);
+
+ // Reloads virtual keyboard URL if the current keyboard's web content URL is
+ // different. The URL can be different if user switch from password field to
+ // any other type input field.
+ // At password field, the system virtual keyboard is forced to load even if
+ // the current IME provides a customized virtual keyboard. This is needed to
+ // prevent IME virtual keyboard logging user's password. Once user switch to
+ // other input fields, the virtual keyboard should switch back to the IME
+ // provided keyboard, or keep using the system virtual keyboard if IME doesn't
+ // provide one.
+ virtual void ReloadKeyboardIfNeeded() = 0;
+
+ // When the embedder changes the keyboard bounds, asks the keyboard to adjust
+ // insets for windows affected by this.
+ virtual void InitInsets(const gfx::Rect& keyboard_bounds) = 0;
+
+ // Resets insets for affected windows.
+ virtual void ResetInsets() = 0;
+
+ protected:
+ KeyboardController* keyboard_controller() { return keyboard_controller_; }
+
+ private:
+ keyboard::KeyboardController* keyboard_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyboardUI);
+};
+
+} // namespace keyboard
+
+#endif // UI_KEYBOARD_KEYBOARD_UI_H_
diff --git a/ui/keyboard/keyboard_util.cc b/ui/keyboard/keyboard_util.cc
index ecc8e29..2a5ae6a 100644
--- a/ui/keyboard/keyboard_util.cc
+++ b/ui/keyboard/keyboard_util.cc
@@ -12,8 +12,6 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/strings/string16.h"
-#include "grit/keyboard_resources.h"
-#include "grit/keyboard_resources_map.h"
#include "media/audio/audio_manager.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window_tree_host.h"
@@ -26,9 +24,8 @@
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
#include "ui/keyboard/keyboard_controller.h"
-#include "ui/keyboard/keyboard_controller_proxy.h"
#include "ui/keyboard/keyboard_switches.h"
-#include "url/gurl.h"
+#include "ui/keyboard/keyboard_ui.h"
namespace {
@@ -52,8 +49,6 @@ bool g_accessibility_keyboard_enabled = false;
bool g_hotrod_keyboard_enabled = false;
-base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER;
-
bool g_touch_keyboard_enabled = false;
keyboard::KeyboardState g_requested_keyboard_state =
@@ -223,7 +218,7 @@ bool InsertText(const base::string16& text) {
if (!controller)
return false;
- ui::InputMethod* input_method = controller->proxy()->GetInputMethod();
+ ui::InputMethod* input_method = controller->ui()->GetInputMethod();
if (!input_method)
return false;
@@ -390,96 +385,6 @@ void MarkKeyboardLoadFinished() {
}
}
-const GritResourceMap* GetKeyboardExtensionResources(size_t* size) {
- // This looks a lot like the contents of a resource map; however it is
- // necessary to have a custom path for the extension path, so the resource
- // map cannot be used directly.
- static const GritResourceMap kKeyboardResources[] = {
- {"keyboard/locales/en.js", IDR_KEYBOARD_LOCALES_EN},
- {"keyboard/config/emoji.js", IDR_KEYBOARD_CONFIG_EMOJI},
- {"keyboard/config/hwt.js", IDR_KEYBOARD_CONFIG_HWT},
- {"keyboard/config/us.js", IDR_KEYBOARD_CONFIG_US},
- {"keyboard/emoji.css", IDR_KEYBOARD_CSS_EMOJI},
- {"keyboard/images/3dots.png", IDR_KEYBOARD_IMAGES_3_DOTS},
- {"keyboard/images/back_to_keyboard.png",
- IDR_KEYBOARD_IMAGES_BACK_TO_KEYBOARD},
- {"keyboard/images/backspace.png", IDR_KEYBOARD_IMAGES_BACKSPACE},
- {"keyboard/images/car.png", IDR_KEYBOARD_IMAGES_CAR},
- {"keyboard/images/check.png", IDR_KEYBOARD_IMAGES_CHECK},
- {"keyboard/images/check_in_menu.png", IDR_KEYBOARD_IMAGES_CHECK_IN_MENU},
- {"keyboard/images/compact.png", IDR_KEYBOARD_IMAGES_COMPACT},
- {"keyboard/images/down.png", IDR_KEYBOARD_IMAGES_DOWN},
- {"keyboard/images/emoji.png", IDR_KEYBOARD_IMAGES_EMOJI},
- {"keyboard/images/emoji_car.png", IDR_KEYBOARD_IMAGES_EMOJI_CAR},
- {"keyboard/images/emoji_crown.png", IDR_KEYBOARD_IMAGES_EMOJI_CROWN},
- {"keyboard/images/emoji_emoticon.png",
- IDR_KEYBOARD_IMAGES_EMOJI_EMOTICON},
- {"keyboard/images/emoji_flower.png", IDR_KEYBOARD_IMAGES_EMOJI_FLOWER},
- {"keyboard/images/emoji_hot.png", IDR_KEYBOARD_IMAGES_EMOJI_HOT},
- {"keyboard/images/emoji_recent.png", IDR_KEYBOARD_IMAGES_EMOJI_RECENT},
- {"keyboard/images/emoji_shape.png", IDR_KEYBOARD_IMAGES_EMOJI_SHAPE},
- {"keyboard/images/emoji_cat_items.png", IDR_KEYBOARD_IMAGES_CAT},
- {"keyboard/images/emoticon.png", IDR_KEYBOARD_IMAGES_EMOTICON},
- {"keyboard/images/enter.png", IDR_KEYBOARD_IMAGES_RETURN},
- {"keyboard/images/error.png", IDR_KEYBOARD_IMAGES_ERROR},
- {"keyboard/images/favorit.png", IDR_KEYBOARD_IMAGES_FAVORITE},
- {"keyboard/images/flower.png", IDR_KEYBOARD_IMAGES_FLOWER},
- {"keyboard/images/globe.png", IDR_KEYBOARD_IMAGES_GLOBE},
- {"keyboard/images/hide.png", IDR_KEYBOARD_IMAGES_HIDE},
- {"keyboard/images/hidekeyboard.png", IDR_KEYBOARD_IMAGES_HIDE_KEYBOARD},
- {"keyboard/images/keyboard.svg", IDR_KEYBOARD_IMAGES_KEYBOARD},
- {"keyboard/images/left.png", IDR_KEYBOARD_IMAGES_LEFT},
- {"keyboard/images/penci.png", IDR_KEYBOARD_IMAGES_PENCIL},
- {"keyboard/images/recent.png", IDR_KEYBOARD_IMAGES_RECENT},
- {"keyboard/images/regular_size.png", IDR_KEYBOARD_IMAGES_FULLSIZE},
- {"keyboard/images/menu.png", IDR_KEYBOARD_IMAGES_MENU},
- {"keyboard/images/pencil.png", IDR_KEYBOARD_IMAGES_PENCIL},
- {"keyboard/images/right.png", IDR_KEYBOARD_IMAGES_RIGHT},
- {"keyboard/images/search.png", IDR_KEYBOARD_IMAGES_SEARCH},
- {"keyboard/images/select_right.png", IDR_KEYBOARD_IMAGES_SELECT_RIGHT},
- {"keyboard/images/select_left.png", IDR_KEYBOARD_IMAGES_SELECT_LEFT},
- {"keyboard/images/setting.png", IDR_KEYBOARD_IMAGES_SETTINGS},
- {"keyboard/images/shift.png", IDR_KEYBOARD_IMAGES_SHIFT},
- {"keyboard/images/space.png", IDR_KEYBOARD_IMAGES_SPACE},
- {"keyboard/images/tab.png", IDR_KEYBOARD_IMAGES_TAB},
- {"keyboard/images/tab_in_fullsize.png",
- IDR_KEYBOARD_IMAGES_TAB_IN_FULLSIZE},
- {"keyboard/images/triangle.png", IDR_KEYBOARD_IMAGES_TRIANGLE},
- {"keyboard/images/up.png", IDR_KEYBOARD_IMAGES_UP},
- {"keyboard/index.html", IDR_KEYBOARD_INDEX},
- {"keyboard/inputview_adapter.js", IDR_KEYBOARD_INPUTVIEW_ADAPTER},
- {"keyboard/inputview.css", IDR_KEYBOARD_INPUTVIEW_CSS},
- {"keyboard/inputview.js", IDR_KEYBOARD_INPUTVIEW_JS},
- {"keyboard/inputview_layouts/101kbd.js", IDR_KEYBOARD_LAYOUTS_101},
- {"keyboard/inputview_layouts/compactkbd-qwerty.js",
- IDR_KEYBOARD_LAYOUTS_COMPACT_QWERTY},
- {"keyboard/inputview_layouts/compactkbd-numberpad.js",
- IDR_KEYBOARD_LAYOUTS_COMPACT_NUMBERPAD},
- {"keyboard/inputview_layouts/emoji.js", IDR_KEYBOARD_LAYOUTS_EMOJI},
- {"keyboard/inputview_layouts/handwriting.js", IDR_KEYBOARD_LAYOUTS_HWT},
- {"keyboard/manifest.json", IDR_KEYBOARD_MANIFEST},
- {"keyboard/sounds/keypress-delete.wav",
- IDR_KEYBOARD_SOUNDS_KEYPRESS_DELETE},
- {"keyboard/sounds/keypress-return.wav",
- IDR_KEYBOARD_SOUNDS_KEYPRESS_RETURN},
- {"keyboard/sounds/keypress-spacebar.wav",
- IDR_KEYBOARD_SOUNDS_KEYPRESS_SPACEBAR},
- {"keyboard/sounds/keypress-standard.wav",
- IDR_KEYBOARD_SOUNDS_KEYPRESS_STANDARD},
- };
- static const size_t kKeyboardResourcesSize = arraysize(kKeyboardResources);
- *size = kKeyboardResourcesSize;
- return kKeyboardResources;
-}
-
-void SetOverrideContentUrl(const GURL& url) {
- g_override_content_url.Get() = url;
-}
-
-const GURL& GetOverrideContentUrl() {
- return g_override_content_url.Get();
-}
-
void LogKeyboardControlEvent(KeyboardControlEvent event) {
UMA_HISTOGRAM_ENUMERATION(
"VirtualKeyboard.KeyboardControlEvent",
diff --git a/ui/keyboard/keyboard_util.h b/ui/keyboard/keyboard_util.h
index 55621b5..2eefc9b 100644
--- a/ui/keyboard/keyboard_util.h
+++ b/ui/keyboard/keyboard_util.h
@@ -7,13 +7,10 @@
#include <string>
-#include "base/strings/string16.h"
// TODO(beng): replace with forward decl once RootWindow is renamed.
#include "ui/aura/window.h"
#include "ui/keyboard/keyboard_export.h"
-struct GritResourceMap;
-
namespace aura {
class WindowTreeHost;
}
@@ -162,11 +159,6 @@ KEYBOARD_EXPORT void MarkKeyboardLoadStarted();
// keyboard is loaded.
KEYBOARD_EXPORT void MarkKeyboardLoadFinished();
-// Get the list of keyboard resources. |size| is populated with the number of
-// resources in the returned array.
-KEYBOARD_EXPORT const GritResourceMap* GetKeyboardExtensionResources(
- size_t* size);
-
// Sets the override content url.
// This is used by for input view for extension IMEs.
KEYBOARD_EXPORT void SetOverrideContentUrl(const GURL& url);