Index: content/browser/web_contents/web_contents_impl.cc |
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
index 1f0df0e0f11ba4d055dd7c2333145f1b3da05ed3..cc8336f64a23d19708fe1cdd7baddadcf0072ae9 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -3002,8 +3002,14 @@ void WebContentsImpl::RouteMessageEvent( |
RenderViewHost* rvh, |
const ViewMsg_PostMessage_Params& params) { |
// Only deliver the message to the active RenderViewHost if the request |
- // came from a RenderViewHost in the same BrowsingInstance. |
- if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) |
+ // came from a RenderViewHost in the same BrowsingInstance or if this |
+ // WebContents is dedicated to a browser plugin guest. |
+ // Note: This check means that an embedder could theoretically receive a |
+ // postMessage from anyone (not just its own guests). However, this is |
+ // probably not a risk for apps since other pages won't have references |
+ // to App windows. |
+ if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance()) && |
+ !GetBrowserPluginGuest() && !GetBrowserPluginEmbedder()) |
return; |
ViewMsg_PostMessage_Params new_params(params); |
@@ -3028,8 +3034,16 @@ void WebContentsImpl::RouteMessageEvent( |
} |
if (source_contents) { |
- new_params.source_routing_id = |
- source_contents->CreateOpenerRenderViews(GetSiteInstance()); |
+ // We create a swapped out RenderView for the embedder in the guest's |
+ // render process but we intentionally do not expose the embedder's |
+ // opener chain to it. |
Charlie Reis
2012/10/15 23:10:09
nit: Move this below the if statement (which will
Fady Samuel
2012/10/16 19:17:08
Done. Wow, I don't know what happened there. Dysle
|
+ if (GetBrowserPluginGuest()) { |
+ new_params.source_routing_id = |
+ source_contents->CreateSwappedOutRenderView(GetSiteInstance()); |
+ } else { |
+ new_params.source_routing_id = |
+ source_contents->CreateOpenerRenderViews(GetSiteInstance()); |
+ } |
} else { |
// We couldn't find it, so don't pass a source frame. |
new_params.source_routing_id = MSG_ROUTING_NONE; |
@@ -3132,6 +3146,11 @@ WebPreferences WebContentsImpl::GetWebkitPrefs() { |
return GetWebkitPrefs(GetRenderViewHost(), url); |
} |
+int WebContentsImpl::CreateSwappedOutRenderView( |
+ content::SiteInstance* instance) { |
+ return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true); |
+} |
+ |
void WebContentsImpl::OnUserGesture() { |
// Notify observers. |
FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |