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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 CHECK(!frame_->parent()); | 1103 CHECK(!frame_->parent()); |
1103 | 1104 |
1104 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 1105 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
1105 bool proceed = frame_->dispatchBeforeUnloadEvent(); | 1106 bool proceed = frame_->dispatchBeforeUnloadEvent(); |
1106 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 1107 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
1107 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, | 1108 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, |
1108 before_unload_start_time, | 1109 before_unload_start_time, |
1109 before_unload_end_time)); | 1110 before_unload_end_time)); |
1110 } | 1111 } |
1111 | 1112 |
1112 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { | 1113 void RenderFrameImpl::OnSwapOut( |
| 1114 int proxy_routing_id, |
| 1115 const FrameReplicationState& replicated_frame_state) { |
1113 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); | 1116 TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); |
1114 RenderFrameProxy* proxy = NULL; | 1117 RenderFrameProxy* proxy = NULL; |
1115 bool is_site_per_process = | 1118 bool is_site_per_process = |
1116 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); | 1119 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); |
1117 bool is_main_frame = !frame_->parent(); | 1120 bool is_main_frame = !frame_->parent(); |
1118 | 1121 |
1119 // Only run unload if we're not swapped out yet, but send the ack either way. | 1122 // Only run unload if we're not swapped out yet, but send the ack either way. |
1120 if (!is_swapped_out_) { | 1123 if (!is_swapped_out_) { |
1121 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 1124 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
1122 // a different process. This involves running the unload handler and | 1125 // a different process. This involves running the unload handler and |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 frame_->swap(proxy->web_frame()); | 1190 frame_->swap(proxy->web_frame()); |
1188 if (is_site_per_process) { | 1191 if (is_site_per_process) { |
1189 // TODO(nasko): delete the frame here, since we've replaced it with a | 1192 // TODO(nasko): delete the frame here, since we've replaced it with a |
1190 // proxy. | 1193 // proxy. |
1191 } | 1194 } |
1192 } else { | 1195 } else { |
1193 set_render_frame_proxy(proxy); | 1196 set_render_frame_proxy(proxy); |
1194 } | 1197 } |
1195 } | 1198 } |
1196 | 1199 |
| 1200 // In --site-per-process, initialize the WebRemoteFrame with the replication |
| 1201 // state passed by the process that is now rendering the frame. |
| 1202 // TODO(alexmos): We cannot yet do this for swapped-out main frames, because |
| 1203 // in that case we leave the LocalFrame as the main frame visible to Blink |
| 1204 // and don't call swap() above. Because swap() is what creates a RemoteFrame |
| 1205 // in proxy->web_frame(), the RemoteFrame will not exist for main frames. |
| 1206 // When we do an unconditional swap for all frames, we can remove |
| 1207 // !is_main_frame below. |
| 1208 if (is_site_per_process && proxy && !is_main_frame) |
| 1209 proxy->SetReplicatedState(replicated_frame_state); |
| 1210 |
1197 // Safe to exit if no one else is using the process. | 1211 // Safe to exit if no one else is using the process. |
1198 if (is_main_frame) | 1212 if (is_main_frame) |
1199 render_view_->WasSwappedOut(); | 1213 render_view_->WasSwappedOut(); |
1200 } | 1214 } |
1201 | 1215 |
1202 void RenderFrameImpl::OnContextMenuClosed( | 1216 void RenderFrameImpl::OnContextMenuClosed( |
1203 const CustomContextMenuContext& custom_context) { | 1217 const CustomContextMenuContext& custom_context) { |
1204 if (custom_context.request_id) { | 1218 if (custom_context.request_id) { |
1205 // External request, should be in our map. | 1219 // External request, should be in our map. |
1206 ContextMenuClient* client = | 1220 ContextMenuClient* client = |
(...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3473 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); | 3487 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); |
3474 if (extra_data) | 3488 if (extra_data) |
3475 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); | 3489 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); |
3476 params.was_within_same_page = navigation_state->was_within_same_page(); | 3490 params.was_within_same_page = navigation_state->was_within_same_page(); |
3477 params.security_info = response.securityInfo(); | 3491 params.security_info = response.securityInfo(); |
3478 | 3492 |
3479 // Set the URL to be displayed in the browser UI to the user. | 3493 // Set the URL to be displayed in the browser UI to the user. |
3480 params.url = GetLoadingUrl(); | 3494 params.url = GetLoadingUrl(); |
3481 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); | 3495 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); |
3482 | 3496 |
| 3497 // Set the origin of the frame. This will be replicated to the corresponding |
| 3498 // RenderFrameProxies in other processes. |
| 3499 // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due |
| 3500 // to https://crbug.com/439608 and will be replicated as unique origins. |
| 3501 if (!is_swapped_out_) { |
| 3502 WebString serialized_origin(frame->document().securityOrigin().toString()); |
| 3503 if (GURL(serialized_origin).IsStandard()) |
| 3504 params.origin = url::Origin(serialized_origin.utf8()); |
| 3505 } |
| 3506 |
3483 if (frame->document().baseURL() != params.url) | 3507 if (frame->document().baseURL() != params.url) |
3484 params.base_url = frame->document().baseURL(); | 3508 params.base_url = frame->document().baseURL(); |
3485 | 3509 |
3486 GetRedirectChain(ds, ¶ms.redirects); | 3510 GetRedirectChain(ds, ¶ms.redirects); |
3487 params.should_update_history = !ds->hasUnreachableURL() && | 3511 params.should_update_history = !ds->hasUnreachableURL() && |
3488 !response.isMultipartPayload() && (response.httpStatusCode() != 404); | 3512 !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
3489 | 3513 |
3490 params.searchable_form_url = internal_data->searchable_form_url(); | 3514 params.searchable_form_url = internal_data->searchable_form_url(); |
3491 params.searchable_form_encoding = internal_data->searchable_form_encoding(); | 3515 params.searchable_form_encoding = internal_data->searchable_form_encoding(); |
3492 | 3516 |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4237 | 4261 |
4238 #if defined(ENABLE_BROWSER_CDMS) | 4262 #if defined(ENABLE_BROWSER_CDMS) |
4239 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4263 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4240 if (!cdm_manager_) | 4264 if (!cdm_manager_) |
4241 cdm_manager_ = new RendererCdmManager(this); | 4265 cdm_manager_ = new RendererCdmManager(this); |
4242 return cdm_manager_; | 4266 return cdm_manager_; |
4243 } | 4267 } |
4244 #endif // defined(ENABLE_BROWSER_CDMS) | 4268 #endif // defined(ENABLE_BROWSER_CDMS) |
4245 | 4269 |
4246 } // namespace content | 4270 } // namespace content |
OLD | NEW |