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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 // We must know the page ID of the page we are navigating back to. | 1085 // We must know the page ID of the page we are navigating back to. |
1086 DCHECK_NE(params.page_id, -1); | 1086 DCHECK_NE(params.page_id, -1); |
1087 scoped_ptr<HistoryEntry> entry = | 1087 scoped_ptr<HistoryEntry> entry = |
1088 PageStateToHistoryEntry(params.commit_params.page_state); | 1088 PageStateToHistoryEntry(params.commit_params.page_state); |
1089 if (entry) { | 1089 if (entry) { |
1090 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1090 // Ensure we didn't save the swapped out URL in UpdateState, since the |
1091 // browser should never be telling us to navigate to swappedout://. | 1091 // browser should never be telling us to navigate to swappedout://. |
1092 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1092 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
1093 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); | 1093 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); |
1094 } | 1094 } |
1095 } else if (!params.base_url_for_data_url.is_empty()) { | 1095 } else if (!params.common_params.base_url_for_data_url.is_empty()) { |
1096 // A loadData request with a specified base URL. | 1096 LoadDataURL(params.common_params, frame); |
1097 std::string mime_type, charset, data; | |
1098 if (net::DataURL::Parse( | |
1099 params.common_params.url, &mime_type, &charset, &data)) { | |
1100 frame->loadData( | |
1101 WebData(data.c_str(), data.length()), | |
1102 WebString::fromUTF8(mime_type), | |
1103 WebString::fromUTF8(charset), | |
1104 params.base_url_for_data_url, | |
1105 params.history_url_for_data_url, | |
1106 false); | |
1107 } else { | |
1108 CHECK(false) << "Invalid URL passed: " | |
1109 << params.common_params.url.possibly_invalid_spec(); | |
1110 } | |
1111 } else { | 1097 } else { |
1112 // Navigate to the given URL. | 1098 // Navigate to the given URL. |
1113 WebURLRequest request = | 1099 WebURLRequest request = |
1114 CreateURLRequestForNavigation(params.common_params, | 1100 CreateURLRequestForNavigation(params.common_params, |
1115 scoped_ptr<StreamOverrideParameters>(), | 1101 scoped_ptr<StreamOverrideParameters>(), |
1116 frame->isViewSourceModeEnabled()); | 1102 frame->isViewSourceModeEnabled()); |
1117 | 1103 |
1118 if (!params.extra_headers.empty()) { | 1104 if (!params.extra_headers.empty()) { |
1119 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), | 1105 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
1120 params.extra_headers.end(), | 1106 params.extra_headers.end(), |
(...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3875 WebURLRequest::UseProtocolCachePolicy; | 3861 WebURLRequest::UseProtocolCachePolicy; |
3876 if (!RenderFrameImpl::PrepareRenderViewForNavigation( | 3862 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
3877 common_params.url, false /* check_for_stale_navigation */, | 3863 common_params.url, false /* check_for_stale_navigation */, |
3878 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, | 3864 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, |
3879 &is_reload, &cache_policy)) { | 3865 &is_reload, &cache_policy)) { |
3880 return; | 3866 return; |
3881 } | 3867 } |
3882 | 3868 |
3883 GetContentClient()->SetActiveURL(common_params.url); | 3869 GetContentClient()->SetActiveURL(common_params.url); |
3884 | 3870 |
3871 if (!common_params.base_url_for_data_url.is_empty() || | |
3872 common_params.url.SchemeIs(url::kDataScheme)) { | |
3873 LoadDataURL(common_params, frame_); | |
3874 return; | |
3875 } | |
3876 | |
3885 // Create a WebURLRequest that blink can use to get access to the body of the | 3877 // Create a WebURLRequest that blink can use to get access to the body of the |
3886 // response through a stream in the browser. Blink will then commit the | 3878 // response through a stream in the browser. Blink will then commit the |
3887 // navigation. | 3879 // navigation. |
3888 // TODO(clamy): Have the navigation commit directly, without going through | 3880 // TODO(clamy): Have the navigation commit directly, without going through |
3889 // loading a WebURLRequest. | 3881 // loading a WebURLRequest. |
3890 scoped_ptr<StreamOverrideParameters> stream_override( | 3882 scoped_ptr<StreamOverrideParameters> stream_override( |
3891 new StreamOverrideParameters()); | 3883 new StreamOverrideParameters()); |
3892 stream_override->stream_url = stream_url; | 3884 stream_override->stream_url = stream_url; |
3893 stream_override->response = response; | 3885 stream_override->response = response; |
3894 WebURLRequest request = | 3886 WebURLRequest request = |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4370 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); | 4362 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); |
4371 Send(new FrameHostMsg_BeginNavigation( | 4363 Send(new FrameHostMsg_BeginNavigation( |
4372 routing_id_, MakeCommonNavigationParams(request), | 4364 routing_id_, MakeCommonNavigationParams(request), |
4373 BeginNavigationParams(request->httpMethod().latin1(), | 4365 BeginNavigationParams(request->httpMethod().latin1(), |
4374 GetWebURLRequestHeaders(*request), | 4366 GetWebURLRequestHeaders(*request), |
4375 GetLoadFlagsForWebURLRequest(*request), | 4367 GetLoadFlagsForWebURLRequest(*request), |
4376 request->hasUserGesture()), | 4368 request->hasUserGesture()), |
4377 GetRequestBodyForWebURLRequest(*request))); | 4369 GetRequestBodyForWebURLRequest(*request))); |
4378 } | 4370 } |
4379 | 4371 |
4372 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, | |
4373 WebFrame* frame) { | |
4374 // A loadData request with a specified base URL. | |
4375 std::string mime_type, charset, data; | |
4376 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | |
4377 const GURL base_url = params.base_url_for_data_url.is_empty() ? | |
Charlie Reis
2015/02/20 22:11:50
We didn't have this case before (i.e., passing a d
clamy
2015/02/26 15:28:36
We cannot pass an empty URL here as this will caus
| |
4378 params.url : params.base_url_for_data_url; | |
4379 frame->loadData( | |
4380 WebData(data.c_str(), data.length()), | |
4381 WebString::fromUTF8(mime_type), | |
4382 WebString::fromUTF8(charset), | |
4383 base_url, | |
4384 params.history_url_for_data_url, | |
4385 false); | |
4386 } else { | |
4387 CHECK(false) << "Invalid URL passed: " | |
4388 << params.url.possibly_invalid_spec(); | |
4389 } | |
4390 } | |
4391 | |
4380 GURL RenderFrameImpl::GetLoadingUrl() const { | 4392 GURL RenderFrameImpl::GetLoadingUrl() const { |
4381 WebDataSource* ds = frame_->dataSource(); | 4393 WebDataSource* ds = frame_->dataSource(); |
4382 if (ds->hasUnreachableURL()) | 4394 if (ds->hasUnreachableURL()) |
4383 return ds->unreachableURL(); | 4395 return ds->unreachableURL(); |
4384 | 4396 |
4385 const WebURLRequest& request = ds->request(); | 4397 const WebURLRequest& request = ds->request(); |
4386 return request.url(); | 4398 return request.url(); |
4387 } | 4399 } |
4388 | 4400 |
4389 #if defined(OS_ANDROID) | 4401 #if defined(OS_ANDROID) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4441 | 4453 |
4442 #if defined(ENABLE_BROWSER_CDMS) | 4454 #if defined(ENABLE_BROWSER_CDMS) |
4443 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4455 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4444 if (!cdm_manager_) | 4456 if (!cdm_manager_) |
4445 cdm_manager_ = new RendererCdmManager(this); | 4457 cdm_manager_ = new RendererCdmManager(this); |
4446 return cdm_manager_; | 4458 return cdm_manager_; |
4447 } | 4459 } |
4448 #endif // defined(ENABLE_BROWSER_CDMS) | 4460 #endif // defined(ENABLE_BROWSER_CDMS) |
4449 | 4461 |
4450 } // namespace content | 4462 } // namespace content |
OLD | NEW |