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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: rparen Created 5 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "content/common/service_worker/service_worker_types.h" 43 #include "content/common/service_worker/service_worker_types.h"
44 #include "content/common/swapped_out_messages.h" 44 #include "content/common/swapped_out_messages.h"
45 #include "content/common/view_messages.h" 45 #include "content/common/view_messages.h"
46 #include "content/public/common/bindings_policy.h" 46 #include "content/public/common/bindings_policy.h"
47 #include "content/public/common/content_constants.h" 47 #include "content/public/common/content_constants.h"
48 #include "content/public/common/content_switches.h" 48 #include "content/public/common/content_switches.h"
49 #include "content/public/common/context_menu_params.h" 49 #include "content/public/common/context_menu_params.h"
50 #include "content/public/common/isolated_world_ids.h" 50 #include "content/public/common/isolated_world_ids.h"
51 #include "content/public/common/page_state.h" 51 #include "content/public/common/page_state.h"
52 #include "content/public/common/resource_response.h" 52 #include "content/public/common/resource_response.h"
53 #include "content/public/common/site_isolation_policy.h"
53 #include "content/public/common/url_constants.h" 54 #include "content/public/common/url_constants.h"
54 #include "content/public/common/url_utils.h" 55 #include "content/public/common/url_utils.h"
55 #include "content/public/renderer/browser_plugin_delegate.h" 56 #include "content/public/renderer/browser_plugin_delegate.h"
56 #include "content/public/renderer/content_renderer_client.h" 57 #include "content/public/renderer/content_renderer_client.h"
57 #include "content/public/renderer/context_menu_client.h" 58 #include "content/public/renderer/context_menu_client.h"
58 #include "content/public/renderer/document_state.h" 59 #include "content/public/renderer/document_state.h"
59 #include "content/public/renderer/navigation_state.h" 60 #include "content/public/renderer/navigation_state.h"
60 #include "content/public/renderer/render_frame_observer.h" 61 #include "content/public/renderer/render_frame_observer.h"
61 #include "content/public/renderer/renderer_ppapi_host.h" 62 #include "content/public/renderer/renderer_ppapi_host.h"
62 #include "content/renderer/accessibility/renderer_accessibility.h" 63 #include "content/renderer/accessibility/renderer_accessibility.h"
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 return media::Context3D(provider->ContextGL(), provider->GrContext()); 503 return media::Context3D(provider->ContextGL(), provider->GrContext());
503 } 504 }
504 #endif 505 #endif
505 506
506 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { 507 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) {
507 return navigation_type == FrameMsg_Navigate_Type::RELOAD || 508 return navigation_type == FrameMsg_Navigate_Type::RELOAD ||
508 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || 509 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE ||
509 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; 510 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL;
510 } 511 }
511 512
512 bool IsSwappedOutStateForbidden() {
513 return base::CommandLine::ForCurrentProcess()->HasSwitch(
514 switches::kSitePerProcess);
515 }
516
517 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = 513 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl =
518 nullptr; 514 nullptr;
519 515
520 } // namespace 516 } // namespace
521 517
522 // static 518 // static
523 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 519 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
524 int32 routing_id) { 520 int32 routing_id) {
525 DCHECK(routing_id != MSG_ROUTING_NONE); 521 DCHECK(routing_id != MSG_ROUTING_NONE);
526 CreateParams params(render_view, routing_id); 522 CreateParams params(render_view, routing_id);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 blink::WebLocalFrame::create(replicated_state.scope, render_frame); 577 blink::WebLocalFrame::create(replicated_state.scope, render_frame);
582 render_frame->proxy_routing_id_ = proxy_routing_id; 578 render_frame->proxy_routing_id_ = proxy_routing_id;
583 web_frame->initializeToReplaceRemoteFrame( 579 web_frame->initializeToReplaceRemoteFrame(
584 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), 580 proxy->web_frame(), WebString::fromUTF8(replicated_state.name),
585 replicated_state.sandbox_flags); 581 replicated_state.sandbox_flags);
586 } 582 }
587 render_frame->SetWebFrame(web_frame); 583 render_frame->SetWebFrame(web_frame);
588 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); 584 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent());
589 585
590 if (widget_params.routing_id != MSG_ROUTING_NONE) { 586 if (widget_params.routing_id != MSG_ROUTING_NONE) {
591 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 587 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
592 switches::kSitePerProcess));
593 render_frame->render_widget_ = RenderWidget::CreateForFrame( 588 render_frame->render_widget_ = RenderWidget::CreateForFrame(
594 widget_params.routing_id, widget_params.surface_id, 589 widget_params.routing_id, widget_params.surface_id,
595 widget_params.hidden, render_frame->render_view_->screen_info(), 590 widget_params.hidden, render_frame->render_view_->screen_info(),
596 compositor_deps, web_frame); 591 compositor_deps, web_frame);
597 // TODO(kenrb): Observing shouldn't be necessary when we sort out 592 // TODO(kenrb): Observing shouldn't be necessary when we sort out
598 // WasShown and WasHidden, separating page-level visibility from 593 // WasShown and WasHidden, separating page-level visibility from
599 // frame-level visibility. 594 // frame-level visibility.
600 render_frame->render_widget_->RegisterRenderFrame(render_frame); 595 render_frame->render_widget_->RegisterRenderFrame(render_frame);
601 } 596 }
602 597
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct()); 684 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct());
690 685
691 base::trace_event::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_); 686 base::trace_event::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_);
692 687
693 #if defined(VIDEO_HOLE) 688 #if defined(VIDEO_HOLE)
694 if (contains_media_player_) 689 if (contains_media_player_)
695 render_view_->UnregisterVideoHoleFrame(this); 690 render_view_->UnregisterVideoHoleFrame(this);
696 #endif 691 #endif
697 692
698 if (!is_subframe_) { 693 if (!is_subframe_) {
699 if (!IsSwappedOutStateForbidden()) { 694 // When using swapped out frames, RenderFrameProxy is owned by
700 // When using swapped out frames, RenderFrameProxy is "owned" by 695 // RenderFrameImpl in the case it is the main frame. Ensure it is deleted
701 // RenderFrameImpl in the case it is the main frame. Ensure it is deleted 696 // along with this object.
702 // along with this object. 697 if (render_frame_proxy_ &&
703 if (render_frame_proxy_ && 698 !RenderFrameProxy::IsSwappedOutStateForbidden()) {
704 !base::CommandLine::ForCurrentProcess()->HasSwitch( 699 // The following method calls back into this object and clears
705 switches::kSitePerProcess)) { 700 // |render_frame_proxy_|.
706 // The following method calls back into this object and clears 701 render_frame_proxy_->frameDetached(
707 // |render_frame_proxy_|. 702 blink::WebRemoteFrameClient::DetachType::Remove);
708 render_frame_proxy_->frameDetached(
709 blink::WebRemoteFrameClient::DetachType::Remove);
710 }
711 } 703 }
712 704
713 // Ensure the RenderView doesn't point to this object, once it is destroyed. 705 // Ensure the RenderView doesn't point to this object, once it is destroyed.
714 // TODO(nasko): Add a check that the |main_render_frame_| of |render_view_| 706 // TODO(nasko): Add a check that the |main_render_frame_| of |render_view_|
715 // is |this|, once the object is no longer leaked. 707 // is |this|, once the object is no longer leaked.
716 // See https://crbug.com/464764. 708 // See https://crbug.com/464764.
717 render_view_->main_render_frame_ = nullptr; 709 render_view_->main_render_frame_ = nullptr;
718 } 710 }
719 711
720 render_view_->UnregisterRenderFrame(this); 712 render_view_->UnregisterRenderFrame(this);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 before_unload_start_time, 1106 before_unload_start_time,
1115 before_unload_end_time)); 1107 before_unload_end_time));
1116 } 1108 }
1117 1109
1118 void RenderFrameImpl::OnSwapOut( 1110 void RenderFrameImpl::OnSwapOut(
1119 int proxy_routing_id, 1111 int proxy_routing_id,
1120 bool is_loading, 1112 bool is_loading,
1121 const FrameReplicationState& replicated_frame_state) { 1113 const FrameReplicationState& replicated_frame_state) {
1122 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); 1114 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_);
1123 RenderFrameProxy* proxy = NULL; 1115 RenderFrameProxy* proxy = NULL;
1124 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( 1116 bool swapped_out_forbidden = RenderFrameProxy::IsSwappedOutStateForbidden();
1125 switches::kSitePerProcess);
1126 bool is_main_frame = !frame_->parent(); 1117 bool is_main_frame = !frame_->parent();
1127 1118
1128 // This codepath should only be hit for subframes when in --site-per-process. 1119 // This codepath should only be hit for subframes when in --site-per-process.
1129 CHECK_IMPLIES(!is_main_frame, is_site_per_process); 1120 CHECK_IMPLIES(!is_main_frame,
1121 SiteIsolationPolicy::AreCrossProcessFramesPossible());
1130 1122
1131 // Only run unload if we're not swapped out yet, but send the ack either way. 1123 // Only run unload if we're not swapped out yet, but send the ack either way.
1132 if (!is_swapped_out_) { 1124 if (!is_swapped_out_) {
1133 // Swap this RenderFrame out so the frame can navigate to a page rendered by 1125 // Swap this RenderFrame out so the frame can navigate to a page rendered by
1134 // a different process. This involves running the unload handler and 1126 // a different process. This involves running the unload handler and
1135 // clearing the page. We also allow this process to exit if there are no 1127 // clearing the page. We also allow this process to exit if there are no
1136 // other active RenderFrames in it. 1128 // other active RenderFrames in it.
1137 1129
1138 // Send an UpdateState message before we get swapped out. 1130 // Send an UpdateState message before we get swapped out.
1139 render_view_->SyncNavigationState(); 1131 render_view_->SyncNavigationState();
(...skipping 21 matching lines...) Expand all
1161 // willCheckAndDispatchMessageEvent() that needs the proxy. 1153 // willCheckAndDispatchMessageEvent() that needs the proxy.
1162 if (proxy) 1154 if (proxy)
1163 set_render_frame_proxy(proxy); 1155 set_render_frame_proxy(proxy);
1164 1156
1165 // Now that we're swapped out and filtering IPC messages, stop loading to 1157 // Now that we're swapped out and filtering IPC messages, stop loading to
1166 // ensure that no other in-progress navigation continues. We do this here 1158 // ensure that no other in-progress navigation continues. We do this here
1167 // to avoid sending a DidStopLoading message to the browser process. 1159 // to avoid sending a DidStopLoading message to the browser process.
1168 // TODO(creis): Should we be stopping all frames here and using 1160 // TODO(creis): Should we be stopping all frames here and using
1169 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this 1161 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this
1170 // frame? 1162 // frame?
1171 if (!IsSwappedOutStateForbidden()) 1163 if (!swapped_out_forbidden)
1172 OnStop(); 1164 OnStop();
1173 1165
1174 // Transfer settings such as initial drawing parameters to the remote frame, 1166 // Transfer settings such as initial drawing parameters to the remote frame,
1175 // if one is created, that will replace this frame. 1167 // if one is created, that will replace this frame.
1176 if (!is_main_frame && proxy) 1168 if (!is_main_frame && proxy)
1177 proxy->web_frame()->initializeFromFrame(frame_); 1169 proxy->web_frame()->initializeFromFrame(frame_);
1178 1170
1179 // Replace the page with a blank dummy URL. The unload handler will not be 1171 // Replace the page with a blank dummy URL. The unload handler will not be
1180 // run a second time, thanks to a check in FrameLoader::stopLoading. 1172 // run a second time, thanks to a check in FrameLoader::stopLoading.
1181 // TODO(creis): Need to add a better way to do this that avoids running the 1173 // TODO(creis): Need to add a better way to do this that avoids running the
1182 // beforeunload handler. For now, we just run it a second time silently. 1174 // beforeunload handler. For now, we just run it a second time silently.
1183 if (!IsSwappedOutStateForbidden()) 1175 if (!swapped_out_forbidden)
1184 NavigateToSwappedOutURL(); 1176 NavigateToSwappedOutURL();
1185 1177
1186 // Let WebKit know that this view is hidden so it can drop resources and 1178 // Let WebKit know that this view is hidden so it can drop resources and
1187 // stop compositing. 1179 // stop compositing.
1188 // TODO(creis): Support this for subframes as well. 1180 // TODO(creis): Support this for subframes as well.
1189 if (is_main_frame) { 1181 if (is_main_frame) {
1190 render_view_->webview()->setVisibilityState( 1182 render_view_->webview()->setVisibilityState(
1191 blink::WebPageVisibilityStateHidden, false); 1183 blink::WebPageVisibilityStateHidden, false);
1192 } 1184 }
1193 } 1185 }
1194 1186
1195 // It is now safe to show modal dialogs again. 1187 // It is now safe to show modal dialogs again.
1196 // TODO(creis): Deal with modal dialogs from subframes. 1188 // TODO(creis): Deal with modal dialogs from subframes.
1197 if (is_main_frame) 1189 if (is_main_frame)
1198 render_view_->suppress_dialogs_until_swap_out_ = false; 1190 render_view_->suppress_dialogs_until_swap_out_ = false;
1199 1191
1200 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1192 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
1201 1193
1202 RenderViewImpl* render_view = render_view_.get(); 1194 RenderViewImpl* render_view = render_view_.get();
1203 1195
1204 // Now that all of the cleanup is complete and the browser side is notified, 1196 // Now that all of the cleanup is complete and the browser side is notified,
1205 // start using the RenderFrameProxy, if one is created. 1197 // start using the RenderFrameProxy, if one is created.
1206 if (proxy && IsSwappedOutStateForbidden()) { 1198 if (proxy && swapped_out_forbidden) {
1207 frame_->swap(proxy->web_frame()); 1199 frame_->swap(proxy->web_frame());
1208 1200
1209 if (is_loading) 1201 if (is_loading)
1210 proxy->OnDidStartLoading(); 1202 proxy->OnDidStartLoading();
1211 } 1203 }
1212 1204
1213 // In --site-per-process, initialize the WebRemoteFrame with the replication 1205 // In --site-per-process, initialize the WebRemoteFrame with the replication
1214 // state passed by the process that is now rendering the frame. 1206 // state passed by the process that is now rendering the frame.
1215 // TODO(alexmos): We cannot yet do this for swapped-out main frames, because 1207 // TODO(alexmos): We cannot yet do this for swapped-out main frames, because
1216 // in that case we leave the LocalFrame as the main frame visible to Blink 1208 // in that case we leave the LocalFrame as the main frame visible to Blink
1217 // and don't call swap() above. Because swap() is what creates a RemoteFrame 1209 // and don't call swap() above. Because swap() is what creates a RemoteFrame
1218 // in proxy->web_frame(), the RemoteFrame will not exist for main frames. 1210 // in proxy->web_frame(), the RemoteFrame will not exist for main frames.
1219 // When we do an unconditional swap for all frames, we can remove 1211 // When we do an unconditional swap for all frames, we can remove
1220 // !is_main_frame below. 1212 // !is_main_frame below.
1221 if (proxy && IsSwappedOutStateForbidden()) 1213 if (proxy && swapped_out_forbidden)
1222 proxy->SetReplicatedState(replicated_frame_state); 1214 proxy->SetReplicatedState(replicated_frame_state);
1223 1215
1224 // Safe to exit if no one else is using the process. 1216 // Safe to exit if no one else is using the process.
1225 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count 1217 // TODO(nasko): Remove the dependency on RenderViewImpl here and ref count
1226 // the process based on the lifetime of this RenderFrameImpl object. 1218 // the process based on the lifetime of this RenderFrameImpl object.
1227 if (is_main_frame) { 1219 if (is_main_frame) {
1228 render_view->WasSwappedOut(); 1220 render_view->WasSwappedOut();
1229 } 1221 }
1230 } 1222 }
1231 1223
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 // We need to clean up subframes by removing them from the map and deleting 2171 // We need to clean up subframes by removing them from the map and deleting
2180 // the RenderFrameImpl. In contrast, the main frame is owned by its 2172 // the RenderFrameImpl. In contrast, the main frame is owned by its
2181 // containing RenderViewHost (so that they have the same lifetime), so only 2173 // containing RenderViewHost (so that they have the same lifetime), so only
2182 // removal from the map is needed and no deletion. 2174 // removal from the map is needed and no deletion.
2183 FrameMap::iterator it = g_frame_map.Get().find(frame); 2175 FrameMap::iterator it = g_frame_map.Get().find(frame);
2184 CHECK(it != g_frame_map.Get().end()); 2176 CHECK(it != g_frame_map.Get().end());
2185 CHECK_EQ(it->second, this); 2177 CHECK_EQ(it->second, this);
2186 g_frame_map.Get().erase(it); 2178 g_frame_map.Get().erase(it);
2187 2179
2188 if (is_subframe_) { 2180 if (is_subframe_) {
2189 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2181 if (render_widget_) {
2190 switches::kSitePerProcess) && render_widget_) { 2182 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
2191 render_widget_->UnregisterRenderFrame(this); 2183 render_widget_->UnregisterRenderFrame(this);
2192 } 2184 }
2193 2185
2194 // Only remove the frame from the renderer's frame tree if the frame is 2186 // Only remove the frame from the renderer's frame tree if the frame is
2195 // being detached for removal. For swaps, WebFrame::swap already takes care 2187 // being detached for removal. For swaps, WebFrame::swap already takes care
2196 // of replacing the frame with a RemoteFrame. 2188 // of replacing the frame with a RemoteFrame.
2197 if (type == DetachType::Remove) 2189 if (type == DetachType::Remove)
2198 frame->parent()->removeChild(frame); 2190 frame->parent()->removeChild(frame);
2199 } 2191 }
2200 2192
(...skipping 24 matching lines...) Expand all
2225 DCHECK(!frame_ || frame_ == frame); 2217 DCHECK(!frame_ || frame_ == frame);
2226 2218
2227 // TODO(alexmos): According to https://crbug.com/169110, sending window.name 2219 // TODO(alexmos): According to https://crbug.com/169110, sending window.name
2228 // updates may have performance implications for benchmarks like SunSpider. 2220 // updates may have performance implications for benchmarks like SunSpider.
2229 // For now, send these updates only for --site-per-process, which needs to 2221 // For now, send these updates only for --site-per-process, which needs to
2230 // replicate frame names to frame proxies, and when 2222 // replicate frame names to frame proxies, and when
2231 // |report_frame_name_changes| is set (used by <webview>). If needed, this 2223 // |report_frame_name_changes| is set (used by <webview>). If needed, this
2232 // can be optimized further by only sending the update if there are any 2224 // can be optimized further by only sending the update if there are any
2233 // remote frames in the frame tree, or delaying and batching up IPCs if 2225 // remote frames in the frame tree, or delaying and batching up IPCs if
2234 // updates are happening too frequently. 2226 // updates are happening too frequently.
2235 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( 2227 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() ||
2236 switches::kSitePerProcess);
2237 if (is_site_per_process ||
2238 render_view_->renderer_preferences_.report_frame_name_changes) { 2228 render_view_->renderer_preferences_.report_frame_name_changes) {
2239 Send(new FrameHostMsg_DidChangeName(routing_id_, base::UTF16ToUTF8(name))); 2229 Send(new FrameHostMsg_DidChangeName(routing_id_, base::UTF16ToUTF8(name)));
2240 } 2230 }
2241 } 2231 }
2242 2232
2243 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame, 2233 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame,
2244 blink::WebSandboxFlags flags) { 2234 blink::WebSandboxFlags flags) {
2245 int frame_routing_id = MSG_ROUTING_NONE; 2235 int frame_routing_id = MSG_ROUTING_NONE;
2246 if (child_frame->isWebRemoteFrame()) { 2236 if (child_frame->isWebRemoteFrame()) {
2247 frame_routing_id = 2237 frame_routing_id =
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 // In fast/loader/stop-provisional-loads.html, we abort the load before this 2487 // In fast/loader/stop-provisional-loads.html, we abort the load before this
2498 // callback is invoked. 2488 // callback is invoked.
2499 if (!ds) 2489 if (!ds)
2500 return; 2490 return;
2501 2491
2502 TRACE_EVENT2("navigation", "RenderFrameImpl::didStartProvisionalLoad", 2492 TRACE_EVENT2("navigation", "RenderFrameImpl::didStartProvisionalLoad",
2503 "id", routing_id_, "url", ds->request().url().string().utf8()); 2493 "id", routing_id_, "url", ds->request().url().string().utf8());
2504 DocumentState* document_state = DocumentState::FromDataSource(ds); 2494 DocumentState* document_state = DocumentState::FromDataSource(ds);
2505 2495
2506 // We should only navigate to swappedout:// when is_swapped_out_ is true. 2496 // We should only navigate to swappedout:// when is_swapped_out_ is true.
2507 CHECK((ds->request().url() != GURL(kSwappedOutURL)) || 2497 CHECK_IMPLIES(ds->request().url() == GURL(kSwappedOutURL), is_swapped_out_)
2508 is_swapped_out_) << 2498 << "Heard swappedout:// when not swapped out.";
2509 "Heard swappedout:// when not swapped out.";
2510 2499
2511 // Update the request time if WebKit has better knowledge of it. 2500 // Update the request time if WebKit has better knowledge of it.
2512 if (document_state->request_time().is_null() && 2501 if (document_state->request_time().is_null() &&
2513 triggering_event_time != 0.0) { 2502 triggering_event_time != 0.0) {
2514 document_state->set_request_time(Time::FromDoubleT(triggering_event_time)); 2503 document_state->set_request_time(Time::FromDoubleT(triggering_event_time));
2515 } 2504 }
2516 2505
2517 // Start time is only set after request time. 2506 // Start time is only set after request time.
2518 document_state->set_start_load_time(Time::Now()); 2507 document_state->set_start_load_time(Time::Now());
2519 2508
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 3885
3897 params.searchable_form_url = internal_data->searchable_form_url(); 3886 params.searchable_form_url = internal_data->searchable_form_url();
3898 params.searchable_form_encoding = internal_data->searchable_form_encoding(); 3887 params.searchable_form_encoding = internal_data->searchable_form_encoding();
3899 3888
3900 params.gesture = render_view_->navigation_gesture_; 3889 params.gesture = render_view_->navigation_gesture_;
3901 render_view_->navigation_gesture_ = NavigationGestureUnknown; 3890 render_view_->navigation_gesture_ = NavigationGestureUnknown;
3902 3891
3903 // Make navigation state a part of the DidCommitProvisionalLoad message so 3892 // Make navigation state a part of the DidCommitProvisionalLoad message so
3904 // that committed entry has it at all times. 3893 // that committed entry has it at all times.
3905 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry(); 3894 HistoryEntry* entry = render_view_->history_controller()->GetCurrentEntry();
3906 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 3895 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3907 switches::kSitePerProcess)) {
3908 if (entry) 3896 if (entry)
3909 params.page_state = HistoryEntryToPageState(entry); 3897 params.page_state = HistoryEntryToPageState(entry);
3910 else 3898 else
3911 params.page_state = PageState::CreateFromURL(request.url()); 3899 params.page_state = PageState::CreateFromURL(request.url());
3912 } else { 3900 } else {
3913 // In --site-per-process, just send a single HistoryItem for this frame, 3901 // In --site-per-process, just send a single HistoryItem for this frame,
nasko 2015/07/08 12:52:24 Should we be dropping these "In --site-per-process
ncarter (slow) 2015/07/10 23:29:19 I can try, but I didn't want to throw effort at it
3914 // rather than the whole tree. It will be stored in the corresponding 3902 // rather than the whole tree. It will be stored in the corresponding
3915 // FrameNavigationEntry. 3903 // FrameNavigationEntry.
3916 params.page_state = SingleHistoryItemToPageState(item); 3904 params.page_state = SingleHistoryItemToPageState(item);
3917 } 3905 }
3918 params.item_sequence_number = item.itemSequenceNumber(); 3906 params.item_sequence_number = item.itemSequenceNumber();
3919 params.document_sequence_number = item.documentSequenceNumber(); 3907 params.document_sequence_number = item.documentSequenceNumber();
3920 3908
3921 if (!frame->parent()) { 3909 if (!frame->parent()) {
3922 // Top-level navigation. 3910 // Top-level navigation.
3923 3911
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
4153 info.urlRequest, 4141 info.urlRequest,
4154 info.navigationType, 4142 info.navigationType,
4155 info.defaultPolicy, 4143 info.defaultPolicy,
4156 info.isRedirect)) { 4144 info.isRedirect)) {
4157 return blink::WebNavigationPolicyIgnore; 4145 return blink::WebNavigationPolicyIgnore;
4158 } 4146 }
4159 #endif 4147 #endif
4160 4148
4161 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame, 4149 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame,
4162 info.urlRequest)); 4150 info.urlRequest));
4163 const base::CommandLine& command_line =
4164 *base::CommandLine::ForCurrentProcess();
4165 4151
4166 if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe_) { 4152 // TODO(nick): Is consulting |is_subframe_| here correct?
4153 if (RenderFrameProxy::IsSwappedOutStateForbidden() && is_subframe_) {
4167 // There's no reason to ignore navigations on subframes, since the swap out 4154 // There's no reason to ignore navigations on subframes, since the swap out
4168 // logic no longer applies. 4155 // logic no longer applies.
4169 } else { 4156 } else {
4170 if (is_swapped_out_) { 4157 if (is_swapped_out_) {
4171 if (info.urlRequest.url() != GURL(kSwappedOutURL)) { 4158 if (info.urlRequest.url() != GURL(kSwappedOutURL)) {
4172 // Targeted links may try to navigate a swapped out frame. Allow the 4159 // Targeted links may try to navigate a swapped out frame. Allow the
4173 // browser process to navigate the tab instead. Note that it is also 4160 // browser process to navigate the tab instead. Note that it is also
4174 // possible for non-targeted navigations (from this view) to arrive 4161 // possible for non-targeted navigations (from this view) to arrive
4175 // here just after we are swapped out. It's ok to send them to the 4162 // here just after we are swapped out. It's ok to send them to the
4176 // browser, as long as they're for the top level frame. 4163 // browser, as long as they're for the top level frame.
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
4460 scoped_ptr<HistoryEntry> entry = 4447 scoped_ptr<HistoryEntry> entry =
4461 PageStateToHistoryEntry(request_params.page_state); 4448 PageStateToHistoryEntry(request_params.page_state);
4462 if (entry) { 4449 if (entry) {
4463 // Ensure we didn't save the swapped out URL in UpdateState, since the 4450 // Ensure we didn't save the swapped out URL in UpdateState, since the
4464 // browser should never be telling us to navigate to swappedout://. 4451 // browser should never be telling us to navigate to swappedout://.
4465 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 4452 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
4466 4453
4467 if (!browser_side_navigation) { 4454 if (!browser_side_navigation) {
4468 scoped_ptr<NavigationParams> navigation_params( 4455 scoped_ptr<NavigationParams> navigation_params(
4469 new NavigationParams(*pending_navigation_params_.get())); 4456 new NavigationParams(*pending_navigation_params_.get()));
4470 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 4457 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) {
4471 switches::kSitePerProcess)) {
4472 // By default, tell the HistoryController to go the deserialized 4458 // By default, tell the HistoryController to go the deserialized
4473 // HistoryEntry. This only works if all frames are in the same 4459 // HistoryEntry. This only works if all frames are in the same
4474 // process. 4460 // process.
4475 DCHECK(!frame_->parent()); 4461 DCHECK(!frame_->parent());
4476 render_view_->history_controller()->GoToEntry( 4462 render_view_->history_controller()->GoToEntry(
4477 frame_, entry.Pass(), navigation_params.Pass(), cache_policy); 4463 frame_, entry.Pass(), navigation_params.Pass(), cache_policy);
4478 } else { 4464 } else {
4479 // In --site-per-process, the browser process sends a single 4465 // In --site-per-process, the browser process sends a single
4480 // WebHistoryItem destined for this frame. 4466 // WebHistoryItem destined for this frame.
4481 // TODO(creis): Change PageState to FrameState. In the meantime, we 4467 // TODO(creis): Change PageState to FrameState. In the meantime, we
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
5002 cdm_manager_ 4988 cdm_manager_
5003 #endif 4989 #endif
5004 )); 4990 ));
5005 #endif // defined(ENABLE_MOJO_MEDIA) 4991 #endif // defined(ENABLE_MOJO_MEDIA)
5006 } 4992 }
5007 4993
5008 return cdm_factory_.get(); 4994 return cdm_factory_.get();
5009 } 4995 }
5010 4996
5011 } // namespace content 4997 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698