| Index: chrome/browser/chromeos/events/event_rewriter.cc
|
| diff --git a/chrome/browser/chromeos/events/event_rewriter.cc b/chrome/browser/chromeos/events/event_rewriter.cc
|
| index 314a3ecd272cc4987b081631fbc14a31bac25219..4199371123b38cd8fed91c635a742e375e5ebf79 100644
|
| --- a/chrome/browser/chromeos/events/event_rewriter.cc
|
| +++ b/chrome/browser/chromeos/events/event_rewriter.cc
|
| @@ -16,7 +16,12 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/sys_info.h"
|
| #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
|
| +#include "chrome/browser/extensions/extension_commands_global_registry.h"
|
| +#include "chrome/browser/extensions/extension_keybinding_registry_tracker.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chromeos/chromeos_switches.h"
|
| #include "chromeos/ime/ime_keyboard.h"
|
| @@ -104,6 +109,44 @@ bool IsISOLevel5ShiftUsedByCurrentInputMethod() {
|
| return manager->IsISOLevel5ShiftUsedByCurrentInputMethod();
|
| }
|
|
|
| +bool IsExtensionCommandRegistered(const ui::KeyEvent& key_event) {
|
| + // Some keyboard events for ChromeOS get rewritten, such as:
|
| + // Search+Shift+Left gets converted to Shift+Home (BeginDocument).
|
| + // This doesn't make sense if the user has assigned that shortcut
|
| + // to an extension. Because:
|
| + // 1) The extension would, upon seeing a request for Ctrl+Shift+Home have
|
| + // to register for Shift+Home, instead.
|
| + // 2) The conversion is unnecessary, because Shift+Home (BeginDocument) isn't
|
| + // going to be executed.
|
| + // Therefore, we skip converting the accelerator if an extension has
|
| + // registered for this shortcut.
|
| + Profile* profile = ProfileManager::GetActiveUserProfile();
|
| + if (!profile)
|
| + return false;
|
| +
|
| + extensions::ExtensionKeybindingRegistry* registry =
|
| + extensions::ExtensionKeybindingRegistryTracker::Get(profile)
|
| + ->GetActiveRegistry();
|
| + if (!registry)
|
| + return false;
|
| +
|
| + int modifiers = ui::EF_NONE;
|
| + if (key_event.IsShiftDown())
|
| + modifiers |= ui::EF_SHIFT_DOWN;
|
| + if (key_event.IsControlDown())
|
| + modifiers |= ui::EF_CONTROL_DOWN;
|
| + if (key_event.IsAltDown())
|
| + modifiers |= ui::EF_ALT_DOWN;
|
| + if (key_event.IsCommandDown())
|
| + modifiers |= ui::EF_COMMAND_DOWN;
|
| + ui::Accelerator accelerator(key_event.key_code(), modifiers);
|
| + if (registry->IsAcceleratorRegistered(accelerator) ||
|
| + extensions::ExtensionCommandsGlobalRegistry::Get(profile)
|
| + ->IsAcceleratorRegistered(accelerator))
|
| + return true;
|
| + return false;
|
| +}
|
| +
|
| EventRewriter::DeviceType GetDeviceType(const std::string& device_name) {
|
| std::vector<std::string> tokens;
|
| Tokenize(device_name, " .", &tokens);
|
| @@ -360,6 +403,8 @@ bool EventRewriter::RewriteWithKeyboardRemappingsByKeyCode(
|
| ui::EventRewriteStatus EventRewriter::RewriteKeyEvent(
|
| const ui::KeyEvent& key_event,
|
| scoped_ptr<ui::Event>* rewritten_event) {
|
| + if (IsExtensionCommandRegistered(key_event))
|
| + return ui::EVENT_REWRITE_CONTINUE;
|
| if (key_event.source_device_id() != ui::ED_UNKNOWN_DEVICE)
|
| DeviceKeyPressedOrReleased(key_event.source_device_id());
|
| MutableKeyState state = {key_event.flags(), key_event.key_code()};
|
|
|