| Index: content/renderer/render_frame_impl.cc
|
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
|
| index dba08879cc19cf0a3e307cf328ec37b9a2f3803e..66d36833589c6404bf2551d9db644459000a1797 100644
|
| --- a/content/renderer/render_frame_impl.cc
|
| +++ b/content/renderer/render_frame_impl.cc
|
| @@ -72,6 +72,7 @@
|
| #include "content/renderer/notification_provider.h"
|
| #include "content/renderer/npapi/plugin_channel_host.h"
|
| #include "content/renderer/push_messaging_dispatcher.h"
|
| +#include "content/renderer/render_frame_proxy.h"
|
| #include "content/renderer/render_process.h"
|
| #include "content/renderer/render_thread_impl.h"
|
| #include "content/renderer/render_view_impl.h"
|
| @@ -366,10 +367,31 @@ RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) {
|
| }
|
|
|
| // static
|
| +void RenderFrameImpl::CreateFrame(int routing_id, int parent_routing_id) {
|
| + CHECK_NE(MSG_ROUTING_NONE, parent_routing_id);
|
| +
|
| + RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(parent_routing_id);
|
| +
|
| + // If the browser is sending a valid parent routing id, it better be created
|
| + // and registered.
|
| + CHECK(proxy);
|
| + blink::WebRemoteFrame* parent_web_frame = proxy->web_frame();
|
| +
|
| + // Create the RenderFrame and WebLocalFrame, linking the two.
|
| + RenderFrameImpl* render_frame =
|
| + RenderFrameImpl::Create(proxy->render_view(), routing_id);
|
| + blink::WebLocalFrame* web_frame =
|
| + parent_web_frame->createLocalChild("", render_frame);
|
| + render_frame->SetWebFrame(web_frame);
|
| + render_frame->Initialize();
|
| +}
|
| +
|
| +// static
|
| RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) {
|
| return RenderFrameImpl::FromWebFrame(web_frame);
|
| }
|
|
|
| +// static
|
| RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) {
|
| FrameMap::iterator iter = g_frame_map.Get().find(web_frame);
|
| if (iter != g_frame_map.Get().end())
|
| @@ -664,11 +686,13 @@ bool RenderFrameImpl::Send(IPC::Message* message) {
|
| delete message;
|
| return false;
|
| }
|
| - if (is_swapped_out_ || render_view_->is_swapped_out()) {
|
| + if (frame_->parent() == NULL &&
|
| + (is_swapped_out_ || render_view_->is_swapped_out())) {
|
| if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) {
|
| delete message;
|
| return false;
|
| }
|
| +
|
| // In most cases, send IPCs through the proxy when swapped out. In some
|
| // calls the associated RenderViewImpl routing id is used to send
|
| // messages, so don't use the proxy.
|
| @@ -680,7 +704,8 @@ bool RenderFrameImpl::Send(IPC::Message* message) {
|
| }
|
|
|
| bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
|
| - GetContentClient()->SetActiveURL(frame_->document().url());
|
| + if (!frame_->document().isNull())
|
| + GetContentClient()->SetActiveURL(frame_->document().url());
|
|
|
| ObserverListBase<RenderFrameObserver>::Iterator it(observers_);
|
| RenderFrameObserver* observer;
|
| @@ -749,7 +774,8 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
|
| return;
|
|
|
| // Swap this renderer back in if necessary.
|
| - if (render_view_->is_swapped_out_) {
|
| + if (render_view_->is_swapped_out_ &&
|
| + GetWebFrame() == render_view_->webview()->mainFrame()) {
|
| // We marked the view as hidden when swapping the view out, so be sure to
|
| // reset the visibility state before navigating to the new URL.
|
| render_view_->webview()->setVisibilityState(
|
| @@ -942,6 +968,8 @@ void RenderFrameImpl::OnBeforeUnload() {
|
|
|
| void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
|
| RenderFrameProxy* proxy = NULL;
|
| + bool is_site_per_process =
|
| + CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess);
|
|
|
| // Only run unload if we're not swapped out yet, but send the ack either way.
|
| if (!is_swapped_out_ || !render_view_->is_swapped_out_) {
|
| @@ -954,7 +982,8 @@ void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
|
| // RenderFrameProxy as well so its routing id is registered for receiving
|
| // IPC messages.
|
| render_view_->SyncNavigationState();
|
| - proxy = RenderFrameProxy::CreateFrameProxy(proxy_routing_id, routing_id_);
|
| + proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this,
|
| + proxy_routing_id);
|
|
|
| // Synchronously run the unload handler before sending the ACK.
|
| // TODO(creis): Call dispatchUnloadEvent unconditionally here to support
|
| @@ -987,7 +1016,8 @@ void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
|
| // run a second time, thanks to a check in FrameLoader::stopLoading.
|
| // TODO(creis): Need to add a better way to do this that avoids running the
|
| // beforeunload handler. For now, we just run it a second time silently.
|
| - render_view_->NavigateToSwappedOutURL(frame_);
|
| + if (!is_site_per_process || frame_->parent() == NULL)
|
| + render_view_->NavigateToSwappedOutURL(frame_);
|
|
|
| // Let WebKit know that this view is hidden so it can drop resources and
|
| // stop compositing.
|
| @@ -1007,8 +1037,17 @@ void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
|
|
|
| // Now that all of the cleanup is complete and the browser side is notified,
|
| // start using the RenderFrameProxy, if one is created.
|
| - if (proxy)
|
| - set_render_frame_proxy(proxy);
|
| + if (proxy) {
|
| + if (frame_->parent()) {
|
| + frame_->swap(proxy->web_frame());
|
| + if (is_site_per_process) {
|
| + // TODO(nasko): delete the frame here, since we've replaced it with a
|
| + // proxy.
|
| + }
|
| + } else {
|
| + set_render_frame_proxy(proxy);
|
| + }
|
| + }
|
| }
|
|
|
| void RenderFrameImpl::OnContextMenuClosed(
|
| @@ -1659,6 +1698,7 @@ void RenderFrameImpl::loadURLExternally(
|
| blink::WebNavigationPolicy policy,
|
| const blink::WebString& suggested_name) {
|
| DCHECK(!frame_ || frame_ == frame);
|
| +
|
| Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
|
| if (policy == blink::WebNavigationPolicyDownload) {
|
| render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
|
| @@ -1681,8 +1721,9 @@ blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
|
| blink::WebNavigationPolicy default_policy,
|
| bool is_redirect) {
|
| DCHECK(!frame_ || frame_ == frame);
|
| - return DecidePolicyForNavigation(
|
| + WebNavigationPolicy value = DecidePolicyForNavigation(
|
| this, frame, extra_data, request, type, default_policy, is_redirect);
|
| + return value;
|
| }
|
|
|
| blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame(
|
| @@ -1787,8 +1828,8 @@ void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) {
|
| DidStartProvisionalLoad(frame));
|
| FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
|
|
|
| - Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(routing_id_,
|
| - ds->request().url()));
|
| + Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
|
| + routing_id_, ds->request().url()));
|
| }
|
|
|
| void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
|
| @@ -2357,13 +2398,19 @@ void RenderFrameImpl::willSendRequest(
|
| if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame) {
|
| request.setFirstPartyForCookies(request.url());
|
| } else {
|
| - request.setFirstPartyForCookies(
|
| - frame->top()->document().firstPartyForCookies());
|
| + // TODO(nasko): When the top-level frame is remote, there is no document.
|
| + // This is broken and should be fixed to propagate the URL.
|
| + WebFrame* top = frame->top();
|
| + if (top->isWebLocalFrame()) {
|
| + request.setFirstPartyForCookies(
|
| + frame->top()->document().firstPartyForCookies());
|
| + }
|
| }
|
| }
|
|
|
| WebFrame* top_frame = frame->top();
|
| - if (!top_frame)
|
| + // TODO(nasko): Hack around asking about top-frame data source.
|
| + if (!top_frame || top_frame->isWebRemoteFrame())
|
| top_frame = frame;
|
| WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
|
| WebDataSource* top_data_source = top_frame->dataSource();
|
| @@ -2460,8 +2507,16 @@ void RenderFrameImpl::willSendRequest(
|
| provider_id = provider->provider_id();
|
| }
|
|
|
| - int parent_routing_id = frame->parent() ?
|
| - FromWebFrame(frame->parent())->GetRoutingID() : -1;
|
| + WebFrame* parent = frame->parent();
|
| + int parent_routing_id = MSG_ROUTING_NONE;
|
| + if (!parent) {
|
| + parent_routing_id = -1;
|
| + } else if (parent->isWebLocalFrame()) {
|
| + parent_routing_id = FromWebFrame(parent)->GetRoutingID();
|
| + } else {
|
| + parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id();
|
| + }
|
| +
|
| RequestExtraData* extra_data = new RequestExtraData();
|
| extra_data->set_visibility_state(render_view_->visibilityState());
|
| extra_data->set_custom_user_agent(custom_user_agent);
|
| @@ -3160,28 +3215,35 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
|
| #endif
|
|
|
| Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
|
| + const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
|
|
| - if (is_swapped_out_ || render_view_->is_swapped_out()) {
|
| - if (request.url() != GURL(kSwappedOutURL)) {
|
| - // Targeted links may try to navigate a swapped out frame. Allow the
|
| - // browser process to navigate the tab instead. Note that it is also
|
| - // possible for non-targeted navigations (from this view) to arrive
|
| - // here just after we are swapped out. It's ok to send them to the
|
| - // browser, as long as they're for the top level frame.
|
| - // TODO(creis): Ensure this supports targeted form submissions when
|
| - // fixing http://crbug.com/101395.
|
| - if (frame->parent() == NULL) {
|
| - OpenURL(frame, request.url(), referrer, default_policy);
|
| - return blink::WebNavigationPolicyIgnore; // Suppress the load here.
|
| + bool is_subframe = !!frame->parent();
|
| +
|
| + if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe) {
|
| + // There's no reason to ignore navigations on subframes (why again?)
|
| + } else {
|
| + if (is_swapped_out_ || render_view_->is_swapped_out()) {
|
| + if (request.url() != GURL(kSwappedOutURL)) {
|
| + // Targeted links may try to navigate a swapped out frame. Allow the
|
| + // browser process to navigate the tab instead. Note that it is also
|
| + // possible for non-targeted navigations (from this view) to arrive
|
| + // here just after we are swapped out. It's ok to send them to the
|
| + // browser, as long as they're for the top level frame.
|
| + // TODO(creis): Ensure this supports targeted form submissions when
|
| + // fixing http://crbug.com/101395.
|
| + if (frame->parent() == NULL) {
|
| + OpenURL(frame, request.url(), referrer, default_policy);
|
| + return blink::WebNavigationPolicyIgnore; // Suppress the load here.
|
| + }
|
| +
|
| + // We should otherwise ignore in-process iframe navigations, if they
|
| + // arrive just after we are swapped out.
|
| + return blink::WebNavigationPolicyIgnore;
|
| }
|
|
|
| - // We should otherwise ignore in-process iframe navigations, if they
|
| - // arrive just after we are swapped out.
|
| - return blink::WebNavigationPolicyIgnore;
|
| + // Allow kSwappedOutURL to complete.
|
| + return default_policy;
|
| }
|
| -
|
| - // Allow kSwappedOutURL to complete.
|
| - return default_policy;
|
| }
|
|
|
| // Webkit is asking whether to navigate to a new URL.
|
| @@ -3199,7 +3261,6 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
|
| // all top-level navigations to the browser to let it swap processes when
|
| // crossing site boundaries. This is currently expected to break some script
|
| // calls and navigations, such as form submissions.
|
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
| bool force_swap_due_to_flag =
|
| command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
|
| command_line.HasSwitch(switches::kSitePerProcess);
|
|
|