| Index: chrome/renderer/extensions/extension_custom_bindings.cc
|
| ===================================================================
|
| --- chrome/renderer/extensions/extension_custom_bindings.cc (revision 158832)
|
| +++ chrome/renderer/extensions/extension_custom_bindings.cc (working copy)
|
| @@ -15,6 +15,7 @@
|
| #include "chrome/renderer/extensions/dispatcher.h"
|
| #include "chrome/renderer/extensions/extension_helper.h"
|
| #include "content/public/renderer/render_view.h"
|
| +#include "content/public/renderer/v8_value_converter.h"
|
| #include "grit/renderer_resources.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
| @@ -31,6 +32,7 @@
|
| : ChromeV8Extension(dispatcher) {
|
| RouteStaticFunction("GetExtensionViews", &GetExtensionViews);
|
| RouteStaticFunction("OpenChannelToExtension", &OpenChannelToExtension);
|
| + RouteStaticFunction("OpenChannelToNativeApp", &OpenChannelToNativeApp);
|
| }
|
|
|
| // static
|
| @@ -123,4 +125,36 @@
|
| return v8::Integer::New(port_id);
|
| }
|
|
|
| +// static
|
| +v8::Handle<v8::Value> ExtensionCustomBindings::OpenChannelToNativeApp(
|
| + const v8::Arguments& args) {
|
| + // Get the current RenderView so that we can send a routed IPC message from
|
| + // the correct source.
|
| + content::RenderView* renderview = GetCurrentRenderView();
|
| + if (!renderview)
|
| + return v8::Undefined();
|
| +
|
| + // The Javascript code should validate/fill the arguments.
|
| + CHECK(args.Length() >= 3 &&
|
| + args[0]->IsString() &&
|
| + args[1]->IsString() &&
|
| + args[2]->IsString() &&
|
| + args[3]->IsString());
|
| +
|
| + std::string extension_id = *v8::String::Utf8Value(args[0]->ToString());
|
| + std::string native_app_name = *v8::String::Utf8Value(args[1]->ToString());
|
| + std::string channel_name = *v8::String::Utf8Value(args[2]->ToString());
|
| + std::string connect_message = *v8::String::Utf8Value(args[3]->ToString());
|
| +
|
| + int port_id = -1;
|
| + renderview->Send(new ExtensionHostMsg_OpenChannelToNativeApp(
|
| + renderview->GetRoutingID(),
|
| + extension_id,
|
| + native_app_name,
|
| + channel_name,
|
| + connect_message,
|
| + &port_id));
|
| + return v8::Integer::New(port_id);
|
| +}
|
| +
|
| } // namespace extensions
|
|
|