summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaheem Adam <rsadam@chromium.org>2015-01-08 16:58:12 -0500
committerRaheem Adam <rsadam@chromium.org>2015-01-08 22:00:46 +0000
commit5fd8335ef6149d523f2d9d1fde1e848175a2a64b (patch)
tree12c000759783e65688088be73ccc3e6a5a54266a
parent79858cd2684d8c4e7b0c5cb4f6dafc89649012cf (diff)
downloadchromium_src-5fd8335ef6149d523f2d9d1fde1e848175a2a64b.zip
chromium_src-5fd8335ef6149d523f2d9d1fde1e848175a2a64b.tar.gz
chromium_src-5fd8335ef6149d523f2d9d1fde1e848175a2a64b.tar.bz2
Fixes smart deploy causing crash on shutdown.
Moves the destruction of the Virtual Keyboard Controller before the Maximized Mode Controller so that re-enabling the internal keyboard when leaving touchview due to shutdown does not cause the on-screen keyboard to change state. BUG=446204 TBR=sky TEST=VirtualKeyboardControllerTest.RestoreKeyboardDevices Review URL: https://codereview.chromium.org/834163002 Cr-Commit-Position: refs/heads/master@{#310316} (cherry picked from commit bbaf2c83b69fe1e0881809f2c0b7a66606d6a15a) Review URL: https://codereview.chromium.org/843603003 Cr-Commit-Position: refs/branch-heads/2214@{#410} Cr-Branched-From: 03655fd3f6d72165dc3c9bd2c89807305316fe6c-refs/heads/master@{#303346}
-rw-r--r--ash/shell.cc9
-rw-r--r--ash/virtual_keyboard_controller_unittest.cc41
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller.h2
3 files changed, 49 insertions, 3 deletions
diff --git a/ash/shell.cc b/ash/shell.cc
index 9de2e15..7640d26 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -695,6 +695,12 @@ Shell::~Shell() {
// TooltipController is deleted with the Shell so removing its references.
RemovePreTargetHandler(tooltip_controller_.get());
+// Destroy the virtual keyboard controller before the maximize mode controller
+// since the latters destructor triggers events that the former is listening
+// to but no longer cares about.
+#if defined(OS_CHROMEOS)
+ virtual_keyboard_controller_.reset();
+#endif
// Destroy maximize mode controller early on since it has some observers which
// need to be removed.
maximize_mode_controller_->Shutdown();
@@ -794,9 +800,6 @@ Shell::~Shell() {
display_manager_->CreateScreenForShutdown();
display_controller_->Shutdown();
display_controller_.reset();
-#if defined(OS_CHROMEOS)
- virtual_keyboard_controller_.reset();
-#endif
screen_position_controller_.reset();
accessibility_delegate_.reset();
new_window_delegate_.reset();
diff --git a/ash/virtual_keyboard_controller_unittest.cc b/ash/virtual_keyboard_controller_unittest.cc
index dc45cc1..df04ae4 100644
--- a/ash/virtual_keyboard_controller_unittest.cc
+++ b/ash/virtual_keyboard_controller_unittest.cc
@@ -4,10 +4,13 @@
#include "ash/virtual_keyboard_controller.h"
+#include <vector>
+
#include "ash/shell.h"
#include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
+#include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h"
#include "base/command_line.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/device_hotplug_event_observer.h"
@@ -39,6 +42,14 @@ class VirtualKeyboardControllerTest : public AshTestBase {
manager->OnKeyboardDevicesUpdated(keyboard_devices);
}
+ // Sets the event blocker on the maximized window controller.
+ void SetEventBlocker(
+ scoped_ptr<ScopedDisableInternalMouseAndKeyboard> blocker) {
+ Shell::GetInstance()
+ ->maximize_mode_controller()
+ ->event_blocker_ = blocker.Pass();
+ }
+
void SetUp() override {
AshTestBase::SetUp();
UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>());
@@ -63,6 +74,36 @@ TEST_F(VirtualKeyboardControllerTest, EnabledDuringMaximizeMode) {
EXPECT_FALSE(keyboard::IsKeyboardEnabled());
}
+// Mock event blocker that enables the internal keyboard when it's destructor
+// is called.
+class MockEventBlocker : public ScopedDisableInternalMouseAndKeyboard {
+ public:
+ MockEventBlocker() {}
+ ~MockEventBlocker() override {
+ std::vector<ui::KeyboardDevice> keyboards;
+ keyboards.push_back(ui::KeyboardDevice(
+ 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
+ ui::DeviceHotplugEventObserver* manager =
+ ui::DeviceDataManager::GetInstance();
+ manager->OnKeyboardDevicesUpdated(keyboards);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockEventBlocker);
+};
+
+// Tests that reenabling keyboard devices while shutting down does not
+// cause the Virtual Keyboard Controller to crash. See crbug.com/446204.
+TEST_F(VirtualKeyboardControllerTest, RestoreKeyboardDevices) {
+ // Toggle maximized mode on.
+ Shell::GetInstance()
+ ->maximize_mode_controller()
+ ->EnableMaximizeModeWindowManager(true);
+ scoped_ptr<ScopedDisableInternalMouseAndKeyboard>
+ blocker(new MockEventBlocker);
+ SetEventBlocker(blocker.Pass());
+}
+
class VirtualKeyboardControllerAutoTest : public VirtualKeyboardControllerTest,
public VirtualKeyboardObserver {
public:
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.h b/ash/wm/maximize_mode/maximize_mode_controller.h
index 4210f27..29c58fa 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.h
+++ b/ash/wm/maximize_mode/maximize_mode_controller.h
@@ -35,6 +35,7 @@ class MaximizeModeWindowManager;
class MaximizeModeWindowManagerTest;
namespace test {
class MultiUserWindowManagerChromeOSTest;
+class VirtualKeyboardControllerTest;
}
// MaximizeModeController listens to accelerometer events and automatically
@@ -131,6 +132,7 @@ class ASH_EXPORT MaximizeModeController
friend class MaximizeModeControllerTest;
friend class MaximizeModeWindowManagerTest;
friend class test::MultiUserWindowManagerChromeOSTest;
+ friend class test::VirtualKeyboardControllerTest;
// Set the TickClock. This is only to be used by tests that need to
// artificially and deterministically control the current time.