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

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

Issue 8585005: Enable content scripts to receive extension API events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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_event_router.cc
diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc
index 01b7c1bdde77786bdff47fcbc463119691b67c04..73c7db29fce1e9482e15e34aec12c62c4b2c86c0 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -20,11 +20,13 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/api/extension_api.h"
#include "content/browser/child_process_security_policy.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/public/browser/notification_service.h"
using content::BrowserThread;
+using extensions::ExtensionAPI;
namespace {
@@ -274,8 +276,13 @@ void ExtensionEventRouter::DispatchEventImpl(
listener->process->browser_context());
extensions::ProcessMap* process_map =
listener_profile->GetExtensionService()->process_map();
- if (!process_map->Contains(extension->id(), listener->process->id()))
+
+ // If the event is privileged, only send to extension processes. Otherwise,
+ // it's OK to send to normal renderers (e.g., for content scripts).
+ if (ExtensionAPI::GetInstance()->IsPrivileged(event->event_name) &&
+ !process_map->Contains(extension->id(), listener->process->id())) {
continue;
+ }
// Is this event from a different profile than the renderer (ie, an
// incognito tab event sent to a normal process, or vice versa).

Powered by Google App Engine
This is Rietveld 408576698