OLD | NEW |
---|---|
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 16 matching lines...) Expand all Loading... | |
27 #include "content/child/service_worker/service_worker_network_provider.h" | 27 #include "content/child/service_worker/service_worker_network_provider.h" |
28 #include "content/child/service_worker/service_worker_provider_context.h" | 28 #include "content/child/service_worker/service_worker_provider_context.h" |
29 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 29 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
30 #include "content/child/web_url_loader_impl.h" | 30 #include "content/child/web_url_loader_impl.h" |
31 #include "content/child/web_url_request_util.h" | 31 #include "content/child/web_url_request_util.h" |
32 #include "content/child/webmessageportchannel_impl.h" | 32 #include "content/child/webmessageportchannel_impl.h" |
33 #include "content/child/websocket_bridge.h" | 33 #include "content/child/websocket_bridge.h" |
34 #include "content/child/weburlresponse_extradata_impl.h" | 34 #include "content/child/weburlresponse_extradata_impl.h" |
35 #include "content/common/clipboard_messages.h" | 35 #include "content/common/clipboard_messages.h" |
36 #include "content/common/frame_messages.h" | 36 #include "content/common/frame_messages.h" |
37 #include "content/common/frame_replication_state.h" | |
37 #include "content/common/input_messages.h" | 38 #include "content/common/input_messages.h" |
38 #include "content/common/service_worker/service_worker_types.h" | 39 #include "content/common/service_worker/service_worker_types.h" |
39 #include "content/common/swapped_out_messages.h" | 40 #include "content/common/swapped_out_messages.h" |
40 #include "content/common/view_messages.h" | 41 #include "content/common/view_messages.h" |
41 #include "content/public/common/bindings_policy.h" | 42 #include "content/public/common/bindings_policy.h" |
42 #include "content/public/common/content_constants.h" | 43 #include "content/public/common/content_constants.h" |
43 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" |
44 #include "content/public/common/context_menu_params.h" | 45 #include "content/public/common/context_menu_params.h" |
45 #include "content/public/common/page_state.h" | 46 #include "content/public/common/page_state.h" |
46 #include "content/public/common/resource_response.h" | 47 #include "content/public/common/resource_response.h" |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 return NULL; | 550 return NULL; |
550 } | 551 } |
551 | 552 |
552 // static | 553 // static |
553 void RenderFrameImpl::InstallCreateHook( | 554 void RenderFrameImpl::InstallCreateHook( |
554 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { | 555 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { |
555 CHECK(!g_create_render_frame_impl); | 556 CHECK(!g_create_render_frame_impl); |
556 g_create_render_frame_impl = create_render_frame_impl; | 557 g_create_render_frame_impl = create_render_frame_impl; |
557 } | 558 } |
558 | 559 |
560 | |
561 // static | |
562 void RenderFrameImpl::SetReplicatedState(blink::WebRemoteFrame* frame, | |
Charlie Reis
2014/11/19 00:46:18
On second thought, maybe this belongs as a non-sta
alexmos
2014/11/19 02:49:27
Done - indeed, that seems much better and the code
| |
563 const FrameReplicationState& state) { | |
564 CHECK(frame); | |
Charlie Reis
2014/11/19 00:46:18
DCHECK is fine here. It clarifies the intent, and
alexmos
2014/11/19 02:49:27
Done.
| |
565 frame->setReplicatedOrigin(blink::WebSecurityOrigin::createFromString( | |
566 blink::WebString::fromUTF8(state.origin.string()))); | |
567 } | |
568 | |
559 // RenderFrameImpl ---------------------------------------------------------- | 569 // RenderFrameImpl ---------------------------------------------------------- |
560 RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) | 570 RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id) |
561 : frame_(NULL), | 571 : frame_(NULL), |
562 render_view_(render_view->AsWeakPtr()), | 572 render_view_(render_view->AsWeakPtr()), |
563 routing_id_(routing_id), | 573 routing_id_(routing_id), |
564 is_swapped_out_(false), | 574 is_swapped_out_(false), |
565 render_frame_proxy_(NULL), | 575 render_frame_proxy_(NULL), |
566 is_detaching_(false), | 576 is_detaching_(false), |
567 proxy_routing_id_(MSG_ROUTING_NONE), | 577 proxy_routing_id_(MSG_ROUTING_NONE), |
568 #if defined(ENABLE_PLUGINS) | 578 #if defined(ENABLE_PLUGINS) |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1099 CHECK(!frame_->parent()); | 1109 CHECK(!frame_->parent()); |
1100 | 1110 |
1101 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 1111 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
1102 bool proceed = frame_->dispatchBeforeUnloadEvent(); | 1112 bool proceed = frame_->dispatchBeforeUnloadEvent(); |
1103 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 1113 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
1104 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, | 1114 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, |
1105 before_unload_start_time, | 1115 before_unload_start_time, |
1106 before_unload_end_time)); | 1116 before_unload_end_time)); |
1107 } | 1117 } |
1108 | 1118 |
1109 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { | 1119 void RenderFrameImpl::OnSwapOut( |
1120 int proxy_routing_id, | |
1121 const FrameReplicationState& remote_frame_state) { | |
1110 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); | 1122 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); |
1111 RenderFrameProxy* proxy = NULL; | 1123 RenderFrameProxy* proxy = NULL; |
1112 bool is_site_per_process = | 1124 bool is_site_per_process = |
1113 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); | 1125 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); |
1114 bool is_main_frame = !frame_->parent(); | 1126 bool is_main_frame = !frame_->parent(); |
1115 | 1127 |
1116 // Only run unload if we're not swapped out yet, but send the ack either way. | 1128 // Only run unload if we're not swapped out yet, but send the ack either way. |
1117 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { | 1129 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { |
1118 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 1130 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
1119 // a different process. This involves running the unload handler and | 1131 // a different process. This involves running the unload handler and |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 frame_->swap(proxy->web_frame()); | 1197 frame_->swap(proxy->web_frame()); |
1186 if (is_site_per_process) { | 1198 if (is_site_per_process) { |
1187 // TODO(nasko): delete the frame here, since we've replaced it with a | 1199 // TODO(nasko): delete the frame here, since we've replaced it with a |
1188 // proxy. | 1200 // proxy. |
1189 } | 1201 } |
1190 } else { | 1202 } else { |
1191 set_render_frame_proxy(proxy); | 1203 set_render_frame_proxy(proxy); |
1192 } | 1204 } |
1193 } | 1205 } |
1194 | 1206 |
1207 // In --site-per-process, initialize the WebRemoteFrame with the replication | |
1208 // state passed by the process that is now rendering the frame. | |
1209 // TODO(alexmos): We cannot yet do this for swapped-out main frames, because | |
1210 // in that case we leave the LocalFrame as the main frame visible to Blink | |
1211 // and don't call swap() above. Because swap() is what creates a RemoteFrame | |
1212 // in proxy->web_frame(), the RemoteFrame will not exist for main frames. | |
1213 // When we do an unconditional swap for all frames, we can remove | |
1214 // !is_main_frame below. | |
1215 if (is_site_per_process && proxy && !is_main_frame) { | |
1216 RenderFrameImpl::SetReplicatedState(proxy->web_frame(), | |
1217 remote_frame_state); | |
1218 } | |
1219 | |
1195 // Safe to exit if no one else is using the process. | 1220 // Safe to exit if no one else is using the process. |
1196 if (is_main_frame) | 1221 if (is_main_frame) |
1197 render_view_->WasSwappedOut(); | 1222 render_view_->WasSwappedOut(); |
1198 } | 1223 } |
1199 | 1224 |
1200 void RenderFrameImpl::OnContextMenuClosed( | 1225 void RenderFrameImpl::OnContextMenuClosed( |
1201 const CustomContextMenuContext& custom_context) { | 1226 const CustomContextMenuContext& custom_context) { |
1202 if (custom_context.request_id) { | 1227 if (custom_context.request_id) { |
1203 // External request, should be in our map. | 1228 // External request, should be in our map. |
1204 ContextMenuClient* client = | 1229 ContextMenuClient* client = |
(...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3451 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); | 3476 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); |
3452 if (extra_data) | 3477 if (extra_data) |
3453 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); | 3478 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); |
3454 params.was_within_same_page = navigation_state->was_within_same_page(); | 3479 params.was_within_same_page = navigation_state->was_within_same_page(); |
3455 params.security_info = response.securityInfo(); | 3480 params.security_info = response.securityInfo(); |
3456 | 3481 |
3457 // Set the URL to be displayed in the browser UI to the user. | 3482 // Set the URL to be displayed in the browser UI to the user. |
3458 params.url = GetLoadingUrl(); | 3483 params.url = GetLoadingUrl(); |
3459 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); | 3484 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); |
3460 | 3485 |
3486 // Set the origin of the frame. This will be replicated to corresponding | |
Charlie Reis
2014/11/19 00:46:18
nit: to the corresponding
alexmos
2014/11/19 02:49:27
Done.
| |
3487 // RenderFrameProxies in other processes. | |
3488 if (!is_swapped_out_) { | |
3489 params.origin = url::Origin( | |
Charlie Reis
2014/11/19 00:46:18
nit: 2 space indent
alexmos
2014/11/19 02:49:27
Done.
| |
3490 frame->document().securityOrigin().toString().utf8()); | |
Charlie Reis
2014/11/19 00:46:18
Just checking: is toString().utf8() the right way
alexmos
2014/11/19 02:49:27
I based this off of how WebSerializedOrigin is ini
Charlie Reis
2014/11/19 19:31:46
Acknowledged.
| |
3491 } | |
3492 | |
3461 if (frame->document().baseURL() != params.url) | 3493 if (frame->document().baseURL() != params.url) |
3462 params.base_url = frame->document().baseURL(); | 3494 params.base_url = frame->document().baseURL(); |
3463 | 3495 |
3464 GetRedirectChain(ds, ¶ms.redirects); | 3496 GetRedirectChain(ds, ¶ms.redirects); |
3465 params.should_update_history = !ds->hasUnreachableURL() && | 3497 params.should_update_history = !ds->hasUnreachableURL() && |
3466 !response.isMultipartPayload() && (response.httpStatusCode() != 404); | 3498 !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
3467 | 3499 |
3468 params.searchable_form_url = internal_data->searchable_form_url(); | 3500 params.searchable_form_url = internal_data->searchable_form_url(); |
3469 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 3501 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
3470 | 3502 |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4198 | 4230 |
4199 #if defined(ENABLE_BROWSER_CDMS) | 4231 #if defined(ENABLE_BROWSER_CDMS) |
4200 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4232 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4201 if (!cdm_manager_) | 4233 if (!cdm_manager_) |
4202 cdm_manager_ = new RendererCdmManager(this); | 4234 cdm_manager_ = new RendererCdmManager(this); |
4203 return cdm_manager_; | 4235 return cdm_manager_; |
4204 } | 4236 } |
4205 #endif // defined(ENABLE_BROWSER_CDMS) | 4237 #endif // defined(ENABLE_BROWSER_CDMS) |
4206 | 4238 |
4207 } // namespace content | 4239 } // namespace content |
OLD | NEW |