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

Unified Diff: chrome/renderer/extensions/event_bindings.cc

Issue 164039: Add module-level permissions to extensions. (Closed)
Patch Set: final nits Created 11 years, 4 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
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/extensions/extension_process_bindings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/event_bindings.cc
diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc
index b44fe82b95d28cbe42a08959f0836df4240b052f..d771580080431abb7b48846899fb010a14d4d9b1 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();
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/extensions/extension_process_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698