diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 10:43:44 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 10:43:44 +0000 |
commit | 0fc4e6ef082e6b6053a3f77932335bcbe59b258a (patch) | |
tree | c8e9ed73d308806b34db3ac7df0e966823ceb211 | |
parent | a1b553cb65d2895c73763797a258590497fbe33a (diff) | |
download | chromium_src-0fc4e6ef082e6b6053a3f77932335bcbe59b258a.zip chromium_src-0fc4e6ef082e6b6053a3f77932335bcbe59b258a.tar.gz chromium_src-0fc4e6ef082e6b6053a3f77932335bcbe59b258a.tar.bz2 |
Make sure events for browser actions, page actions and script badges are not delivered twice.
BUG=124873
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10834393
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152310 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc index be78df2..4badf73 100644 --- a/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.cc @@ -59,12 +59,10 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( extensions::CommandService* command_service = extensions::CommandServiceFactory::GetForProfile(profile_); extensions::CommandMap commands; - if (!command_service->GetNamedCommands( + command_service->GetNamedCommands( extension->id(), extensions::CommandService::ACTIVE_ONLY, - &commands)) { - return; - } + &commands); for (extensions::CommandMap::const_iterator iter = commands.begin(); iter != commands.end(); ++iter) { @@ -108,6 +106,7 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( std::make_pair(extension->id(), browser_action.command_name()); } + // Add the Page Action (if any). extensions::Command page_action; if (command_service->GetPageActionCommand( extension->id(), @@ -121,6 +120,21 @@ void ExtensionKeybindingRegistryGtk::AddExtensionKeybinding( event_targets_[accelerator] = std::make_pair(extension->id(), page_action.command_name()); } + + // Add the Script Badge (if any). + extensions::Command script_badge; + if (command_service->GetScriptBadgeCommand( + extension->id(), + extensions::CommandService::ACTIVE_ONLY, + &script_badge, + NULL)) { + ui::AcceleratorGtk accelerator(script_badge.accelerator().key_code(), + script_badge.accelerator().IsShiftDown(), + script_badge.accelerator().IsCtrlDown(), + script_badge.accelerator().IsAltDown()); + event_targets_[accelerator] = + std::make_pair(extension->id(), script_badge.command_name()); + } } void ExtensionKeybindingRegistryGtk::RemoveExtensionKeybinding( @@ -135,15 +149,13 @@ void ExtensionKeybindingRegistryGtk::RemoveExtensionKeybinding( } // On GTK, unlike Windows, the Event Targets contain all events but we must - // only unregister the ones we own. - if (ShouldIgnoreCommand(iter->second.second)) { - ++iter; - continue; + // only unregister the ones we registered targets for. + if (!ShouldIgnoreCommand(iter->second.second)) { + gtk_accel_group_disconnect_key(accel_group_, + iter->first.GetGdkKeyCode(), + iter->first.gdk_modifier_type()); } - gtk_accel_group_disconnect_key(accel_group_, - iter->first.GetGdkKeyCode(), - iter->first.gdk_modifier_type()); EventTargets::iterator old = iter++; event_targets_.erase(old); } |