Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3540)

Unified Diff: chrome/browser/extensions/extension_keybinding_registry.cc

Issue 23812010: Implement first part of supporting global extension commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gclient sync Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_keybinding_registry.cc
diff --git a/chrome/browser/extensions/extension_keybinding_registry.cc b/chrome/browser/extensions/extension_keybinding_registry.cc
index 43ad281e21cc895bb49564a39179c0040a214a04..a819ab409c17a2a842b5d4a5249afd2bce7f4be2 100644
--- a/chrome/browser/extensions/extension_keybinding_registry.cc
+++ b/chrome/browser/extensions/extension_keybinding_registry.cc
@@ -34,6 +34,30 @@ ExtensionKeybindingRegistry::ExtensionKeybindingRegistry(
ExtensionKeybindingRegistry::~ExtensionKeybindingRegistry() {
}
+void ExtensionKeybindingRegistry::RemoveExtensionKeybinding(
+ const Extension* extension,
+ const std::string& command_name) {
+ EventTargets::iterator iter = event_targets_.begin();
+ while (iter != event_targets_.end()) {
+ if (iter->second.first != extension->id() ||
+ (!command_name.empty() && (iter->second.second != command_name))) {
+ ++iter;
+ continue; // Not the extension or command we asked for.
+ }
+
+ // Let each platform-specific implementation get a chance to clean up.
+ RemoveExtensionKeybindingImpl(iter->first, command_name);
+
+ EventTargets::iterator old = iter++;
+ event_targets_.erase(old);
+
+ // If a specific command_name was requested, it has now been deleted so
+ // no further work is required.
+ if (!command_name.empty())
+ break;
+ }
+}
+
void ExtensionKeybindingRegistry::Init() {
ExtensionService* service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
@@ -64,9 +88,11 @@ void ExtensionKeybindingRegistry::CommandExecuted(
return;
// Grant before sending the event so that the permission is granted before
- // the extension acts on the command.
+ // the extension acts on the command. NOTE: The Global Commands handler does
+ // not set the delegate as it deals only with named commands (not page/browser
+ // actions that are associated with the current page directly).
ActiveTabPermissionGranter* granter =
- delegate_->GetActiveTabPermissionGranter();
+ delegate_ ? delegate_->GetActiveTabPermissionGranter() : NULL;
if (granter)
granter->GrantIfRequested(extension);
« no previous file with comments | « chrome/browser/extensions/extension_keybinding_registry.h ('k') | chrome/browser/extensions/global_shortcut_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698