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

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

Issue 12300041: Add nativeMessaging extension permission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/renderer/extensions/runtime_custom_bindings.cc
diff --git a/chrome/renderer/extensions/runtime_custom_bindings.cc b/chrome/renderer/extensions/runtime_custom_bindings.cc
index 211ad62ebd65082784a7bfc48976424647670f34..b775d49e7c69b4a1c676ee9e62df67efff586b18 100644
--- a/chrome/renderer/extensions/runtime_custom_bindings.cc
+++ b/chrome/renderer/extensions/runtime_custom_bindings.cc
@@ -11,6 +11,7 @@
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/renderer/extensions/chrome_v8_context.h"
+#include "chrome/renderer/extensions/dispatcher.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/v8_value_converter.h"
@@ -18,12 +19,16 @@ using content::V8ValueConverter;
namespace extensions {
-RuntimeCustomBindings::RuntimeCustomBindings(ChromeV8Context* context)
- : ChromeV8Extension(NULL), context_(context) {
+RuntimeCustomBindings::RuntimeCustomBindings(Dispatcher* dispatcher,
+ ChromeV8Context* context)
+ : ChromeV8Extension(dispatcher), context_(context) {
RouteFunction("GetManifest",
- base::Bind(&RuntimeCustomBindings::GetManifest, base::Unretained(this)));
+ base::Bind(&RuntimeCustomBindings::GetManifest,
+ base::Unretained(this)));
RouteStaticFunction("OpenChannelToExtension", &OpenChannelToExtension);
- RouteStaticFunction("OpenChannelToNativeApp", &OpenChannelToNativeApp);
+ RouteFunction("OpenChannelToNativeApp",
+ base::Bind(&RuntimeCustomBindings::OpenChannelToNativeApp,
+ base::Unretained(this)));
}
RuntimeCustomBindings::~RuntimeCustomBindings() {}
@@ -56,9 +61,14 @@ v8::Handle<v8::Value> RuntimeCustomBindings::OpenChannelToExtension(
return v8::Integer::New(port_id);
}
-// static
v8::Handle<v8::Value> RuntimeCustomBindings::OpenChannelToNativeApp(
const v8::Arguments& args) {
+ // Verify that the extension has permission to use native messaging.
+ if (!dispatcher()->CheckCurrentContextAccessToExtensionAPI(
+ "nativeMessaging")) {
+ return v8::Undefined();
+ }
+
// Get the current RenderView so that we can send a routed IPC message from
// the correct source.
content::RenderView* renderview = GetCurrentRenderView();

Powered by Google App Engine
This is Rietveld 408576698