Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/browser_plugin_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a022e79e95287f0bfdd6b51eb19fb1ed3af0f8fb..a4040938fb79ffb83cb2ee1e5437548b0d62e288 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3005,8 +3005,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);
@@ -3031,8 +3037,16 @@ void WebContentsImpl::RouteMessageEvent(
}
if (source_contents) {
- new_params.source_routing_id =
- source_contents->CreateOpenerRenderViews(GetSiteInstance());
+ if (GetBrowserPluginGuest()) {
+ // 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.
+ 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;
@@ -3135,6 +3149,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());
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/browser_plugin_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698