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

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

Issue 10914122: Test ActiveTab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
===================================================================
--- chrome/browser/extensions/extension_keybinding_registry.cc (revision 155251)
+++ chrome/browser/extensions/extension_keybinding_registry.cc (working copy)
@@ -4,6 +4,8 @@
#include "chrome/browser/extensions/extension_keybinding_registry.h"
+#include "chrome/browser/extensions/active_tab_permission_manager.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"
@@ -13,8 +15,9 @@
namespace extensions {
-ExtensionKeybindingRegistry::ExtensionKeybindingRegistry(Profile* profile)
- : profile_(profile) {
+ExtensionKeybindingRegistry::ExtensionKeybindingRegistry(Profile* profile,
+ Delegate* delegate)
+ : profile_(profile), delegate_(delegate) {
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile->GetOriginalProfile()));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
@@ -46,6 +49,27 @@
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.
+ ActiveTabPermissionManager* 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/ui/views/browser_actions_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698