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 "chrome/browser/chromeos/events/event_rewriter.h" | 5 #include "chrome/browser/chromeos/events/event_rewriter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/sticky_keys/sticky_keys_controller.h" | 9 #include "ash/sticky_keys/sticky_keys_controller.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
18 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 18 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/ui/browser.h" | |
21 #include "chrome/browser/ui/browser_list.h" | |
22 #include "chrome/browser/ui/browser_window.h" | |
20 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
21 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
22 #include "chromeos/ime/ime_keyboard.h" | 25 #include "chromeos/ime/ime_keyboard.h" |
23 #include "chromeos/ime/input_method_manager.h" | 26 #include "chromeos/ime/input_method_manager.h" |
24 #include "components/user_manager/user_manager.h" | 27 #include "components/user_manager/user_manager.h" |
25 #include "ui/events/event.h" | 28 #include "ui/events/event.h" |
26 #include "ui/events/event_utils.h" | 29 #include "ui/events/event_utils.h" |
27 #include "ui/events/keycodes/keyboard_code_conversion.h" | 30 #include "ui/events/keycodes/keyboard_code_conversion.h" |
28 #include "ui/wm/core/window_util.h" | 31 #include "ui/wm/core/window_util.h" |
29 | 32 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 const ui::MouseEvent& event, | 152 const ui::MouseEvent& event, |
150 scoped_ptr<ui::Event>* rewritten_event) { | 153 scoped_ptr<ui::Event>* rewritten_event) { |
151 RewriteMouseButtonEvent(event, rewritten_event); | 154 RewriteMouseButtonEvent(event, rewritten_event); |
152 } | 155 } |
153 | 156 |
154 ui::EventRewriteStatus EventRewriter::RewriteEvent( | 157 ui::EventRewriteStatus EventRewriter::RewriteEvent( |
155 const ui::Event& event, | 158 const ui::Event& event, |
156 scoped_ptr<ui::Event>* rewritten_event) { | 159 scoped_ptr<ui::Event>* rewritten_event) { |
157 if ((event.type() == ui::ET_KEY_PRESSED) || | 160 if ((event.type() == ui::ET_KEY_PRESSED) || |
158 (event.type() == ui::ET_KEY_RELEASED)) { | 161 (event.type() == ui::ET_KEY_RELEASED)) { |
162 // Check the extensions system didn't bind any of these keys. | |
Finnur
2014/09/10 10:15:16
I would do a few things here.
1) Add a helper fun
| |
163 const BrowserList* ash_browser_list = | |
164 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | |
165 for (BrowserList::const_reverse_iterator browser_iterator = | |
166 ash_browser_list->begin_last_active(); | |
167 browser_iterator != ash_browser_list->end_last_active(); | |
168 ++browser_iterator) { | |
169 BrowserWindow* window = (*browser_iterator)->window(); | |
170 | |
171 if (window->IsActive()) { | |
172 int modifiers = ui::EF_NONE; | |
173 if (event.IsShiftDown()) | |
174 modifiers |= ui::EF_SHIFT_DOWN; | |
175 if (event.IsControlDown()) | |
176 modifiers |= ui::EF_CONTROL_DOWN; | |
177 if (event.IsAltDown()) | |
178 modifiers |= ui::EF_ALT_DOWN; | |
179 if (event.IsCommandDown()) | |
180 modifiers |= ui::EF_COMMAND_DOWN; | |
181 ui::Accelerator accelerator( | |
182 static_cast<const ui::KeyEvent&>(event).key_code(), modifiers); | |
183 if (window->IsExtensionCommandRegistered(accelerator)) | |
184 return ui::EVENT_REWRITE_CONTINUE; | |
185 } | |
186 } | |
187 | |
159 return RewriteKeyEvent(static_cast<const ui::KeyEvent&>(event), | 188 return RewriteKeyEvent(static_cast<const ui::KeyEvent&>(event), |
160 rewritten_event); | 189 rewritten_event); |
161 } | 190 } |
162 if ((event.type() == ui::ET_MOUSE_PRESSED) || | 191 if ((event.type() == ui::ET_MOUSE_PRESSED) || |
163 (event.type() == ui::ET_MOUSE_RELEASED)) { | 192 (event.type() == ui::ET_MOUSE_RELEASED)) { |
164 return RewriteMouseButtonEvent(static_cast<const ui::MouseEvent&>(event), | 193 return RewriteMouseButtonEvent(static_cast<const ui::MouseEvent&>(event), |
165 rewritten_event); | 194 rewritten_event); |
166 } | 195 } |
167 if (event.type() == ui::ET_MOUSEWHEEL) { | 196 if (event.type() == ui::ET_MOUSEWHEEL) { |
168 return RewriteMouseWheelEvent( | 197 return RewriteMouseWheelEvent( |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 KeyboardDeviceAddedInternal(device_info[i].deviceid, device_info[i].name); | 890 KeyboardDeviceAddedInternal(device_info[i].deviceid, device_info[i].name); |
862 } | 891 } |
863 | 892 |
864 XIFreeDeviceInfo(device_info); | 893 XIFreeDeviceInfo(device_info); |
865 #else | 894 #else |
866 KeyboardDeviceAddedInternal(device_id, "keyboard"); | 895 KeyboardDeviceAddedInternal(device_id, "keyboard"); |
867 #endif | 896 #endif |
868 } | 897 } |
869 | 898 |
870 } // namespace chromeos | 899 } // namespace chromeos |
OLD | NEW |