summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 21:58:00 +0000
committerflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 21:58:00 +0000
commitacc38027acf92220412f07699e12774f71f9c445 (patch)
tree8c75214e0164ec70357635e8e090cda8970856e0 /ash
parent26024774201acfcee1be949aaf56af17f0f19c12 (diff)
downloadchromium_src-acc38027acf92220412f07699e12774f71f9c445.zip
chromium_src-acc38027acf92220412f07699e12774f71f9c445.tar.gz
chromium_src-acc38027acf92220412f07699e12774f71f9c445.tar.bz2
Do not allow system modal dialogs below the lock layer to steal focus.
BUG=110920 TEST=Open a system modal dialog, lock the screen, and verify that you can now unlock the screen. Review URL: https://chromiumcodereview.appspot.com/9271062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/system_modal_container_layout_manager.cc6
-rw-r--r--ash/wm/system_modal_container_layout_manager_unittest.cc69
2 files changed, 75 insertions, 0 deletions
diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc
index 01a7bfb..3fc56b3 100644
--- a/ash/wm/system_modal_container_layout_manager.cc
+++ b/ash/wm/system_modal_container_layout_manager.cc
@@ -6,6 +6,7 @@
#include "ash/ash_switches.h"
#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
#include "ash/wm/system_modal_container_event_filter.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_util.h"
@@ -143,6 +144,11 @@ void SystemModalContainerLayoutManager::OnLayerAnimationScheduled(
bool SystemModalContainerLayoutManager::CanWindowReceiveEvents(
aura::Window* window) {
+ // This container can not handle events if the screen is locked and it is not
+ // above the lock screen layer (crbug.com/110920).
+ if (ash::Shell::GetInstance()->IsScreenLocked() &&
+ container_->id() < ash::internal::kShellWindowId_LockScreenContainer)
+ return true;
return GetActivatableWindow(window) == modal_window();
}
diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc
index db1fbc5..04198ea 100644
--- a/ash/wm/system_modal_container_layout_manager_unittest.cc
+++ b/ash/wm/system_modal_container_layout_manager_unittest.cc
@@ -12,6 +12,7 @@
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
+#include "ui/views/events/event.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -62,6 +63,32 @@ class TestWindow : public views::WidgetDelegateView {
DISALLOW_COPY_AND_ASSIGN(TestWindow);
};
+class EventTestWindow : public TestWindow {
+ public:
+ explicit EventTestWindow(bool modal) : TestWindow(modal),
+ mouse_presses_(0) {}
+ virtual ~EventTestWindow() {}
+
+ aura::Window* OpenTestWindow(aura::Window* parent) {
+ views::Widget* widget =
+ views::Widget::CreateWindowWithParent(this, parent);
+ widget->Show();
+ return widget->GetNativeView();
+ }
+
+ // Overridden from views::View:
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
+ mouse_presses_++;
+ return false;
+ }
+
+ int mouse_presses() const { return mouse_presses_; }
+ private:
+ int mouse_presses_;
+
+ DISALLOW_COPY_AND_ASSIGN(EventTestWindow);
+};
+
class TransientWindowObserver : public aura::WindowObserver {
public:
TransientWindowObserver() : destroyed_(false) {}
@@ -173,5 +200,47 @@ TEST_F(SystemModalContainerLayoutManagerTest,
EXPECT_TRUE(IsActiveWindow(unrelated.get()));
}
+TEST_F(SystemModalContainerLayoutManagerTest,
+ EventFocusContainers) {
+ // Create a normal window and attempt to receive a click event.
+ EventTestWindow* main_delegate = new EventTestWindow(false);
+ scoped_ptr<aura::Window> main(main_delegate->OpenTestWindow(NULL));
+ EXPECT_TRUE(IsActiveWindow(main.get()));
+ aura::test::EventGenerator e1(main.get());
+ e1.ClickLeftButton();
+ EXPECT_EQ(1, main_delegate->mouse_presses());
+
+ // Create a modal window for the main window and verify that the main window
+ // no longer receives mouse events.
+ EventTestWindow* transient_delegate = new EventTestWindow(true);
+ aura::Window* transient = transient_delegate->OpenTestWindow(main.get());
+ EXPECT_TRUE(IsActiveWindow(transient));
+ e1.ClickLeftButton();
+ EXPECT_EQ(1, transient_delegate->mouse_presses());
+
+ // Create a window in the lock screen container and ensure that it receives
+ // the mouse event instead of the modal window (crbug.com/110920).
+ EventTestWindow* lock_delegate = new EventTestWindow(false);
+ scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindow(
+ Shell::GetInstance()->GetContainer(
+ ash::internal::kShellWindowId_LockScreenContainer)));
+ EXPECT_TRUE(IsActiveWindow(lock.get()));
+ e1.ClickLeftButton();
+ EXPECT_EQ(1, lock_delegate->mouse_presses());
+
+ // Make sure that a modal container created by the lock screen can still
+ // receive mouse events.
+ EventTestWindow* lock_modal_delegate = new EventTestWindow(true);
+ aura::Window* lock_modal = lock_modal_delegate->OpenTestWindow(lock.get());
+ EXPECT_TRUE(IsActiveWindow(lock_modal));
+ e1.ClickLeftButton();
+ EXPECT_EQ(1, main_delegate->mouse_presses());
+
+ // Verify that none of the other containers received any more mouse presses.
+ EXPECT_EQ(1, transient_delegate->mouse_presses());
+ EXPECT_EQ(1, lock_delegate->mouse_presses());
+ EXPECT_EQ(1, lock_modal_delegate->mouse_presses());
+}
+
} // namespace test
} // namespace ash