summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp7
-rw-r--r--ash/display/display_controller.h5
-rw-r--r--ash/display/virtual_keyboard_window_controller.cc8
-rw-r--r--ash/display/virtual_keyboard_window_controller.h16
-rw-r--r--ash/display/virtual_keyboard_window_controller_unittest.cc64
-rw-r--r--ash/root_window_controller.cc27
-rw-r--r--ash/root_window_controller_unittest.cc4
-rw-r--r--ash/shell.cc31
-rw-r--r--ash/shell.h11
-rw-r--r--ash/shell/keyboard_controller_proxy_stub.cc (renamed from ash/keyboard_controller_proxy_stub.cc)9
-rw-r--r--ash/shell/keyboard_controller_proxy_stub.h (renamed from ash/keyboard_controller_proxy_stub.h)18
-rw-r--r--ash/shell/shell_delegate_impl.cc2
-rw-r--r--ash/test/test_shell_delegate.cc2
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc2
-rw-r--r--chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc9
-rw-r--r--ui/keyboard/keyboard_controller.cc9
-rw-r--r--ui/keyboard/keyboard_controller_unittest.cc2
-rw-r--r--ui/keyboard/keyboard_switches.cc2
-rw-r--r--ui/keyboard/keyboard_switches.h5
-rw-r--r--ui/keyboard/keyboard_util.cc7
-rw-r--r--ui/keyboard/keyboard_util.h3
21 files changed, 195 insertions, 48 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 7f8ea56..0c2d99a 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -148,8 +148,6 @@
'host/root_window_host_factory.cc',
'host/root_window_host_factory.h',
'host/root_window_host_factory_win.cc',
- 'keyboard_controller_proxy_stub.cc',
- 'keyboard_controller_proxy_stub.h',
'keyboard_overlay/keyboard_overlay_delegate.cc',
'keyboard_overlay/keyboard_overlay_delegate.h',
'keyboard_overlay/keyboard_overlay_view.cc',
@@ -639,6 +637,8 @@
'sources': [
'shell/toplevel_window.cc',
'shell/toplevel_window.h',
+ 'shell/keyboard_controller_proxy_stub.cc',
+ 'shell/keyboard_controller_proxy_stub.h',
'test/app_list_controller_test_api.cc',
'test/app_list_controller_test_api.h',
'test/ash_test_base.cc',
@@ -754,6 +754,7 @@
'display/display_info_unittest.cc',
'display/display_manager_unittest.cc',
'display/mirror_window_controller_unittest.cc',
+ 'display/virtual_keyboard_window_controller_unittest.cc',
'display/mouse_cursor_event_filter_unittest.cc',
'display/resolution_notification_controller_unittest.cc',
'display/root_window_transformers_unittest.cc',
@@ -949,6 +950,8 @@
'shell/context_menu.cc',
'shell/context_menu.h',
'shell/example_factory.h',
+ 'shell/keyboard_controller_proxy_stub.cc',
+ 'shell/keyboard_controller_proxy_stub.h',
'shell/launcher_delegate_impl.cc',
'shell/launcher_delegate_impl.h',
'shell/lock_view.cc',
diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h
index 9dc20f5..75fe22c 100644
--- a/ash/display/display_controller.h
+++ b/ash/display/display_controller.h
@@ -84,6 +84,11 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver,
return mirror_window_controller_.get();
}
+ internal::VirtualKeyboardWindowController*
+ virtual_keyboard_window_controller() {
+ return virtual_keyboard_window_controller_.get();
+ }
+
// Initializes primary display.
void InitPrimaryDisplay();
diff --git a/ash/display/virtual_keyboard_window_controller.cc b/ash/display/virtual_keyboard_window_controller.cc
index 42f2531..7be0e47 100644
--- a/ash/display/virtual_keyboard_window_controller.cc
+++ b/ash/display/virtual_keyboard_window_controller.cc
@@ -16,6 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
+#include "ui/keyboard/keyboard_controller.h"
namespace ash {
namespace internal {
@@ -28,6 +29,11 @@ VirtualKeyboardWindowController::~VirtualKeyboardWindowController() {
Close();
}
+void VirtualKeyboardWindowController::ActivateKeyboard(
+ keyboard::KeyboardController* keyboard_controller) {
+ root_window_controller_->ActivateKeyboard(keyboard_controller);
+}
+
void VirtualKeyboardWindowController::UpdateWindow(
const DisplayInfo& display_info) {
static int virtual_keyboard_root_window_count = 0;
@@ -53,6 +59,8 @@ void VirtualKeyboardWindowController::UpdateWindow(
root_window_controller_.reset(GetRootWindowController(
root_window->window()));
root_window_controller_->dispatcher()->host()->Show();
+ root_window_controller_->ActivateKeyboard(
+ Shell::GetInstance()->keyboard_controller());
} else {
aura::RootWindow* root_window = root_window_controller_->dispatcher();
GetRootWindowSettings(root_window->window())->display_id =
diff --git a/ash/display/virtual_keyboard_window_controller.h b/ash/display/virtual_keyboard_window_controller.h
index def3c06..88db57d 100644
--- a/ash/display/virtual_keyboard_window_controller.h
+++ b/ash/display/virtual_keyboard_window_controller.h
@@ -9,8 +9,16 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+namespace keyboard {
+class KeyboardController;
+}
+
namespace ash {
+namespace test {
+class VirtualKeyboardWindowControllerTest;
+} // namespace test
+
namespace internal {
class DisplayInfo;
class RootWindowController;
@@ -22,6 +30,8 @@ class ASH_EXPORT VirtualKeyboardWindowController {
VirtualKeyboardWindowController();
virtual ~VirtualKeyboardWindowController();
+ void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
+
// Updates the root window's bounds using |display_info|.
// Creates the new root window if one doesn't exist.
void UpdateWindow(const DisplayInfo& display_info);
@@ -30,6 +40,12 @@ class ASH_EXPORT VirtualKeyboardWindowController {
void Close();
private:
+ friend class test::VirtualKeyboardWindowControllerTest;
+
+ RootWindowController* root_window_controller_for_test() {
+ return root_window_controller_.get();
+ }
+
scoped_ptr<RootWindowController> root_window_controller_;
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowController);
diff --git a/ash/display/virtual_keyboard_window_controller_unittest.cc b/ash/display/virtual_keyboard_window_controller_unittest.cc
new file mode 100644
index 0000000..b03f335
--- /dev/null
+++ b/ash/display/virtual_keyboard_window_controller_unittest.cc
@@ -0,0 +1,64 @@
+// 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/display/virtual_keyboard_window_controller.h"
+
+#include "ash/ash_switches.h"
+#include "ash/display/display_controller.h"
+#include "ash/root_window_controller.h"
+#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
+#include "ash/test/ash_test_base.h"
+#include "base/command_line.h"
+#include "ui/keyboard/keyboard_switches.h"
+
+namespace ash {
+namespace test {
+
+class VirtualKeyboardWindowControllerTest : public AshTestBase {
+ public:
+ VirtualKeyboardWindowControllerTest()
+ : virtual_keyboard_window_controller_(NULL) {}
+ virtual ~VirtualKeyboardWindowControllerTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kAshHostWindowBounds, "1+1-300x300,1+301-300x300");
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ keyboard::switches::kKeyboardUsabilityExperiment);
+ test::AshTestBase::SetUp();
+ }
+
+ void set_virtual_keyboard_window_controller(
+ internal::VirtualKeyboardWindowController* controller) {
+ virtual_keyboard_window_controller_ = controller;
+ }
+
+ internal::RootWindowController* root_window_controller() {
+ return virtual_keyboard_window_controller_->
+ root_window_controller_for_test();
+ }
+
+ private:
+ internal::VirtualKeyboardWindowController*
+ virtual_keyboard_window_controller_;
+ DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowControllerTest);
+};
+
+
+TEST_F(VirtualKeyboardWindowControllerTest, VirtualKeyboardWindowTest) {
+ if (!SupportsMultipleDisplays())
+ return;
+ RunAllPendingInMessageLoop();
+ set_virtual_keyboard_window_controller(
+ Shell::GetInstance()->display_controller()->
+ virtual_keyboard_window_controller());
+ EXPECT_TRUE(root_window_controller());
+ // Keyboard container is added to virtual keyboard window.
+ EXPECT_TRUE(root_window_controller()->GetContainer(
+ internal::kShellWindowId_VirtualKeyboardContainer));
+}
+
+} // namespace test
+} // namespace ash
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index ffa91d0..45c0f7a 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -542,9 +542,11 @@ void RootWindowController::ActivateKeyboard(
return;
}
DCHECK(keyboard_controller);
- keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
- keyboard_controller->AddObserver(panel_layout_manager_);
- keyboard_controller->AddObserver(docked_layout_manager_);
+ if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
+ keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
+ keyboard_controller->AddObserver(panel_layout_manager_);
+ keyboard_controller->AddObserver(docked_layout_manager_);
+ }
aura::Window* parent = root_window();
aura::Window* keyboard_container =
keyboard_controller->GetContainerWindow();
@@ -565,9 +567,11 @@ void RootWindowController::DeactivateKeyboard(
keyboard_controller->GetContainerWindow();
if (keyboard_container->GetRootWindow() == root_window()) {
root_window()->RemoveChild(keyboard_container);
- keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
- keyboard_controller->RemoveObserver(panel_layout_manager_);
- keyboard_controller->RemoveObserver(docked_layout_manager_);
+ if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
+ keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
+ keyboard_controller->RemoveObserver(panel_layout_manager_);
+ keyboard_controller->RemoveObserver(docked_layout_manager_);
+ }
}
}
@@ -593,13 +597,16 @@ RootWindowController::RootWindowController(aura::RootWindow* root_window)
void RootWindowController::Init(RootWindowType root_window_type,
bool first_run_after_boot) {
- Shell::GetInstance()->InitRootWindow(root_window());
+ Shell* shell = Shell::GetInstance();
+ shell->InitRootWindow(root_window());
root_window_->SetCursor(ui::kCursorPointer);
CreateContainersInRootWindow(root_window_->window());
- if (root_window_type == VIRTUAL_KEYBOARD)
+ if (root_window_type == VIRTUAL_KEYBOARD) {
+ shell->InitKeyboard();
return;
+ }
CreateSystemBackground(first_run_after_boot);
@@ -611,12 +618,12 @@ void RootWindowController::Init(RootWindowType root_window_type,
GetSystemModalLayoutManager(NULL)->CreateModalBackground();
}
- Shell* shell = Shell::GetInstance();
shell->AddShellObserver(this);
if (root_window_type == PRIMARY) {
root_window_layout()->OnWindowResized();
- shell->InitKeyboard(this);
+ if (!keyboard::IsKeyboardUsabilityExperimentEnabled())
+ shell->InitKeyboard();
} else {
root_window_layout()->OnWindowResized();
shell->desktop_background_controller()->OnRootWindowAdded(root_window());
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc
index 78c96d9..d547a8a 100644
--- a/ash/root_window_controller_unittest.cc
+++ b/ash/root_window_controller_unittest.cc
@@ -696,8 +696,8 @@ TEST_F(VirtualKeyboardRootWindowControllerTest,
// Track the keyboard container window.
aura::WindowTracker tracker;
tracker.Add(keyboard_container);
- // Mock a login state change to reinitialize the keyboard.
- ash::Shell::GetInstance()->OnLoginStateChanged(user::LOGGED_IN_OWNER);
+ // Mock a login user profile change to reinitialize the keyboard.
+ ash::Shell::GetInstance()->OnLoginUserProfilePrepared();
// keyboard_container should no longer be present.
EXPECT_FALSE(tracker.Contains(keyboard_container));
}
diff --git a/ash/shell.cc b/ash/shell.cc
index 45c4648..8a2f524 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -23,6 +23,7 @@
#include "ash/display/mouse_cursor_event_filter.h"
#include "ash/display/resolution_notification_controller.h"
#include "ash/display/screen_position_controller.h"
+#include "ash/display/virtual_keyboard_window_controller.h"
#include "ash/drag_drop/drag_drop_controller.h"
#include "ash/first_run/first_run_helper_impl.h"
#include "ash/focus_cycler.h"
@@ -337,16 +338,14 @@ void Shell::SetDisplayWorkAreaInsets(Window* contains,
}
void Shell::OnLoginStateChanged(user::LoginStatus status) {
- if (status != user::LOGGED_IN_NONE) {
- // TODO(bshe): Primary root window controller may not be the controller to
- // attach virtual keyboard. See http://crbug.com/303429
- InitKeyboard(GetPrimaryRootWindowController());
- GetPrimaryRootWindowController()->ActivateKeyboard(
- keyboard_controller_.get());
- }
FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status));
}
+void Shell::OnLoginUserProfilePrepared() {
+ CreateLauncher();
+ CreateKeyboard();
+}
+
void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) {
RootWindowControllerList controllers = GetAllRootWindowControllers();
for (RootWindowControllerList::iterator iter = controllers.begin();
@@ -381,6 +380,19 @@ void Shell::CreateLauncher() {
(*iter)->shelf()->CreateLauncher();
}
+void Shell::CreateKeyboard() {
+ // TODO(bshe): Primary root window controller may not be the controller to
+ // attach virtual keyboard. See http://crbug.com/303429
+ InitKeyboard();
+ if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
+ display_controller()->virtual_keyboard_window_controller()->
+ ActivateKeyboard(keyboard_controller_.get());
+ } else {
+ GetPrimaryRootWindowController()->
+ ActivateKeyboard(keyboard_controller_.get());
+ }
+}
+
void Shell::ShowLauncher() {
RootWindowControllerList controllers = GetAllRootWindowControllers();
for (RootWindowControllerList::iterator iter = controllers.begin();
@@ -619,6 +631,7 @@ Shell::~Shell() {
// Destroy all child windows including widgets.
display_controller_->CloseChildWindows();
+ display_controller_->CloseNonDesktopDisplay();
// Destroy SystemTrayNotifier after destroying SystemTray as TrayItems
// needs to remove observers from it.
@@ -693,7 +706,7 @@ void Shell::Init() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
delegate_->PreInit();
- if (command_line->HasSwitch(keyboard::switches::kKeyboardUsabilityTest)) {
+ if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
display_manager_->SetSecondDisplayMode(
internal::DisplayManager::VIRTUAL_KEYBOARD);
}
@@ -916,7 +929,7 @@ void Shell::Init() {
weak_display_manager_factory_->GetWeakPtr()));
}
-void Shell::InitKeyboard(internal::RootWindowController* root) {
+void Shell::InitKeyboard() {
if (keyboard::IsKeyboardEnabled()) {
if (keyboard_controller_.get()) {
RootWindowControllerList controllers = GetAllRootWindowControllers();
diff --git a/ash/shell.h b/ash/shell.h
index 6bab5b1..410be21 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -269,6 +269,9 @@ class ASH_EXPORT Shell
// Called when the user logs in.
void OnLoginStateChanged(user::LoginStatus status);
+ // Called after the logged-in user's profile is ready.
+ void OnLoginUserProfilePrepared();
+
// Called when the login status changes.
// TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
void UpdateAfterLoginStatusChange(user::LoginStatus status);
@@ -283,6 +286,10 @@ class ASH_EXPORT Shell
// Initializes |launcher_|. Does nothing if it's already initialized.
void CreateLauncher();
+ // Creates virtual keyboard. Deletes the old virtual keyboard if it's already
+ // exist.
+ void CreateKeyboard();
+
// Show shelf view if it was created hidden (before session has started).
void ShowLauncher();
@@ -539,8 +546,8 @@ class ASH_EXPORT Shell
void Init();
- // Initializes virtual keyboard controller and attaches it to |root|.
- void InitKeyboard(internal::RootWindowController* root);
+ // Initializes virtual keyboard controller.
+ void InitKeyboard();
// Initializes the root window so that it can host browser windows.
void InitRootWindow(aura::Window* root_window);
diff --git a/ash/keyboard_controller_proxy_stub.cc b/ash/shell/keyboard_controller_proxy_stub.cc
index 6db733c..700c834 100644
--- a/ash/keyboard_controller_proxy_stub.cc
+++ b/ash/shell/keyboard_controller_proxy_stub.cc
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/keyboard_controller_proxy_stub.h"
+#include "ash/shell/keyboard_controller_proxy_stub.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
+#include "ui/aura/window.h"
#include "ui/views/corewm/input_method_event_filter.h"
using namespace content;
@@ -18,6 +19,12 @@ KeyboardControllerProxyStub::KeyboardControllerProxyStub() {
KeyboardControllerProxyStub::~KeyboardControllerProxyStub() {
}
+aura::Window* KeyboardControllerProxyStub::GetKeyboardWindow() {
+ aura::Window* window = new aura::Window(&delegate_);
+ window->Init(ui::LAYER_NOT_DRAWN);
+ return window;
+}
+
BrowserContext* KeyboardControllerProxyStub::GetBrowserContext() {
return Shell::GetInstance()->delegate()->GetCurrentBrowserContext();
}
diff --git a/ash/keyboard_controller_proxy_stub.h b/ash/shell/keyboard_controller_proxy_stub.h
index 25310d7..639e5d2 100644
--- a/ash/keyboard_controller_proxy_stub.h
+++ b/ash/shell/keyboard_controller_proxy_stub.h
@@ -2,21 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_
-#define ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_
+#ifndef ASH_SHELL_KEYBOARD_CONTROLLER_PROXY_STUB_H_
+#define ASH_SHELL_KEYBOARD_CONTROLLER_PROXY_STUB_H_
-#include "ash/ash_export.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 ASH_EXPORT KeyboardControllerProxyStub
- : public keyboard::KeyboardControllerProxy {
+class KeyboardControllerProxyStub : public keyboard::KeyboardControllerProxy {
public:
KeyboardControllerProxyStub();
virtual ~KeyboardControllerProxyStub();
+ virtual aura::Window* GetKeyboardWindow() OVERRIDE;
+
private:
// Overridden from keyboard::KeyboardControllerProxy:
virtual content::BrowserContext* GetBrowserContext() OVERRIDE;
@@ -25,9 +30,10 @@ class ASH_EXPORT KeyboardControllerProxyStub
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) OVERRIDE;
+ aura::test::TestWindowDelegate delegate_;
DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxyStub);
};
} // namespace ash
-#endif // ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_
+#endif // ASH_SHELL_KEYBOARD_CONTROLLER_PROXY_STUB_H_
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 44d955f..acc8e3d 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -9,13 +9,13 @@
#include "ash/default_accessibility_delegate.h"
#include "ash/default_user_wallpaper_delegate.h"
#include "ash/host/root_window_host_factory.h"
-#include "ash/keyboard_controller_proxy_stub.h"
#include "ash/media_delegate.h"
#include "ash/new_window_delegate.h"
#include "ash/session_state_delegate.h"
#include "ash/session_state_delegate_stub.h"
#include "ash/shell/context_menu.h"
#include "ash/shell/example_factory.h"
+#include "ash/shell/keyboard_controller_proxy_stub.h"
#include "ash/shell/launcher_delegate_impl.h"
#include "ash/shell/toplevel_window.h"
#include "ash/shell_window_ids.h"
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 8a4970c..0432c42 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -9,11 +9,11 @@
#include "ash/caps_lock_delegate_stub.h"
#include "ash/default_accessibility_delegate.h"
#include "ash/host/root_window_host_factory.h"
-#include "ash/keyboard_controller_proxy_stub.h"
#include "ash/media_delegate.h"
#include "ash/new_window_delegate.h"
#include "ash/session_state_delegate.h"
#include "ash/shell.h"
+#include "ash/shell/keyboard_controller_proxy_stub.h"
#include "ash/shell_window_ids.h"
#include "ash/test/test_launcher_delegate.h"
#include "ash/test/test_session_state_delegate.h"
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
index d370383..ed86767 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
@@ -225,7 +225,7 @@ void ChromeShellDelegate::Observe(int type,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED:
- ash::Shell::GetInstance()->CreateLauncher();
+ ash::Shell::GetInstance()->OnLoginUserProfilePrepared();
break;
case chrome::NOTIFICATION_SESSION_STARTED:
RestoreFocus();
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 d021e0c..186c5ed 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
@@ -95,9 +95,12 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() {
// Initialize TabScrubber after the Ash Shell has been initialized.
TabScrubber::GetInstance();
// Activate virtual keyboard after profile is initialized. It depends on the
- // default profile.
- ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard(
- ash::Shell::GetInstance()->keyboard_controller());
+ // default profile. If keyboard usability experiment flag is set, defer the
+ // activation to UpdateWindow() in virtual_keyboard_window_controller.cc.
+ if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
+ ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard(
+ ash::Shell::GetInstance()->keyboard_controller());
+ }
}
void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc
index 00a3b1b..537cf12 100644
--- a/ui/keyboard/keyboard_controller.cc
+++ b/ui/keyboard/keyboard_controller.cc
@@ -27,7 +27,8 @@ namespace {
const int kHideKeyboardDelayMs = 100;
gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds) {
- const float kKeyboardHeightRatio = 0.3f;
+ const float kKeyboardHeightRatio =
+ keyboard::IsKeyboardUsabilityExperimentEnabled() ? 1.0f : 0.3f;
return gfx::Rect(
window_bounds.x(),
window_bounds.y() + window_bounds.height() * (1 - kKeyboardHeightRatio),
@@ -191,8 +192,7 @@ void KeyboardController::OnTextInputStateChanged(
ui::TextInputType type =
client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
if (type == ui::TEXT_INPUT_TYPE_NONE &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kKeyboardUsabilityTest)) {
+ !IsKeyboardUsabilityExperimentEnabled()) {
should_show = false;
} else {
if (container_->children().empty()) {
@@ -202,7 +202,8 @@ void KeyboardController::OnTextInputStateChanged(
container_->AddChild(keyboard);
container_->layout_manager()->OnWindowResized();
}
- proxy_->SetUpdateInputType(type);
+ if (type != ui::TEXT_INPUT_TYPE_NONE)
+ proxy_->SetUpdateInputType(type);
container_->parent()->StackChildAtTop(container_.get());
should_show = true;
}
diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc
index 81de83f..89cac7c 100644
--- a/ui/keyboard/keyboard_controller_unittest.cc
+++ b/ui/keyboard/keyboard_controller_unittest.cc
@@ -338,7 +338,7 @@ class KeyboardControllerUsabilityTest : public KeyboardControllerTest {
virtual void SetUp() OVERRIDE {
CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kKeyboardUsabilityTest);
+ switches::kKeyboardUsabilityExperiment);
KeyboardControllerTest::SetUp();
}
diff --git a/ui/keyboard/keyboard_switches.cc b/ui/keyboard/keyboard_switches.cc
index 9776abff..aeecf37 100644
--- a/ui/keyboard/keyboard_switches.cc
+++ b/ui/keyboard/keyboard_switches.cc
@@ -10,7 +10,7 @@ namespace switches {
const char kEnableSwipeSelection[] = "enable-swipe-selection";
const char kEnableVirtualKeyboard[] = "enable-virtual-keyboard";
-const char kKeyboardUsabilityTest[] = "keyboard-usability-test";
+const char kKeyboardUsabilityExperiment[] = "keyboard-usability-experiment";
} // namespace switches
} // namespace keyboard
diff --git a/ui/keyboard/keyboard_switches.h b/ui/keyboard/keyboard_switches.h
index b6fae62..04d4e73 100644
--- a/ui/keyboard/keyboard_switches.h
+++ b/ui/keyboard/keyboard_switches.h
@@ -16,8 +16,9 @@ KEYBOARD_EXPORT extern const char kEnableSwipeSelection[];
// Enables the virtual keyboard.
KEYBOARD_EXPORT extern const char kEnableVirtualKeyboard[];
-// Enables the keyboard usability test.
-KEYBOARD_EXPORT extern const char kKeyboardUsabilityTest[];
+// Enables the keyboard usability experiment. This is an experimental mode for
+// testing the usability of various experimental keyboard layouts.
+KEYBOARD_EXPORT extern const char kKeyboardUsabilityExperiment[];
} // namespace switches
} // namespace keyboard
diff --git a/ui/keyboard/keyboard_util.cc b/ui/keyboard/keyboard_util.cc
index 96d8385..670a758 100644
--- a/ui/keyboard/keyboard_util.cc
+++ b/ui/keyboard/keyboard_util.cc
@@ -42,9 +42,12 @@ namespace keyboard {
bool IsKeyboardEnabled() {
return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableVirtualKeyboard) ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kKeyboardUsabilityTest);
+ IsKeyboardUsabilityExperimentEnabled();
+}
+bool IsKeyboardUsabilityExperimentEnabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kKeyboardUsabilityExperiment);
}
bool InsertText(const base::string16& text, aura::Window* root_window) {
diff --git a/ui/keyboard/keyboard_util.h b/ui/keyboard/keyboard_util.h
index 8769825..b5dcefd 100644
--- a/ui/keyboard/keyboard_util.h
+++ b/ui/keyboard/keyboard_util.h
@@ -35,6 +35,9 @@ enum KeyboardControlEvent {
// Returns true if the virtual keyboard is enabled.
KEYBOARD_EXPORT bool IsKeyboardEnabled();
+// Returns true if the keyboard usability test is enabled.
+KEYBOARD_EXPORT bool IsKeyboardUsabilityExperimentEnabled();
+
// Insert |text| into the active TextInputClient associated with |root_window|,
// if there is one. Returns true if |text| was successfully inserted. Note
// that this may convert |text| into ui::KeyEvents for injection in some