OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/accelerators/accelerator_router.h" | 5 #include "ash/accelerators/accelerator_router.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_port.h" |
9 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
10 #include "ash/wm_shell.h" | |
11 #include "ash/wm_window.h" | 11 #include "ash/wm_window.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "ui/base/accelerators/accelerator.h" | 14 #include "ui/base/accelerators/accelerator.h" |
15 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
16 | 16 |
17 namespace ash { | 17 namespace ash { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 WmWindow* target, | 97 WmWindow* target, |
98 const ui::KeyEvent& event, | 98 const ui::KeyEvent& event, |
99 const ui::Accelerator& accelerator) { | 99 const ui::Accelerator& accelerator) { |
100 // Callers should never supply null. | 100 // Callers should never supply null. |
101 DCHECK(target); | 101 DCHECK(target); |
102 // On ChromeOS, If the accelerator is Search+<key(s)> then it must never be | 102 // On ChromeOS, If the accelerator is Search+<key(s)> then it must never be |
103 // intercepted by apps or windows. | 103 // intercepted by apps or windows. |
104 if (accelerator.IsCmdDown()) | 104 if (accelerator.IsCmdDown()) |
105 return true; | 105 return true; |
106 | 106 |
107 if (base::ContainsValue(WmShell::Get()->GetAllRootWindows(), target)) | 107 if (base::ContainsValue(ShellPort::Get()->GetAllRootWindows(), target)) |
108 return true; | 108 return true; |
109 | 109 |
110 AcceleratorController* accelerator_controller = | 110 AcceleratorController* accelerator_controller = |
111 Shell::Get()->accelerator_controller(); | 111 Shell::Get()->accelerator_controller(); |
112 | 112 |
113 // Reserved accelerators (such as Power button) always have a prority. | 113 // Reserved accelerators (such as Power button) always have a prority. |
114 if (accelerator_controller->IsReserved(accelerator)) | 114 if (accelerator_controller->IsReserved(accelerator)) |
115 return true; | 115 return true; |
116 | 116 |
117 // A full screen window has a right to handle all key events including the | 117 // A full screen window has a right to handle all key events including the |
118 // reserved ones. | 118 // reserved ones. |
119 WmWindow* top_level = target->GetToplevelWindowForFocus(); | 119 WmWindow* top_level = target->GetToplevelWindowForFocus(); |
120 if (top_level && top_level->GetWindowState()->IsFullscreen()) { | 120 if (top_level && top_level->GetWindowState()->IsFullscreen()) { |
121 // On ChromeOS, fullscreen windows are either browser or apps, which | 121 // On ChromeOS, fullscreen windows are either browser or apps, which |
122 // send key events to a web content first, then will process keys | 122 // send key events to a web content first, then will process keys |
123 // if the web content didn't consume them. | 123 // if the web content didn't consume them. |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 // Handle preferred accelerators (such as ALT-TAB) before sending | 127 // Handle preferred accelerators (such as ALT-TAB) before sending |
128 // to the target. | 128 // to the target. |
129 if (accelerator_controller->IsPreferred(accelerator)) | 129 if (accelerator_controller->IsPreferred(accelerator)) |
130 return true; | 130 return true; |
131 | 131 |
132 return Shell::Get()->GetAppListTargetVisibility(); | 132 return Shell::Get()->GetAppListTargetVisibility(); |
133 } | 133 } |
134 | 134 |
135 } // namespace ash | 135 } // namespace ash |
OLD | NEW |