| Index: chrome/renderer/extensions/messaging_bindings.cc
|
| ===================================================================
|
| --- chrome/renderer/extensions/messaging_bindings.cc (revision 246091)
|
| +++ chrome/renderer/extensions/messaging_bindings.cc (working copy)
|
| @@ -23,6 +23,7 @@
|
| #include "chrome/renderer/extensions/chrome_v8_extension.h"
|
| #include "chrome/renderer/extensions/dispatcher.h"
|
| #include "chrome/renderer/extensions/event_bindings.h"
|
| +#include "chrome/renderer/extensions/media_galleries_custom_bindings.h"
|
| #include "chrome/renderer/extensions/scoped_persistent.h"
|
| #include "content/public/renderer/render_thread.h"
|
| #include "content/public/renderer/render_view.h"
|
| @@ -47,6 +48,8 @@
|
| using content::RenderThread;
|
| using content::V8ValueConverter;
|
|
|
| +namespace extensions {
|
| +
|
| namespace {
|
|
|
| struct ExtensionData {
|
| @@ -77,13 +80,14 @@
|
| const char kReceivingEndDoesntExistError[] =
|
| "Could not establish connection. Receiving end does not exist.";
|
|
|
| -class ExtensionImpl : public extensions::ChromeV8Extension {
|
| +class ExtensionImpl : public ChromeV8Extension {
|
| public:
|
| - explicit ExtensionImpl(extensions::Dispatcher* dispatcher,
|
| - extensions::ChromeV8Context* context)
|
| - : extensions::ChromeV8Extension(dispatcher, context) {
|
| + ExtensionImpl(Dispatcher* dispatcher, ChromeV8Context* context)
|
| + : ChromeV8Extension(dispatcher, context) {
|
| RouteFunction("CloseChannel",
|
| base::Bind(&ExtensionImpl::CloseChannel, base::Unretained(this)));
|
| + RouteFunction("GetSenderTabId",
|
| + base::Bind(&ExtensionImpl::GetSenderTabId, base::Unretained(this)));
|
| RouteFunction("PortAddRef",
|
| base::Bind(&ExtensionImpl::PortAddRef, base::Unretained(this)));
|
| RouteFunction("PortRelease",
|
| @@ -117,9 +121,8 @@
|
|
|
| renderview->Send(new ExtensionHostMsg_PostMessage(
|
| renderview->GetRoutingID(), port_id,
|
| - extensions::Message(
|
| - *v8::String::Utf8Value(args[1]),
|
| - blink::WebUserGestureIndicator::isProcessingUserGesture())));
|
| + Message(*v8::String::Utf8Value(args[1]),
|
| + blink::WebUserGestureIndicator::isProcessingUserGesture())));
|
| }
|
|
|
| // Forcefully disconnects a port.
|
| @@ -210,8 +213,8 @@
|
| callback->Call(context->Global(), 0, NULL);
|
| }
|
|
|
| - extensions::ScopedPersistent<v8::Object> object_;
|
| - extensions::ScopedPersistent<v8::Function> callback_;
|
| + ScopedPersistent<v8::Object> object_;
|
| + ScopedPersistent<v8::Function> callback_;
|
| v8::Isolate* isolate_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(GCCallback);
|
| @@ -228,12 +231,15 @@
|
| args[1].As<v8::Function>(),
|
| args.GetIsolate());
|
| }
|
| +
|
| + void GetSenderTabId(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| + CHECK_EQ(0, args.Length());
|
| + args.GetReturnValue().Set(dispatcher()->request_sender()->sender_tab_id());
|
| + }
|
| };
|
|
|
| } // namespace
|
|
|
| -namespace extensions {
|
| -
|
| ChromeV8Extension* MessagingBindings::Get(
|
| Dispatcher* dispatcher,
|
| ChromeV8Context* context) {
|
| @@ -272,7 +278,7 @@
|
| continue;
|
|
|
| v8::Handle<v8::Value> tab = v8::Null(isolate);
|
| - if (!source_tab.empty())
|
| + if (!source_tab.empty() && !(*it)->extension()->is_platform_app())
|
| tab = converter->ToV8Value(&source_tab, (*it)->v8_context());
|
|
|
| v8::Handle<v8::Value> tls_channel_id_value = v8::Undefined(isolate);
|
| @@ -290,23 +296,31 @@
|
| }
|
|
|
| v8::Handle<v8::Value> arguments[] = {
|
| + // portId
|
| v8::Integer::New(isolate, target_port_id),
|
| + // channelName
|
| v8::String::NewFromUtf8(isolate,
|
| channel_name.c_str(),
|
| v8::String::kNormalString,
|
| channel_name.size()),
|
| - tab, v8::String::NewFromUtf8(isolate,
|
| - source_extension_id.c_str(),
|
| - v8::String::kNormalString,
|
| - source_extension_id.size()),
|
| + // sourceTab
|
| + tab,
|
| + // sourceExtensionId
|
| v8::String::NewFromUtf8(isolate,
|
| + source_extension_id.c_str(),
|
| + v8::String::kNormalString,
|
| + source_extension_id.size()),
|
| + // targetExtensionId
|
| + v8::String::NewFromUtf8(isolate,
|
| target_extension_id.c_str(),
|
| v8::String::kNormalString,
|
| target_extension_id.size()),
|
| + // sourceUrl
|
| v8::String::NewFromUtf8(isolate,
|
| source_url_spec.c_str(),
|
| v8::String::kNormalString,
|
| source_url_spec.size()),
|
| + // tlsChannelId
|
| tls_channel_id_value,
|
| };
|
|
|
|
|