Index: chrome/browser/extensions/api/messaging/message_service.cc |
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc |
index 68fa08626c5da3eff0e0bf84a630f88e16f384fd..f467f630473bf75f1ec4acdf21cd011dacd85a28 100644 |
--- a/chrome/browser/extensions/api/messaging/message_service.cc |
+++ b/chrome/browser/extensions/api/messaging/message_service.cc |
@@ -24,6 +24,7 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/tab_contents/tab_util.h" |
#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/render_frame_host.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/render_widget_host.h" |
@@ -119,6 +120,7 @@ struct MessageService::MessageChannel { |
struct MessageService::OpenChannelParams { |
content::RenderProcessHost* source; |
base::DictionaryValue source_tab; |
+ int source_frame_id; |
scoped_ptr<MessagePort> receiver; |
int receiver_port_id; |
std::string source_extension_id; |
@@ -131,6 +133,7 @@ struct MessageService::OpenChannelParams { |
// Takes ownership of receiver. |
OpenChannelParams(content::RenderProcessHost* source, |
scoped_ptr<base::DictionaryValue> source_tab, |
+ int source_frame_id, |
MessagePort* receiver, |
int receiver_port_id, |
const std::string& source_extension_id, |
@@ -139,6 +142,7 @@ struct MessageService::OpenChannelParams { |
const std::string& channel_name, |
bool include_tls_channel_id) |
: source(source), |
+ source_frame_id(source_frame_id), |
receiver(receiver), |
receiver_port_id(receiver_port_id), |
source_extension_id(source_extension_id), |
@@ -332,15 +336,21 @@ void MessageService::OpenChannelToExtension( |
// Include info about the opener's tab (if it was a tab). |
scoped_ptr<base::DictionaryValue> source_tab; |
+ int source_frame_id = -1; |
if (source_contents && ExtensionTabUtil::GetTabId(source_contents) >= 0) { |
// Only the tab id is useful to platform apps for internal use. The |
// unnecessary bits will be stripped out in |
// MessagingBindings::DispatchOnConnect(). |
source_tab.reset(ExtensionTabUtil::CreateTabValue(source_contents)); |
+ int source_frame_id = source_routing_id; |
not at google - send to devlin
2014/11/11 00:03:04
It looks like this declaration will shadow the dec
robwu
2014/11/11 00:34:26
Done.
|
+ RenderFrameHost* rfh = RenderFrameHost::FromID(source_frame_id, |
+ source_routing_id); |
+ // Main frame's frameId is 0. |
+ source_frame_id = rfh && !rfh.GetParent() ? 0 : source_routing_id; |
not at google - send to devlin
2014/11/11 00:03:04
I would find this a bit easier to read with parens
robwu
2014/11/11 00:34:26
Done.
|
} |
OpenChannelParams* params = new OpenChannelParams( |
- source, source_tab.Pass(), receiver, receiver_port_id, |
+ source, source_tab.Pass(), source_frame_id, receiver, receiver_port_id, |
source_extension_id, target_extension_id, source_url, channel_name, |
include_tls_channel_id); |
@@ -480,6 +490,7 @@ void MessageService::OpenChannelToTab( |
source, |
scoped_ptr<base::DictionaryValue>(), // Source tab doesn't make sense |
// for opening to tabs. |
+ -1, // If there is no tab, then there is no frame either. |
receiver.release(), |
receiver_port_id, |
extension_id, |
@@ -522,6 +533,7 @@ bool MessageService::OpenChannelImpl(scoped_ptr<OpenChannelParams> params) { |
channel->receiver->DispatchOnConnect(params->receiver_port_id, |
params->channel_name, |
params->source_tab, |
+ params->source_frame_id, |
params->source_extension_id, |
params->target_extension_id, |
params->source_url, |