Commit 51f43811 authored by bshe@chromium.org's avatar bshe@chromium.org

Add a full screen virtual keyboard to virtual keyboard root window

This relands https://codereview.chromium.org/47873003. It was reverted
because of VirtualKeyboardWindowControllerTest.VirtualKeyboardWindowTest
test crash on win8_aura.

R=oshima@chromium.org
TBR=jamescook, sadrul
BUG=310331
TEST=
1. add keyboard-usability-experiment flag
2. hook up an external screen
3. boot device
expected: a full screen keyboard on one of the screen

Review URL: https://codereview.chromium.org/62833010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235795 0039d316-1c4b-4281-b951-d872f2087c98
parent 301a0be6
...@@ -148,8 +148,6 @@ ...@@ -148,8 +148,6 @@
'host/root_window_host_factory.cc', 'host/root_window_host_factory.cc',
'host/root_window_host_factory.h', 'host/root_window_host_factory.h',
'host/root_window_host_factory_win.cc', '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.cc',
'keyboard_overlay/keyboard_overlay_delegate.h', 'keyboard_overlay/keyboard_overlay_delegate.h',
'keyboard_overlay/keyboard_overlay_view.cc', 'keyboard_overlay/keyboard_overlay_view.cc',
...@@ -637,6 +635,8 @@ ...@@ -637,6 +635,8 @@
'sources': [ 'sources': [
'shell/toplevel_window.cc', 'shell/toplevel_window.cc',
'shell/toplevel_window.h', '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.cc',
'test/app_list_controller_test_api.h', 'test/app_list_controller_test_api.h',
'test/ash_test_base.cc', 'test/ash_test_base.cc',
...@@ -752,6 +752,7 @@ ...@@ -752,6 +752,7 @@
'display/display_info_unittest.cc', 'display/display_info_unittest.cc',
'display/display_manager_unittest.cc', 'display/display_manager_unittest.cc',
'display/mirror_window_controller_unittest.cc', 'display/mirror_window_controller_unittest.cc',
'display/virtual_keyboard_window_controller_unittest.cc',
'display/mouse_cursor_event_filter_unittest.cc', 'display/mouse_cursor_event_filter_unittest.cc',
'display/resolution_notification_controller_unittest.cc', 'display/resolution_notification_controller_unittest.cc',
'display/root_window_transformers_unittest.cc', 'display/root_window_transformers_unittest.cc',
...@@ -947,6 +948,8 @@ ...@@ -947,6 +948,8 @@
'shell/context_menu.cc', 'shell/context_menu.cc',
'shell/context_menu.h', 'shell/context_menu.h',
'shell/example_factory.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.cc',
'shell/launcher_delegate_impl.h', 'shell/launcher_delegate_impl.h',
'shell/lock_view.cc', 'shell/lock_view.cc',
......
...@@ -84,6 +84,11 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, ...@@ -84,6 +84,11 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver,
return mirror_window_controller_.get(); return mirror_window_controller_.get();
} }
internal::VirtualKeyboardWindowController*
virtual_keyboard_window_controller() {
return virtual_keyboard_window_controller_.get();
}
// Initializes primary display. // Initializes primary display.
void InitPrimaryDisplay(); void InitPrimaryDisplay();
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/root_window.h" #include "ui/aura/root_window.h"
#include "ui/keyboard/keyboard_controller.h"
namespace ash { namespace ash {
namespace internal { namespace internal {
...@@ -28,6 +29,11 @@ VirtualKeyboardWindowController::~VirtualKeyboardWindowController() { ...@@ -28,6 +29,11 @@ VirtualKeyboardWindowController::~VirtualKeyboardWindowController() {
Close(); Close();
} }
void VirtualKeyboardWindowController::ActivateKeyboard(
keyboard::KeyboardController* keyboard_controller) {
root_window_controller_->ActivateKeyboard(keyboard_controller);
}
void VirtualKeyboardWindowController::UpdateWindow( void VirtualKeyboardWindowController::UpdateWindow(
const DisplayInfo& display_info) { const DisplayInfo& display_info) {
static int virtual_keyboard_root_window_count = 0; static int virtual_keyboard_root_window_count = 0;
...@@ -53,6 +59,8 @@ void VirtualKeyboardWindowController::UpdateWindow( ...@@ -53,6 +59,8 @@ void VirtualKeyboardWindowController::UpdateWindow(
root_window_controller_.reset(GetRootWindowController( root_window_controller_.reset(GetRootWindowController(
root_window->window())); root_window->window()));
root_window_controller_->dispatcher()->host()->Show(); root_window_controller_->dispatcher()->host()->Show();
root_window_controller_->ActivateKeyboard(
Shell::GetInstance()->keyboard_controller());
} else { } else {
aura::RootWindow* root_window = root_window_controller_->dispatcher(); aura::RootWindow* root_window = root_window_controller_->dispatcher();
GetRootWindowSettings(root_window->window())->display_id = GetRootWindowSettings(root_window->window())->display_id =
......
...@@ -9,8 +9,16 @@ ...@@ -9,8 +9,16 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
namespace keyboard {
class KeyboardController;
}
namespace ash { namespace ash {
namespace test {
class VirtualKeyboardWindowControllerTest;
} // namespace test
namespace internal { namespace internal {
class DisplayInfo; class DisplayInfo;
class RootWindowController; class RootWindowController;
...@@ -22,6 +30,8 @@ class ASH_EXPORT VirtualKeyboardWindowController { ...@@ -22,6 +30,8 @@ class ASH_EXPORT VirtualKeyboardWindowController {
VirtualKeyboardWindowController(); VirtualKeyboardWindowController();
virtual ~VirtualKeyboardWindowController(); virtual ~VirtualKeyboardWindowController();
void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
// Updates the root window's bounds using |display_info|. // Updates the root window's bounds using |display_info|.
// Creates the new root window if one doesn't exist. // Creates the new root window if one doesn't exist.
void UpdateWindow(const DisplayInfo& display_info); void UpdateWindow(const DisplayInfo& display_info);
...@@ -30,6 +40,12 @@ class ASH_EXPORT VirtualKeyboardWindowController { ...@@ -30,6 +40,12 @@ class ASH_EXPORT VirtualKeyboardWindowController {
void Close(); void Close();
private: private:
friend class test::VirtualKeyboardWindowControllerTest;
RootWindowController* root_window_controller_for_test() {
return root_window_controller_.get();
}
scoped_ptr<RootWindowController> root_window_controller_; scoped_ptr<RootWindowController> root_window_controller_;
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowController); DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowController);
......
// 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 {
if (SupportsMultipleDisplays()) {
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
...@@ -542,9 +542,11 @@ void RootWindowController::ActivateKeyboard( ...@@ -542,9 +542,11 @@ void RootWindowController::ActivateKeyboard(
return; return;
} }
DCHECK(keyboard_controller); DCHECK(keyboard_controller);
keyboard_controller->AddObserver(shelf()->shelf_layout_manager()); if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
keyboard_controller->AddObserver(panel_layout_manager_); keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
keyboard_controller->AddObserver(docked_layout_manager_); keyboard_controller->AddObserver(panel_layout_manager_);
keyboard_controller->AddObserver(docked_layout_manager_);
}
aura::Window* parent = root_window(); aura::Window* parent = root_window();
aura::Window* keyboard_container = aura::Window* keyboard_container =
keyboard_controller->GetContainerWindow(); keyboard_controller->GetContainerWindow();
...@@ -565,9 +567,11 @@ void RootWindowController::DeactivateKeyboard( ...@@ -565,9 +567,11 @@ void RootWindowController::DeactivateKeyboard(
keyboard_controller->GetContainerWindow(); keyboard_controller->GetContainerWindow();
if (keyboard_container->GetRootWindow() == root_window()) { if (keyboard_container->GetRootWindow() == root_window()) {
root_window()->RemoveChild(keyboard_container); root_window()->RemoveChild(keyboard_container);
keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
keyboard_controller->RemoveObserver(panel_layout_manager_); keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
keyboard_controller->RemoveObserver(docked_layout_manager_); keyboard_controller->RemoveObserver(panel_layout_manager_);
keyboard_controller->RemoveObserver(docked_layout_manager_);
}
} }
} }
...@@ -593,13 +597,16 @@ RootWindowController::RootWindowController(aura::RootWindow* root_window) ...@@ -593,13 +597,16 @@ RootWindowController::RootWindowController(aura::RootWindow* root_window)
void RootWindowController::Init(RootWindowType root_window_type, void RootWindowController::Init(RootWindowType root_window_type,
bool first_run_after_boot) { bool first_run_after_boot) {
Shell::GetInstance()->InitRootWindow(root_window()); Shell* shell = Shell::GetInstance();
shell->InitRootWindow(root_window());
root_window_->SetCursor(ui::kCursorPointer); root_window_->SetCursor(ui::kCursorPointer);
CreateContainersInRootWindow(root_window_->window()); CreateContainersInRootWindow(root_window_->window());
if (root_window_type == VIRTUAL_KEYBOARD) if (root_window_type == VIRTUAL_KEYBOARD) {
shell->InitKeyboard();
return; return;
}
CreateSystemBackground(first_run_after_boot); CreateSystemBackground(first_run_after_boot);
...@@ -611,12 +618,12 @@ void RootWindowController::Init(RootWindowType root_window_type, ...@@ -611,12 +618,12 @@ void RootWindowController::Init(RootWindowType root_window_type,
GetSystemModalLayoutManager(NULL)->CreateModalBackground(); GetSystemModalLayoutManager(NULL)->CreateModalBackground();
} }
Shell* shell = Shell::GetInstance();
shell->AddShellObserver(this); shell->AddShellObserver(this);
if (root_window_type == PRIMARY) { if (root_window_type == PRIMARY) {
root_window_layout()->OnWindowResized(); root_window_layout()->OnWindowResized();
shell->InitKeyboard(this); if (!keyboard::IsKeyboardUsabilityExperimentEnabled())
shell->InitKeyboard();
} else { } else {
root_window_layout()->OnWindowResized(); root_window_layout()->OnWindowResized();
shell->desktop_background_controller()->OnRootWindowAdded(root_window()); shell->desktop_background_controller()->OnRootWindowAdded(root_window());
......
...@@ -696,8 +696,8 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, ...@@ -696,8 +696,8 @@ TEST_F(VirtualKeyboardRootWindowControllerTest,
// Track the keyboard container window. // Track the keyboard container window.
aura::WindowTracker tracker; aura::WindowTracker tracker;
tracker.Add(keyboard_container); tracker.Add(keyboard_container);
// Mock a login state change to reinitialize the keyboard. // Mock a login user profile change to reinitialize the keyboard.
ash::Shell::GetInstance()->OnLoginStateChanged(user::LOGGED_IN_OWNER); ash::Shell::GetInstance()->OnLoginUserProfilePrepared();
// keyboard_container should no longer be present. // keyboard_container should no longer be present.
EXPECT_FALSE(tracker.Contains(keyboard_container)); EXPECT_FALSE(tracker.Contains(keyboard_container));
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "ash/display/mouse_cursor_event_filter.h" #include "ash/display/mouse_cursor_event_filter.h"
#include "ash/display/resolution_notification_controller.h" #include "ash/display/resolution_notification_controller.h"
#include "ash/display/screen_position_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/drag_drop/drag_drop_controller.h"
#include "ash/first_run/first_run_helper_impl.h" #include "ash/first_run/first_run_helper_impl.h"
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
...@@ -336,16 +337,14 @@ void Shell::SetDisplayWorkAreaInsets(Window* contains, ...@@ -336,16 +337,14 @@ void Shell::SetDisplayWorkAreaInsets(Window* contains,
} }
void Shell::OnLoginStateChanged(user::LoginStatus status) { 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)); FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status));
} }
void Shell::OnLoginUserProfilePrepared() {
CreateLauncher();
CreateKeyboard();
}
void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) {
RootWindowControllerList controllers = GetAllRootWindowControllers(); RootWindowControllerList controllers = GetAllRootWindowControllers();
for (RootWindowControllerList::iterator iter = controllers.begin(); for (RootWindowControllerList::iterator iter = controllers.begin();
...@@ -380,6 +379,19 @@ void Shell::CreateLauncher() { ...@@ -380,6 +379,19 @@ void Shell::CreateLauncher() {
(*iter)->shelf()->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() { void Shell::ShowLauncher() {
RootWindowControllerList controllers = GetAllRootWindowControllers(); RootWindowControllerList controllers = GetAllRootWindowControllers();
for (RootWindowControllerList::iterator iter = controllers.begin(); for (RootWindowControllerList::iterator iter = controllers.begin();
...@@ -618,6 +630,7 @@ Shell::~Shell() { ...@@ -618,6 +630,7 @@ Shell::~Shell() {
// Destroy all child windows including widgets. // Destroy all child windows including widgets.
display_controller_->CloseChildWindows(); display_controller_->CloseChildWindows();
display_controller_->CloseNonDesktopDisplay();
// Destroy SystemTrayNotifier after destroying SystemTray as TrayItems // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems
// needs to remove observers from it. // needs to remove observers from it.
...@@ -692,7 +705,7 @@ void Shell::Init() { ...@@ -692,7 +705,7 @@ void Shell::Init() {
CommandLine* command_line = CommandLine::ForCurrentProcess(); CommandLine* command_line = CommandLine::ForCurrentProcess();
delegate_->PreInit(); delegate_->PreInit();
if (command_line->HasSwitch(keyboard::switches::kKeyboardUsabilityTest)) { if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
display_manager_->SetSecondDisplayMode( display_manager_->SetSecondDisplayMode(
internal::DisplayManager::VIRTUAL_KEYBOARD); internal::DisplayManager::VIRTUAL_KEYBOARD);
} }
...@@ -915,7 +928,7 @@ void Shell::Init() { ...@@ -915,7 +928,7 @@ void Shell::Init() {
weak_display_manager_factory_->GetWeakPtr())); weak_display_manager_factory_->GetWeakPtr()));
} }
void Shell::InitKeyboard(internal::RootWindowController* root) { void Shell::InitKeyboard() {
if (keyboard::IsKeyboardEnabled()) { if (keyboard::IsKeyboardEnabled()) {
if (keyboard_controller_.get()) { if (keyboard_controller_.get()) {
RootWindowControllerList controllers = GetAllRootWindowControllers(); RootWindowControllerList controllers = GetAllRootWindowControllers();
......
...@@ -269,6 +269,9 @@ class ASH_EXPORT Shell ...@@ -269,6 +269,9 @@ class ASH_EXPORT Shell
// Called when the user logs in. // Called when the user logs in.
void OnLoginStateChanged(user::LoginStatus status); void OnLoginStateChanged(user::LoginStatus status);
// Called after the logged-in user's profile is ready.
void OnLoginUserProfilePrepared();
// Called when the login status changes. // Called when the login status changes.
// TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
void UpdateAfterLoginStatusChange(user::LoginStatus status); void UpdateAfterLoginStatusChange(user::LoginStatus status);
...@@ -283,6 +286,10 @@ class ASH_EXPORT Shell ...@@ -283,6 +286,10 @@ class ASH_EXPORT Shell
// Initializes |launcher_|. Does nothing if it's already initialized. // Initializes |launcher_|. Does nothing if it's already initialized.
void CreateLauncher(); 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). // Show shelf view if it was created hidden (before session has started).
void ShowLauncher(); void ShowLauncher();
...@@ -539,8 +546,8 @@ class ASH_EXPORT Shell ...@@ -539,8 +546,8 @@ class ASH_EXPORT Shell
void Init(); void Init();
// Initializes virtual keyboard controller and attaches it to |root|. // Initializes virtual keyboard controller.
void InitKeyboard(internal::RootWindowController* root); void InitKeyboard();
// Initializes the root window so that it can host browser windows. // Initializes the root window so that it can host browser windows.
void InitRootWindow(aura::Window* root_window); void InitRootWindow(aura::Window* root_window);
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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.h"
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ui/aura/window.h"
#include "ui/views/corewm/input_method_event_filter.h" #include "ui/views/corewm/input_method_event_filter.h"
using namespace content; using namespace content;
...@@ -18,6 +19,12 @@ KeyboardControllerProxyStub::KeyboardControllerProxyStub() { ...@@ -18,6 +19,12 @@ KeyboardControllerProxyStub::KeyboardControllerProxyStub() {
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() { BrowserContext* KeyboardControllerProxyStub::GetBrowserContext() {
return Shell::GetInstance()->delegate()->GetCurrentBrowserContext(); return Shell::GetInstance()->delegate()->GetCurrentBrowserContext();
} }
......
...@@ -2,21 +2,26 @@ ...@@ -2,21 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_ #ifndef ASH_SHELL_KEYBOARD_CONTROLLER_PROXY_STUB_H_
#define ASH_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" #include "ui/keyboard/keyboard_controller_proxy.h"
namespace aura {
class Window;
} // namespace aura
namespace ash { namespace ash {
// Stub implementation of KeyboardControllerProxy // Stub implementation of KeyboardControllerProxy
class ASH_EXPORT KeyboardControllerProxyStub class KeyboardControllerProxyStub : public keyboard::KeyboardControllerProxy {
: public keyboard::KeyboardControllerProxy {
public: public:
KeyboardControllerProxyStub(); KeyboardControllerProxyStub();
virtual ~KeyboardControllerProxyStub(); virtual ~KeyboardControllerProxyStub();
virtual aura::Window* GetKeyboardWindow() OVERRIDE;
private: private:
// Overridden from keyboard::KeyboardControllerProxy: // Overridden from keyboard::KeyboardControllerProxy:
virtual content::BrowserContext* GetBrowserContext() OVERRIDE; virtual content::BrowserContext* GetBrowserContext() OVERRIDE;
...@@ -25,9 +30,10 @@ class ASH_EXPORT KeyboardControllerProxyStub ...@@ -25,9 +30,10 @@ class ASH_EXPORT KeyboardControllerProxyStub
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) OVERRIDE; const content::MediaResponseCallback& callback) OVERRIDE;
aura::test::TestWindowDelegate delegate_;
DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxyStub); DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxyStub);
}; };
} // namespace ash } // namespace ash
#endif // ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_ #endif // ASH_SHELL_KEYBOARD_CONTROLLER_PROXY_STUB_H_
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include "ash/default_accessibility_delegate.h" #include "ash/default_accessibility_delegate.h"
#include "ash/default_user_wallpaper_delegate.h" #include "ash/default_user_wallpaper_delegate.h"
#include "ash/host/root_window_host_factory.h" #include "ash/host/root_window_host_factory.h"
#include "ash/keyboard_controller_proxy_stub.h"
#include "ash/media_delegate.h" #include "ash/media_delegate.h"
#include "ash/new_window_delegate.h" #include "ash/new_window_delegate.h"
#include "ash/session_state_delegate.h" #include "ash/session_state_delegate.h"
#include "ash/session_state_delegate_stub.h" #include "ash/session_state_delegate_stub.h"
#include "ash/shell/context_menu.h" #include "ash/shell/context_menu.h"
#include "ash/shell/example_factory.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/launcher_delegate_impl.h"
#include "ash/shell/toplevel_window.h" #include "ash/shell/toplevel_window.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
#include "ash/caps_lock_delegate_stub.h" #include "ash/caps_lock_delegate_stub.h"
#include "ash/default_accessibility_delegate.h" #include "ash/default_accessibility_delegate.h"
#include "ash/host/root_window_host_factory.h" #include "ash/host/root_window_host_factory.h"
#include "ash/keyboard_controller_proxy_stub.h"
#include "ash/media_delegate.h" #include "ash/media_delegate.h"
#include "ash/new_window_delegate.h" #include "ash/new_window_delegate.h"
#include "ash/session_state_delegate.h" #include "ash/session_state_delegate.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell/keyboard_controller_proxy_stub.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/test/test_launcher_delegate.h" #include "ash/test/test_launcher_delegate.h"
#include "ash/test/test_session_state_delegate.h" #include "ash/test/test_session_state_delegate.h"
......
...@@ -225,7 +225,7 @@ void ChromeShellDelegate::Observe(int type, ...@@ -225,7 +225,7 @@ void ChromeShellDelegate::Observe(int type,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
switch (type) { switch (type) {
case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED:
ash::Shell::GetInstance()->CreateLauncher(); ash::Shell::GetInstance()->OnLoginUserProfilePrepared();
break; break;
case chrome::NOTIFICATION_SESSION_STARTED: case chrome::NOTIFICATION_SESSION_STARTED:
RestoreFocus(); RestoreFocus();
......
...@@ -95,9 +95,12 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() { ...@@ -95,9 +95,12 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() {
// Initialize TabScrubber after the Ash Shell has been initialized. // Initialize TabScrubber after the Ash Shell has been initialized.
TabScrubber::GetInstance(); TabScrubber::GetInstance();
// Activate virtual keyboard after profile is initialized. It depends on the // Activate virtual keyboard after profile is initialized. It depends on the
// default profile. // default profile. If keyboard usability experiment flag is set, defer the
ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard( // activation to UpdateWindow() in virtual_keyboard_window_controller.cc.
ash::Shell::GetInstance()->keyboard_controller()); if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard(
ash::Shell::GetInstance()->keyboard_controller());
}
} }
void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
......
...@@ -27,7 +27,8 @@ namespace { ...@@ -27,7 +27,8 @@ namespace {
const int kHideKeyboardDelayMs = 100; const int kHideKeyboardDelayMs = 100;
gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds) { 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( return gfx::Rect(
window_bounds.x(), window_bounds.x(),
window_bounds.y() + window_bounds.height() * (1 - kKeyboardHeightRatio), window_bounds.y() + window_bounds.height() * (1 - kKeyboardHeightRatio),
...@@ -191,8 +192,7 @@ void KeyboardController::OnTextInputStateChanged( ...@@ -191,8 +192,7 @@ void KeyboardController::OnTextInputStateChanged(
ui::TextInputType type = ui::TextInputType type =
client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
if (type == ui::TEXT_INPUT_TYPE_NONE && if (type == ui::TEXT_INPUT_TYPE_NONE &&
!CommandLine::ForCurrentProcess()->HasSwitch( !IsKeyboardUsabilityExperimentEnabled()) {
switches::kKeyboardUsabilityTest)) {
should_show = false; should_show = false;
} else { } else {
if (container_->children().empty()) { if (container_->children().empty()) {
...@@ -202,7 +202,8 @@ void KeyboardController::OnTextInputStateChanged( ...@@ -202,7 +202,8 @@ void KeyboardController::OnTextInputStateChanged(
container_->AddChild(keyboard); container_->AddChild(keyboard);
container_->layout_manager()->OnWindowResized(); container_->layout_manager()->OnWindowResized();
} }
proxy_->SetUpdateInputType(type); if (type != ui::TEXT_INPUT_TYPE_NONE)
proxy_->SetUpdateInputType(type);
container_->parent()->StackChildAtTop(container_.get()); container_->parent()->StackChildAtTop(container_.get());
should_show = true; should_show = true;
} }
......
...@@ -338,7 +338,7 @@ class KeyboardControllerUsabilityTest : public KeyboardControllerTest { ...@@ -338,7 +338,7 @@ class KeyboardControllerUsabilityTest : public KeyboardControllerTest {
virtual void SetUp() OVERRIDE { virtual void SetUp() OVERRIDE {
CommandLine::ForCurrentProcess()->AppendSwitch( CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kKeyboardUsabilityTest); switches::kKeyboardUsabilityExperiment);
KeyboardControllerTest::SetUp(); KeyboardControllerTest::SetUp();
} }
......
...@@ -10,7 +10,7 @@ namespace switches { ...@@ -10,7 +10,7 @@ namespace switches {
const char kEnableSwipeSelection[] = "enable-swipe-selection"; const char kEnableSwipeSelection[] = "enable-swipe-selection";
const char kEnableVirtualKeyboard[] = "enable-virtual-keyboard"; const char kEnableVirtualKeyboard[] = "enable-virtual-keyboard";
const char kKeyboardUsabilityTest[] = "keyboard-usability-test"; const char kKeyboardUsabilityExperiment[] = "keyboard-usability-experiment";
} // namespace switches } // namespace switches
} // namespace keyboard } // namespace keyboard
...@@ -16,8 +16,9 @@ KEYBOARD_EXPORT extern const char kEnableSwipeSelection[]; ...@@ -16,8 +16,9 @@ KEYBOARD_EXPORT extern const char kEnableSwipeSelection[];
// Enables the virtual keyboard. // Enables the virtual keyboard.
KEYBOARD_EXPORT extern const char kEnableVirtualKeyboard[]; KEYBOARD_EXPORT extern const char kEnableVirtualKeyboard[];
// Enables the keyboard usability test. // Enables the keyboard usability experiment. This is an experimental mode for
KEYBOARD_EXPORT extern const char kKeyboardUsabilityTest[]; // testing the usability of various experimental keyboard layouts.
KEYBOARD_EXPORT extern const char kKeyboardUsabilityExperiment[];
} // namespace switches } // namespace switches
} // namespace keyboard } // namespace keyboard
......
...@@ -42,9 +42,12 @@ namespace keyboard { ...@@ -42,9 +42,12 @@ namespace keyboard {
bool IsKeyboardEnabled() { bool IsKeyboardEnabled() {
return CommandLine::ForCurrentProcess()->HasSwitch( return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableVirtualKeyboard) || switches::kEnableVirtualKeyboard) ||
CommandLine::ForCurrentProcess()->HasSwitch( IsKeyboardUsabilityExperimentEnabled();
switches::kKeyboardUsabilityTest); }
bool IsKeyboardUsabilityExperimentEnabled() {
return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kKeyboardUsabilityExperiment);
} }
bool InsertText(const base::string16& text, aura::Window* root_window) { bool InsertText(const base::string16& text, aura::Window* root_window) {
......
...@@ -35,6 +35,9 @@ enum KeyboardControlEvent { ...@@ -35,6 +35,9 @@ enum KeyboardControlEvent {
// Returns true if the virtual keyboard is enabled. // Returns true if the virtual keyboard is enabled.
KEYBOARD_EXPORT bool IsKeyboardEnabled(); 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|, // Insert |text| into the active TextInputClient associated with |root_window|,
// if there is one. Returns true if |text| was successfully inserted. Note // if there is one. Returns true if |text| was successfully inserted. Note
// that this may convert |text| into ui::KeyEvents for injection in some // that this may convert |text| into ui::KeyEvents for injection in some
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment