Prevents double-clicks on a tab close button from aslo maximizing the browser
[chromium-blink-merge.git] / ash / wm / event_client_impl.cc
blobb54e62206d84c63b84bc341435f90007caff98f1
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/wm/event_client_impl.h"
7 #include "ash/session_state_delegate.h"
8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
10 #include "ui/aura/window.h"
11 #include "ui/keyboard/keyboard_util.h"
13 namespace ash {
15 EventClientImpl::EventClientImpl() {
18 EventClientImpl::~EventClientImpl() {
21 bool EventClientImpl::CanProcessEventsWithinSubtree(
22 const aura::Window* window) const {
23 const aura::Window* root_window = window ? window->GetRootWindow() : NULL;
24 if (!root_window ||
25 !Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked()) {
26 return true;
29 const aura::Window* lock_screen_containers = Shell::GetContainer(
30 root_window,
31 kShellWindowId_LockScreenContainersContainer);
32 const aura::Window* lock_background_containers = Shell::GetContainer(
33 root_window,
34 kShellWindowId_LockScreenBackgroundContainer);
35 const aura::Window* lock_screen_related_containers = Shell::GetContainer(
36 root_window,
37 kShellWindowId_LockScreenRelatedContainersContainer);
38 bool can_process_events = (window->Contains(lock_screen_containers) &&
39 window->Contains(lock_background_containers) &&
40 window->Contains(lock_screen_related_containers)) ||
41 lock_screen_containers->Contains(window) ||
42 lock_background_containers->Contains(window) ||
43 lock_screen_related_containers->Contains(window);
44 if (keyboard::IsKeyboardEnabled()) {
45 const aura::Window* virtual_keyboard_container = Shell::GetContainer(
46 root_window,
47 kShellWindowId_VirtualKeyboardContainer);
48 can_process_events |= (window->Contains(virtual_keyboard_container) ||
49 virtual_keyboard_container->Contains(window));
51 return can_process_events;
54 ui::EventTarget* EventClientImpl::GetToplevelEventTarget() {
55 return Shell::GetInstance();
58 } // namespace ash