From 4ae97b7b61308ab58413c135b4ed70955b698335 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 9 Dec 2014 16:16:04 -0800 Subject: Add frameId option to chrome.tabs.connect and chrome.tabs.sendMessage. BUG=264286 R=kalman@chromium.org,tsepez@chromium.org,sky@chromium.org TEST=browser_tests ExtensionApiTest.Messaging Review URL: https://codereview.chromium.org/758443002 Cr-Commit-Position: refs/heads/master@{#307592} --- extensions/renderer/messaging_bindings.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'extensions/renderer/messaging_bindings.cc') diff --git a/extensions/renderer/messaging_bindings.cc b/extensions/renderer/messaging_bindings.cc index 5a12f71..cb24496 100644 --- a/extensions/renderer/messaging_bindings.cc +++ b/extensions/renderer/messaging_bindings.cc @@ -25,6 +25,7 @@ #include "extensions/renderer/scoped_persistent.h" #include "extensions/renderer/script_context.h" #include "extensions/renderer/script_context_set.h" +#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "third_party/WebKit/public/web/WebScopedUserGesture.h" #include "third_party/WebKit/public/web/WebScopedWindowFocusAllowedIndicator.h" @@ -245,6 +246,14 @@ void DispatchOnConnectToScriptContext( const std::string& tls_channel_id, bool* port_created, ScriptContext* script_context) { + // Only dispatch the events if this is the requested target frame (0 = main + // frame; positive = child frame). + content::RenderFrame* renderframe = script_context->GetRenderFrame(); + if (info.target_frame_id == 0 && renderframe->GetWebFrame()->parent() != NULL) + return; + if (info.target_frame_id > 0 && + renderframe->GetRoutingID() != info.target_frame_id) + return; v8::Isolate* isolate = script_context->isolate(); v8::HandleScope handle_scope(isolate); -- cgit v1.1