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

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

Issue 10880064: Make extension commands grant the activeTab permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 3 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 1603851127ece69e03c682b63afd3ad7e05cebe4..713077094b8ae9ee1f3d7e8b4387544d1f4e34c3 100644
--- a/chrome/browser/extensions/extension_keybinding_registry.cc
+++ b/chrome/browser/extensions/extension_keybinding_registry.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/extensions/extension_keybinding_registry.h"
+#include "chrome/browser/extensions/active_tab_permission_granter.h"
+#include "chrome/browser/extensions/browser_event_router.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
@@ -14,8 +16,10 @@
namespace extensions {
ExtensionKeybindingRegistry::ExtensionKeybindingRegistry(
- Profile* profile, ExtensionFilter extension_filter)
- : profile_(profile), extension_filter_(extension_filter) {
+ Profile* profile, ExtensionFilter extension_filter, Delegate* delegate)
+ : profile_(profile),
+ extension_filter_(extension_filter),
+ delegate_(delegate) {
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile->GetOriginalProfile()));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
@@ -48,6 +52,27 @@ bool ExtensionKeybindingRegistry::ShouldIgnoreCommand(
command == extension_manifest_values::kScriptBadgeCommandEvent;
}
+void ExtensionKeybindingRegistry::CommandExecuted(
+ const std::string& extension_id, const std::string& command) {
+ ExtensionService* service =
+ ExtensionSystem::Get(profile_)->extension_service();
+
+ const Extension* extension = service->extensions()->GetByID(extension_id);
+ if (!extension)
+ return;
+
+ // Grant before sending the event so that the permission is granted before
+ // the extension acts on the command.
+ ActiveTabPermissionGranter* granter =
+ delegate_->GetActiveTabPermissionGranter();
+ if (granter)
+ granter->GrantIfRequested(extension);
+
+ service->browser_event_router()->CommandExecuted(profile_,
+ extension_id,
+ command);
+}
+
void ExtensionKeybindingRegistry::Observe(
int type,
const content::NotificationSource& source,
« no previous file with comments | « chrome/browser/extensions/extension_keybinding_registry.h ('k') | chrome/browser/extensions/extension_toolbar_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698