summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbshe <bshe@chromium.org>2014-09-22 16:16:52 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-22 23:17:05 +0000
commiteaae09a093fc4c3d4ac8ba0f36e367e8a3dc7378 (patch)
treef73cd7542e583df4201d33ace2b5e05e5c85c78e
parentbeec6a363b7ec3751a83566beaa6f8565e709bad (diff)
downloadchromium_src-eaae09a093fc4c3d4ac8ba0f36e367e8a3dc7378.zip
chromium_src-eaae09a093fc4c3d4ac8ba0f36e367e8a3dc7378.tar.gz
chromium_src-eaae09a093fc4c3d4ac8ba0f36e367e8a3dc7378.tar.bz2
Enable virtual keyboard in overview mode
Touch view uses virtual_keyboard_window_controller to enable/disable virtual keyboard. However, virtual_keyboard_window_controller is specific for a Touch Usability mode which nobody uses and is removed. This CL adds a VirtualKeyboardObserver to replace virtual_keyboard_window_controller. BUG=416495 Review URL: https://codereview.chromium.org/592753004 Cr-Commit-Position: refs/heads/master@{#296086}
-rw-r--r--ash/ash.gyp3
-rw-r--r--ash/shell.cc3
-rw-r--r--ash/shell.h2
-rw-r--r--ash/virtual_keyboard_controller.cc31
-rw-r--r--ash/virtual_keyboard_controller.h29
-rw-r--r--ash/virtual_keyboard_controller_unittest.cc30
6 files changed, 98 insertions, 0 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 3744e4e..0592abd 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -480,6 +480,8 @@
'touch/touch_uma.h',
'touch/touchscreen_util.cc',
'touch/touchscreen_util.h',
+ 'virtual_keyboard_controller.cc',
+ 'virtual_keyboard_controller.h',
'volume_control_delegate.h',
'wm/app_list_controller.cc',
'wm/app_list_controller.h',
@@ -835,6 +837,7 @@
'touch/touch_observer_hud_unittest.cc',
'touch/touch_transformer_controller_unittest.cc',
'touch/touchscreen_util_unittest.cc',
+ 'virtual_keyboard_controller_unittest.cc',
'wm/app_list_controller_unittest.cc',
'wm/ash_native_cursor_manager_unittest.cc',
'wm/dock/docked_window_layout_manager_unittest.cc',
diff --git a/ash/shell.cc b/ash/shell.cc
index 9f8272f..bf6f5a4d 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -53,6 +53,7 @@
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_notifier.h"
+#include "ash/virtual_keyboard_controller.h"
#include "ash/wm/app_list_controller.h"
#include "ash/wm/ash_focus_rules.h"
#include "ash/wm/ash_native_cursor_manager.h"
@@ -793,6 +794,7 @@ Shell::~Shell() {
display_manager_->CreateScreenForShutdown();
display_controller_->Shutdown();
display_controller_.reset();
+ virtual_keyboard_controller_.reset();
screen_position_controller_.reset();
accessibility_delegate_.reset();
new_window_delegate_.reset();
@@ -879,6 +881,7 @@ void Shell::Init(const ShellInitParams& init_params) {
display_controller_->Start();
display_controller_->CreatePrimaryHost(
ShellInitParamsToAshWindowTreeHostInitParams(init_params));
+ virtual_keyboard_controller_.reset(new VirtualKeyboardController);
aura::Window* root_window = display_controller_->GetPrimaryRootWindow();
target_root_window_ = root_window;
diff --git a/ash/shell.h b/ash/shell.h
index 7d5ab3b..a807c6b 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -141,6 +141,7 @@ class TouchTransformerController;
class TouchObserverHUD;
class UserActivityDetector;
class UserWallpaperDelegate;
+class VirtualKeyboardController;
class VideoActivityNotifier;
class VideoDetector;
class WebNotificationTray;
@@ -666,6 +667,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
scoped_ptr<WindowSelectorController> window_selector_controller_;
scoped_ptr<FocusCycler> focus_cycler_;
scoped_ptr<DisplayController> display_controller_;
+ scoped_ptr<VirtualKeyboardController> virtual_keyboard_controller_;
scoped_ptr<HighContrastController> high_contrast_controller_;
scoped_ptr<MagnificationController> magnification_controller_;
scoped_ptr<PartialMagnificationController> partial_magnification_controller_;
diff --git a/ash/virtual_keyboard_controller.cc b/ash/virtual_keyboard_controller.cc
new file mode 100644
index 0000000..6bd535a
--- /dev/null
+++ b/ash/virtual_keyboard_controller.cc
@@ -0,0 +1,31 @@
+// Copyright 2014 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/virtual_keyboard_controller.h"
+
+#include "ash/shell.h"
+#include "ui/keyboard/keyboard_util.h"
+
+namespace ash {
+
+VirtualKeyboardController::VirtualKeyboardController() {
+ Shell::GetInstance()->AddShellObserver(this);
+}
+
+VirtualKeyboardController::~VirtualKeyboardController() {
+ Shell::GetInstance()->RemoveShellObserver(this);
+}
+
+void VirtualKeyboardController::OnMaximizeModeStarted() {
+ keyboard::SetTouchKeyboardEnabled(true);
+ Shell::GetInstance()->CreateKeyboard();
+}
+
+void VirtualKeyboardController::OnMaximizeModeEnded() {
+ keyboard::SetTouchKeyboardEnabled(false);
+ if (!keyboard::IsKeyboardEnabled())
+ Shell::GetInstance()->DeactivateKeyboard();
+}
+
+} // namespace ash
diff --git a/ash/virtual_keyboard_controller.h b/ash/virtual_keyboard_controller.h
new file mode 100644
index 0000000..47ef475
--- /dev/null
+++ b/ash/virtual_keyboard_controller.h
@@ -0,0 +1,29 @@
+// Copyright 2014 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_VIRTUAL_KEYBOARD_CONTROLLER_H_
+#define ASH_VIRTUAL_KEYBOARD_CONTROLLER_H_
+
+#include "ash/ash_export.h"
+#include "ash/shell_observer.h"
+
+namespace ash {
+
+// This class observes enter/leaving maximized mode for virtual keyboard.
+class ASH_EXPORT VirtualKeyboardController : public ShellObserver {
+ public:
+ VirtualKeyboardController();
+ virtual ~VirtualKeyboardController();
+
+ // ShellObserver:
+ virtual void OnMaximizeModeStarted() OVERRIDE;
+ virtual void OnMaximizeModeEnded() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardController);
+};
+
+} // namespace ash
+
+#endif // ASH_VIRTUAL_KEYBOARD_CONTROLLER_H_
diff --git a/ash/virtual_keyboard_controller_unittest.cc b/ash/virtual_keyboard_controller_unittest.cc
new file mode 100644
index 0000000..8072b84
--- /dev/null
+++ b/ash/virtual_keyboard_controller_unittest.cc
@@ -0,0 +1,30 @@
+// Copyright 2014 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/virtual_keyboard_controller.h"
+
+#include "ash/shell.h"
+#include "ash/test/ash_test_base.h"
+#include "ash/wm/maximize_mode/maximize_mode_controller.h"
+#include "ui/keyboard/keyboard_util.h"
+
+namespace ash {
+namespace test {
+
+typedef AshTestBase VirtualKeyboardControllerTest;
+
+// Tests that the onscreen keyboard becomes enabled when maximize mode is
+// enabled.
+TEST_F(VirtualKeyboardControllerTest, EnabledDuringMaximizeMode) {
+ ASSERT_FALSE(keyboard::IsKeyboardEnabled());
+ Shell::GetInstance()->maximize_mode_controller()->
+ EnableMaximizeModeWindowManager(true);
+ EXPECT_TRUE(keyboard::IsKeyboardEnabled());
+ Shell::GetInstance()->maximize_mode_controller()->
+ EnableMaximizeModeWindowManager(false);
+ EXPECT_FALSE(keyboard::IsKeyboardEnabled());
+}
+
+} // namespace test
+} // namespace ash