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

Side by Side 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: No need to rename addEventListener/removeEventListener 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 // It is possible to receive it from one that has just been swapped in, 3006 // It is possible to receive it from one that has just been swapped in,
3007 // in which case we might as well deliver the message anyway. 3007 // in which case we might as well deliver the message anyway.
3008 if (rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) 3008 if (rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance()))
3009 GetRenderViewHost()->ClosePage(); 3009 GetRenderViewHost()->ClosePage();
3010 } 3010 }
3011 3011
3012 void WebContentsImpl::RouteMessageEvent( 3012 void WebContentsImpl::RouteMessageEvent(
3013 RenderViewHost* rvh, 3013 RenderViewHost* rvh,
3014 const ViewMsg_PostMessage_Params& params) { 3014 const ViewMsg_PostMessage_Params& params) {
3015 // Only deliver the message to the active RenderViewHost if the request 3015 // Only deliver the message to the active RenderViewHost if the request
3016 // came from a RenderViewHost in the same BrowsingInstance. 3016 // came from a RenderViewHost in the same BrowsingInstance or this WebContents
3017 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) 3017 // is dedicated to a browser plugin guest.
Charlie Reis 2012/10/12 00:31:43 nit: or if This check isn't quite right, but I'm
Fady Samuel 2012/10/12 18:07:53 Done.
3018 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance()) &&
3019 !GetBrowserPluginGuest() && !GetBrowserPluginEmbedder())
3018 return; 3020 return;
3019 3021
3020 ViewMsg_PostMessage_Params new_params(params); 3022 ViewMsg_PostMessage_Params new_params(params);
3021 3023
3022 // If the renderer has changed while the post message is being routed, 3024 // If the renderer has changed while the post message is being routed,
3023 // drop the message, as it will not be delivered to the right target. 3025 // drop the message, as it will not be delivered to the right target.
3024 // TODO(nasko): Check for process ID and target frame id mismatch, once 3026 // TODO(nasko): Check for process ID and target frame id mismatch, once
3025 // http://crbug.com/153701 is fixed. 3027 // http://crbug.com/153701 is fixed.
3026 3028
3027 // If there is a source_routing_id, translate it to the routing ID for 3029 // If there is a source_routing_id, translate it to the routing ID for
3028 // the equivalent swapped out RVH in the target process. If we need 3030 // the equivalent swapped out RVH in the target process. If we need
3029 // to create a swapped out RVH for the source tab, we create its opener 3031 // to create a swapped out RVH for the source tab, we create its opener
3030 // chain as well, since those will also be accessible to the target page. 3032 // chain as well, since those will also be accessible to the target page.
3031 if (new_params.source_routing_id != MSG_ROUTING_NONE) { 3033 if (new_params.source_routing_id != MSG_ROUTING_NONE) {
3032 // Try to look up the WebContents for the source page. 3034 // Try to look up the WebContents for the source page.
3033 WebContentsImpl* source_contents = NULL; 3035 WebContentsImpl* source_contents = NULL;
3034 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID( 3036 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID(
3035 rvh->GetProcess()->GetID(), params.source_routing_id); 3037 rvh->GetProcess()->GetID(), params.source_routing_id);
3036 if (source_rvh) { 3038 if (source_rvh) {
3037 source_contents = static_cast<WebContentsImpl*>( 3039 source_contents = static_cast<WebContentsImpl*>(
3038 source_rvh->GetDelegate()->GetAsWebContents()); 3040 source_rvh->GetDelegate()->GetAsWebContents());
3039 } 3041 }
3040 3042
3041 if (source_contents) { 3043 if (source_contents) {
3042 new_params.source_routing_id = 3044 if (GetBrowserPluginGuest()) {
3043 source_contents->CreateOpenerRenderViews(GetSiteInstance()); 3045 new_params.source_routing_id =
Charlie Reis 2012/10/12 00:31:43 Please mention that we create a swapped out RV for
Fady Samuel 2012/10/12 18:07:53 Done.
3046 source_contents->CreateSwappedOutRenderView(GetSiteInstance());
3047 } else {
3048 new_params.source_routing_id =
3049 source_contents->CreateOpenerRenderViews(GetSiteInstance());
3050 }
3044 } else { 3051 } else {
3045 // We couldn't find it, so don't pass a source frame. 3052 // We couldn't find it, so don't pass a source frame.
3046 new_params.source_routing_id = MSG_ROUTING_NONE; 3053 new_params.source_routing_id = MSG_ROUTING_NONE;
3047 } 3054 }
3048 } 3055 }
3049 3056
3050 // In most cases, we receive this from a swapped out RenderViewHost. 3057 // In most cases, we receive this from a swapped out RenderViewHost.
3051 // It is possible to receive it from one that has just been swapped in, 3058 // It is possible to receive it from one that has just been swapped in,
3052 // in which case we might as well deliver the message anyway. 3059 // in which case we might as well deliver the message anyway.
3053 Send(new ViewMsg_PostMessageEvent(GetRoutingID(), new_params)); 3060 Send(new ViewMsg_PostMessageEvent(GetRoutingID(), new_params));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 } 3143 }
3137 3144
3138 WebPreferences WebContentsImpl::GetWebkitPrefs() { 3145 WebPreferences WebContentsImpl::GetWebkitPrefs() {
3139 // We want to base the page config off of the real URL, rather than the 3146 // We want to base the page config off of the real URL, rather than the
3140 // display URL. 3147 // display URL.
3141 GURL url = controller_.GetActiveEntry() 3148 GURL url = controller_.GetActiveEntry()
3142 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); 3149 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL();
3143 return GetWebkitPrefs(GetRenderViewHost(), url); 3150 return GetWebkitPrefs(GetRenderViewHost(), url);
3144 } 3151 }
3145 3152
3153 int WebContentsImpl::CreateSwappedOutRenderView(
3154 content::SiteInstance* instance) {
3155 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true);
3156 }
3157
3146 void WebContentsImpl::OnUserGesture() { 3158 void WebContentsImpl::OnUserGesture() {
3147 // Notify observers. 3159 // Notify observers.
3148 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); 3160 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture());
3149 3161
3150 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 3162 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
3151 if (rdh) // NULL in unittests. 3163 if (rdh) // NULL in unittests.
3152 rdh->OnUserGesture(this); 3164 rdh->OnUserGesture(this);
3153 } 3165 }
3154 3166
3155 void WebContentsImpl::OnIgnoredUIEvent() { 3167 void WebContentsImpl::OnIgnoredUIEvent() {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
3415 } 3427 }
3416 } 3428 }
3417 3429
3418 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { 3430 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3419 return browser_plugin_guest_.get(); 3431 return browser_plugin_guest_.get();
3420 } 3432 }
3421 3433
3422 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { 3434 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
3423 return browser_plugin_embedder_.get(); 3435 return browser_plugin_embedder_.get();
3424 } 3436 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698