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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 // We must know the page ID of the page we are navigating back to. | 1084 // We must know the page ID of the page we are navigating back to. |
1085 DCHECK_NE(params.page_id, -1); | 1085 DCHECK_NE(params.page_id, -1); |
1086 scoped_ptr<HistoryEntry> entry = | 1086 scoped_ptr<HistoryEntry> entry = |
1087 PageStateToHistoryEntry(params.commit_params.page_state); | 1087 PageStateToHistoryEntry(params.commit_params.page_state); |
1088 if (entry) { | 1088 if (entry) { |
1089 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1089 // Ensure we didn't save the swapped out URL in UpdateState, since the |
1090 // browser should never be telling us to navigate to swappedout://. | 1090 // browser should never be telling us to navigate to swappedout://. |
1091 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1091 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
1092 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); | 1092 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); |
1093 } | 1093 } |
1094 } else if (!params.base_url_for_data_url.is_empty()) { | 1094 } else if (!params.common_params.base_url_for_data_url.is_empty()) { |
1095 // A loadData request with a specified base URL. | 1095 LoadDataURL(params.common_params, frame); |
1096 std::string mime_type, charset, data; | |
1097 if (net::DataURL::Parse( | |
1098 params.common_params.url, &mime_type, &charset, &data)) { | |
1099 frame->loadData( | |
1100 WebData(data.c_str(), data.length()), | |
1101 WebString::fromUTF8(mime_type), | |
1102 WebString::fromUTF8(charset), | |
1103 params.base_url_for_data_url, | |
1104 params.history_url_for_data_url, | |
1105 false); | |
1106 } else { | |
1107 CHECK(false) << "Invalid URL passed: " | |
1108 << params.common_params.url.possibly_invalid_spec(); | |
1109 } | |
1110 } else { | 1096 } else { |
1111 // Navigate to the given URL. | 1097 // Navigate to the given URL. |
1112 WebURLRequest request = | 1098 WebURLRequest request = |
1113 CreateURLRequestForNavigation(params.common_params, | 1099 CreateURLRequestForNavigation(params.common_params, |
1114 scoped_ptr<StreamOverrideParameters>(), | 1100 scoped_ptr<StreamOverrideParameters>(), |
1115 frame->isViewSourceModeEnabled()); | 1101 frame->isViewSourceModeEnabled()); |
1116 | 1102 |
1117 if (!params.extra_headers.empty()) { | 1103 if (!params.extra_headers.empty()) { |
1118 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), | 1104 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
1119 params.extra_headers.end(), | 1105 params.extra_headers.end(), |
(...skipping 2756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3876 WebURLRequest::UseProtocolCachePolicy; | 3862 WebURLRequest::UseProtocolCachePolicy; |
3877 if (!RenderFrameImpl::PrepareRenderViewForNavigation( | 3863 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
3878 common_params.url, false /* check_for_stale_navigation */, | 3864 common_params.url, false /* check_for_stale_navigation */, |
3879 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, | 3865 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, |
3880 &is_reload, &cache_policy)) { | 3866 &is_reload, &cache_policy)) { |
3881 return; | 3867 return; |
3882 } | 3868 } |
3883 | 3869 |
3884 GetContentClient()->SetActiveURL(common_params.url); | 3870 GetContentClient()->SetActiveURL(common_params.url); |
3885 | 3871 |
3872 if (!common_params.base_url_for_data_url.is_empty() || | |
3873 common_params.url.SchemeIs(url::kDataScheme)) { | |
carlosk
2015/02/17 12:35:09
Shouldn't this be a call to ShouldMakeNetworkReque
clamy
2015/02/17 12:54:28
The goal is for ShouldMakeNetworkRequestForNavigat
carlosk
2015/02/17 14:11:23
Acknowledged.
| |
3874 LoadDataURL(common_params, frame_); | |
3875 return; | |
3876 } | |
3877 | |
3886 // Create a WebURLRequest that blink can use to get access to the body of the | 3878 // Create a WebURLRequest that blink can use to get access to the body of the |
3887 // response through a stream in the browser. Blink will then commit the | 3879 // response through a stream in the browser. Blink will then commit the |
3888 // navigation. | 3880 // navigation. |
3889 // TODO(clamy): Have the navigation commit directly, without going through | 3881 // TODO(clamy): Have the navigation commit directly, without going through |
3890 // loading a WebURLRequest. | 3882 // loading a WebURLRequest. |
3891 scoped_ptr<StreamOverrideParameters> stream_override( | 3883 scoped_ptr<StreamOverrideParameters> stream_override( |
3892 new StreamOverrideParameters()); | 3884 new StreamOverrideParameters()); |
3893 stream_override->stream_url = stream_url; | 3885 stream_override->stream_url = stream_url; |
3894 stream_override->response = response; | 3886 stream_override->response = response; |
3895 WebURLRequest request = | 3887 WebURLRequest request = |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4127 if (is_fork) { | 4119 if (is_fork) { |
4128 // Open the URL via the browser, not via WebKit. | 4120 // Open the URL via the browser, not via WebKit. |
4129 OpenURL(info.frame, url, Referrer(), info.defaultPolicy); | 4121 OpenURL(info.frame, url, Referrer(), info.defaultPolicy); |
4130 return blink::WebNavigationPolicyIgnore; | 4122 return blink::WebNavigationPolicyIgnore; |
4131 } | 4123 } |
4132 | 4124 |
4133 // PlzNavigate: send the request to the browser if needed. | 4125 // PlzNavigate: send the request to the browser if needed. |
4134 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 4126 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
4135 switches::kEnableBrowserSideNavigation) && | 4127 switches::kEnableBrowserSideNavigation) && |
4136 info.urlRequest.checkForBrowserSideNavigation()) { | 4128 info.urlRequest.checkForBrowserSideNavigation()) { |
4137 BeginNavigation(&info.urlRequest); | 4129 if (BeginNavigation(&info.urlRequest)) |
4138 return blink::WebNavigationPolicyIgnore; | 4130 return blink::WebNavigationPolicyIgnore; |
Charlie Reis
2015/02/18 00:43:25
What if we're navigating a RemoteFrame and it need
clamy
2015/02/20 17:05:59
Done.
| |
4139 } | 4131 } |
4140 | 4132 |
4141 return info.defaultPolicy; | 4133 return info.defaultPolicy; |
4142 } | 4134 } |
4143 | 4135 |
4144 void RenderFrameImpl::OpenURL(WebFrame* frame, | 4136 void RenderFrameImpl::OpenURL(WebFrame* frame, |
4145 const GURL& url, | 4137 const GURL& url, |
4146 const Referrer& referrer, | 4138 const Referrer& referrer, |
4147 WebNavigationPolicy policy) { | 4139 WebNavigationPolicy policy) { |
4148 DCHECK_EQ(frame_, frame); | 4140 DCHECK_EQ(frame_, frame); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4340 // We refresh timezone when a view is swapped in since timezone | 4332 // We refresh timezone when a view is swapped in since timezone |
4341 // can get out of sync when the system timezone is updated while | 4333 // can get out of sync when the system timezone is updated while |
4342 // the view is swapped out. | 4334 // the view is swapped out. |
4343 RenderThreadImpl::NotifyTimezoneChange(); | 4335 RenderThreadImpl::NotifyTimezoneChange(); |
4344 | 4336 |
4345 render_view_->SetSwappedOut(false); | 4337 render_view_->SetSwappedOut(false); |
4346 is_swapped_out_ = false; | 4338 is_swapped_out_ = false; |
4347 return true; | 4339 return true; |
4348 } | 4340 } |
4349 | 4341 |
4350 void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request) { | 4342 bool RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request) { |
4351 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 4343 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
4352 switches::kEnableBrowserSideNavigation)); | 4344 switches::kEnableBrowserSideNavigation)); |
4353 DCHECK(request); | 4345 DCHECK(request); |
4354 // TODO(clamy): Execute the beforeunload event. | 4346 // TODO(clamy): Execute the beforeunload event. |
4355 | 4347 |
4356 // Note: At this stage, the goal is to apply all the modifications the | 4348 // Note: At this stage, the goal is to apply all the modifications the |
4357 // renderer wants to make to the request, and then send it to the browser, so | 4349 // renderer wants to make to the request, and then send it to the browser, so |
4358 // that the actual network request can be started. Ideally, all such | 4350 // that the actual network request can be started. Ideally, all such |
4359 // modifications should take place in willSendRequest, and in the | 4351 // modifications should take place in willSendRequest, and in the |
4360 // implementation of willSendRequest for the various InspectorAgents | 4352 // implementation of willSendRequest for the various InspectorAgents |
4361 // (devtools). | 4353 // (devtools). |
4362 // | 4354 // |
4363 // TODO(clamy): Apply devtools override. | 4355 // TODO(clamy): Apply devtools override. |
4364 // TODO(clamy): Make sure that navigation requests are not modified somewhere | 4356 // TODO(clamy): Make sure that navigation requests are not modified somewhere |
4365 // else in blink. | 4357 // else in blink. |
4366 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); | 4358 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); |
4367 | 4359 |
4368 // TODO(clamy): Same-document navigations should not be sent back to the | 4360 // TODO(clamy): Same-document navigations should not be sent back to the |
4369 // browser. | 4361 // browser. |
4370 // TODO(clamy): Data urls should not be sent back to the browser either. | 4362 // TODO(clamy): Data urls should not be sent back to the browser either. |
4371 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); | 4363 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); |
4372 Send(new FrameHostMsg_BeginNavigation( | 4364 Send(new FrameHostMsg_BeginNavigation( |
4373 routing_id_, MakeCommonNavigationParams(request), | 4365 routing_id_, MakeCommonNavigationParams(request), |
4374 BeginNavigationParams(request->httpMethod().latin1(), | 4366 BeginNavigationParams(request->httpMethod().latin1(), |
4375 GetWebURLRequestHeaders(*request), | 4367 GetWebURLRequestHeaders(*request), |
4376 GetLoadFlagsForWebURLRequest(*request), | 4368 GetLoadFlagsForWebURLRequest(*request), |
4377 request->hasUserGesture()), | 4369 request->hasUserGesture()), |
4378 GetRequestBodyForWebURLRequest(*request))); | 4370 GetRequestBodyForWebURLRequest(*request))); |
4371 return ShouldMakeNetworkRequestForNavigation(request->url()); | |
4372 } | |
4373 | |
4374 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, | |
4375 WebFrame* frame) { | |
4376 // A loadData request with a specified base URL. | |
4377 std::string mime_type, charset, data; | |
4378 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | |
4379 const GURL base_url = params.base_url_for_data_url.is_empty() ? | |
4380 params.url : params.base_url_for_data_url; | |
4381 frame->loadData( | |
4382 WebData(data.c_str(), data.length()), | |
4383 WebString::fromUTF8(mime_type), | |
4384 WebString::fromUTF8(charset), | |
4385 base_url, | |
4386 params.history_url_for_data_url, | |
4387 false); | |
4388 } else { | |
4389 CHECK(false) << "Invalid URL passed: " | |
4390 << params.url.possibly_invalid_spec(); | |
4391 } | |
4379 } | 4392 } |
4380 | 4393 |
4381 GURL RenderFrameImpl::GetLoadingUrl() const { | 4394 GURL RenderFrameImpl::GetLoadingUrl() const { |
4382 WebDataSource* ds = frame_->dataSource(); | 4395 WebDataSource* ds = frame_->dataSource(); |
4383 if (ds->hasUnreachableURL()) | 4396 if (ds->hasUnreachableURL()) |
4384 return ds->unreachableURL(); | 4397 return ds->unreachableURL(); |
4385 | 4398 |
4386 const WebURLRequest& request = ds->request(); | 4399 const WebURLRequest& request = ds->request(); |
4387 return request.url(); | 4400 return request.url(); |
4388 } | 4401 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4442 | 4455 |
4443 #if defined(ENABLE_BROWSER_CDMS) | 4456 #if defined(ENABLE_BROWSER_CDMS) |
4444 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4457 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4445 if (!cdm_manager_) | 4458 if (!cdm_manager_) |
4446 cdm_manager_ = new RendererCdmManager(this); | 4459 cdm_manager_ = new RendererCdmManager(this); |
4447 return cdm_manager_; | 4460 return cdm_manager_; |
4448 } | 4461 } |
4449 #endif // defined(ENABLE_BROWSER_CDMS) | 4462 #endif // defined(ENABLE_BROWSER_CDMS) |
4450 | 4463 |
4451 } // namespace content | 4464 } // namespace content |
OLD | NEW |