summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/extensions/event_bindings.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/renderer/extensions/event_bindings.cc')
-rw-r--r--chrome/renderer/extensions/event_bindings.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc
index b44fe82..d771580 100644
--- a/chrome/renderer/extensions/event_bindings.cc
+++ b/chrome/renderer/extensions/event_bindings.cc
@@ -76,10 +76,20 @@ class ExtensionImpl : public ExtensionBase {
if (args[0]->IsString()) {
std::string event_name(*v8::String::AsciiValue(args[0]));
- if (EventIncrementListenerCount(event_name) == 1) {
+ bool has_permission =
+ ExtensionProcessBindings::CurrentContextHasPermission(event_name);
+
+ // Increment the count even if the caller doesn't have permission, so that
+ // refcounts stay balanced.
+ if (EventIncrementListenerCount(event_name) == 1 && has_permission) {
EventBindings::GetRenderThread()->Send(
new ViewHostMsg_ExtensionAddListener(event_name));
}
+
+ if (!has_permission) {
+ return ExtensionProcessBindings::ThrowPermissionDeniedException(
+ event_name);
+ }
}
return v8::Undefined();