summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_commands_global_registry.cc
diff options
context:
space:
mode:
authorzhchbin@gmail.com <zhchbin@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-25 18:42:22 +0000
committerzhchbin@gmail.com <zhchbin@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-25 18:42:22 +0000
commit1532cbd923670f004d548db3f9c6198b10dbf19b (patch)
treefc864360edc7190454ba3a31f88417484da5902c /chrome/browser/extensions/extension_commands_global_registry.cc
parent9d7b4787e17b61ffe22c5f48902c346b1f79f029 (diff)
downloadchromium_src-1532cbd923670f004d548db3f9c6198b10dbf19b.zip
chromium_src-1532cbd923670f004d548db3f9c6198b10dbf19b.tar.gz
chromium_src-1532cbd923670f004d548db3f9c6198b10dbf19b.tar.bz2
Suspend shortcut handling while setting commands.
BUG=329901 TEST=0. Run chrome with --global-commands=1 1. Go to chrome://extensions -> Keyboard shortcuts 2. When overriding a command with a global commands, the original command should not fire while changing the shortcut. Review URL: https://codereview.chromium.org/206293004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_commands_global_registry.cc')
-rw-r--r--chrome/browser/extensions/extension_commands_global_registry.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_commands_global_registry.cc b/chrome/browser/extensions/extension_commands_global_registry.cc
index b3b19b0..1982add 100644
--- a/chrome/browser/extensions/extension_commands_global_registry.cc
+++ b/chrome/browser/extensions/extension_commands_global_registry.cc
@@ -21,8 +21,17 @@ ExtensionCommandsGlobalRegistry::ExtensionCommandsGlobalRegistry(
}
ExtensionCommandsGlobalRegistry::~ExtensionCommandsGlobalRegistry() {
- if (!IsEventTargetsEmpty())
- GlobalShortcutListener::GetInstance()->UnregisterAccelerators(this);
+ if (!IsEventTargetsEmpty()) {
+ GlobalShortcutListener* global_shortcut_listener =
+ GlobalShortcutListener::GetInstance();
+
+ // Resume GlobalShortcutListener before we clean up if the shortcut handling
+ // is currently suspended.
+ if (global_shortcut_listener->IsShortcutHandlingSuspended())
+ global_shortcut_listener->SetShortcutHandlingSuspended(false);
+
+ global_shortcut_listener->UnregisterAccelerators(this);
+ }
}
static base::LazyInstance<
@@ -42,6 +51,13 @@ ExtensionCommandsGlobalRegistry* ExtensionCommandsGlobalRegistry::Get(
context);
}
+// static
+void ExtensionCommandsGlobalRegistry::SetShortcutHandlingSuspended(
+ bool suspended) {
+ GlobalShortcutListener::GetInstance()->SetShortcutHandlingSuspended(
+ suspended);
+}
+
void ExtensionCommandsGlobalRegistry::AddExtensionKeybinding(
const extensions::Extension* extension,
const std::string& command_name) {