Chromium Code Reviews| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 using base::TimeDelta; | 210 using base::TimeDelta; |
| 211 | 211 |
| 212 namespace content { | 212 namespace content { |
| 213 | 213 |
| 214 namespace { | 214 namespace { |
| 215 | 215 |
| 216 const char kDefaultAcceptHeader[] = | 216 const char kDefaultAcceptHeader[] = |
| 217 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" | 217 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" |
| 218 "*;q=0.8"; | 218 "*;q=0.8"; |
| 219 const char kAcceptHeader[] = "Accept"; | 219 const char kAcceptHeader[] = "Accept"; |
| 220 const char kHtmlMimeType[] = "text/html"; | |
| 220 | 221 |
| 221 const size_t kExtraCharsBeforeAndAfterSelection = 100; | 222 const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| 222 | 223 |
| 223 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; | 224 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; |
| 224 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = | 225 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = |
| 225 LAZY_INSTANCE_INITIALIZER; | 226 LAZY_INSTANCE_INITIALIZER; |
| 226 | 227 |
| 227 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap; | 228 typedef std::map<blink::WebFrame*, RenderFrameImpl*> FrameMap; |
| 228 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; | 229 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; |
| 229 | 230 |
| (...skipping 855 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. | 1086 // We must know the page ID of the page we are navigating back to. |
| 1086 DCHECK_NE(params.page_id, -1); | 1087 DCHECK_NE(params.page_id, -1); |
| 1087 scoped_ptr<HistoryEntry> entry = | 1088 scoped_ptr<HistoryEntry> entry = |
| 1088 PageStateToHistoryEntry(params.commit_params.page_state); | 1089 PageStateToHistoryEntry(params.commit_params.page_state); |
| 1089 if (entry) { | 1090 if (entry) { |
| 1090 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1091 // Ensure we didn't save the swapped out URL in UpdateState, since the |
| 1091 // browser should never be telling us to navigate to swappedout://. | 1092 // browser should never be telling us to navigate to swappedout://. |
| 1092 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1093 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| 1093 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); | 1094 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); |
| 1094 } | 1095 } |
| 1095 } else if (!params.base_url_for_data_url.is_empty()) { | 1096 } else if (!params.common_params.base_url_for_data_url.is_empty()) { |
| 1096 // A loadData request with a specified base URL. | 1097 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 { | 1098 } else { |
| 1112 // Navigate to the given URL. | 1099 // Navigate to the given URL. |
| 1113 WebURLRequest request = | 1100 WebURLRequest request = |
| 1114 CreateURLRequestForNavigation(params.common_params, | 1101 CreateURLRequestForNavigation(params.common_params, |
| 1115 scoped_ptr<StreamOverrideParameters>(), | 1102 scoped_ptr<StreamOverrideParameters>(), |
| 1116 frame->isViewSourceModeEnabled()); | 1103 frame->isViewSourceModeEnabled()); |
| 1117 | 1104 |
| 1118 if (!params.extra_headers.empty()) { | 1105 if (!params.extra_headers.empty()) { |
| 1119 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), | 1106 for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
| 1120 params.extra_headers.end(), | 1107 params.extra_headers.end(), |
| (...skipping 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3882 WebURLRequest::UseProtocolCachePolicy; | 3869 WebURLRequest::UseProtocolCachePolicy; |
| 3883 if (!RenderFrameImpl::PrepareRenderViewForNavigation( | 3870 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
| 3884 common_params.url, false /* check_for_stale_navigation */, | 3871 common_params.url, false /* check_for_stale_navigation */, |
| 3885 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, | 3872 is_history_navigation, -1 /* current_history_list_offset; TODO(clamy)*/, |
| 3886 &is_reload, &cache_policy)) { | 3873 &is_reload, &cache_policy)) { |
| 3887 return; | 3874 return; |
| 3888 } | 3875 } |
| 3889 | 3876 |
| 3890 GetContentClient()->SetActiveURL(common_params.url); | 3877 GetContentClient()->SetActiveURL(common_params.url); |
| 3891 | 3878 |
| 3879 if (!common_params.base_url_for_data_url.is_empty() || | |
| 3880 common_params.url.SchemeIs(url::kDataScheme)) { | |
|
Charlie Reis
2015/02/26 20:49:01
This case passes data URLs without base_url_data_u
clamy
2015/02/27 12:53:59
I removed the CHECK.
| |
| 3881 LoadDataURL(common_params, frame_); | |
| 3882 return; | |
| 3883 } | |
| 3884 | |
| 3892 // Create a WebURLRequest that blink can use to get access to the body of the | 3885 // Create a WebURLRequest that blink can use to get access to the body of the |
| 3893 // response through a stream in the browser. Blink will then commit the | 3886 // response through a stream in the browser. Blink will then commit the |
| 3894 // navigation. | 3887 // navigation. |
| 3895 // TODO(clamy): Have the navigation commit directly, without going through | 3888 // TODO(clamy): Have the navigation commit directly, without going through |
| 3896 // loading a WebURLRequest. | 3889 // loading a WebURLRequest. |
| 3897 scoped_ptr<StreamOverrideParameters> stream_override( | 3890 scoped_ptr<StreamOverrideParameters> stream_override( |
| 3898 new StreamOverrideParameters()); | 3891 new StreamOverrideParameters()); |
| 3899 stream_override->stream_url = stream_url; | 3892 stream_override->stream_url = stream_url; |
| 3900 stream_override->response = response; | 3893 stream_override->response = response; |
| 3901 WebURLRequest request = | 3894 WebURLRequest request = |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4377 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); | 4370 Send(new FrameHostMsg_DidStartLoading(routing_id_, true)); |
| 4378 Send(new FrameHostMsg_BeginNavigation( | 4371 Send(new FrameHostMsg_BeginNavigation( |
| 4379 routing_id_, MakeCommonNavigationParams(request), | 4372 routing_id_, MakeCommonNavigationParams(request), |
| 4380 BeginNavigationParams(request->httpMethod().latin1(), | 4373 BeginNavigationParams(request->httpMethod().latin1(), |
| 4381 GetWebURLRequestHeaders(*request), | 4374 GetWebURLRequestHeaders(*request), |
| 4382 GetLoadFlagsForWebURLRequest(*request), | 4375 GetLoadFlagsForWebURLRequest(*request), |
| 4383 request->hasUserGesture()), | 4376 request->hasUserGesture()), |
| 4384 GetRequestBodyForWebURLRequest(*request))); | 4377 GetRequestBodyForWebURLRequest(*request))); |
| 4385 } | 4378 } |
| 4386 | 4379 |
| 4380 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, | |
| 4381 WebFrame* frame) { | |
| 4382 // A loadData request with a specified base URL. | |
| 4383 std::string mime_type, charset, data; | |
| 4384 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | |
| 4385 CHECK(mime_type != kHtmlMimeType || | |
| 4386 !params.base_url_for_data_url.is_empty()); | |
|
Charlie Reis
2015/02/26 20:49:01
I don't understand why this would be true. It's p
clamy
2015/02/27 12:53:59
I removed the CHECK. It was introduced because the
| |
| 4387 const GURL base_url = params.base_url_for_data_url.is_empty() ? | |
| 4388 params.url : params.base_url_for_data_url; | |
| 4389 frame->loadData( | |
| 4390 WebData(data.c_str(), data.length()), | |
| 4391 WebString::fromUTF8(mime_type), | |
| 4392 WebString::fromUTF8(charset), | |
| 4393 base_url, | |
| 4394 params.history_url_for_data_url, | |
| 4395 false); | |
| 4396 } else { | |
| 4397 CHECK(false) << "Invalid URL passed: " | |
| 4398 << params.url.possibly_invalid_spec(); | |
| 4399 } | |
| 4400 } | |
| 4401 | |
| 4387 GURL RenderFrameImpl::GetLoadingUrl() const { | 4402 GURL RenderFrameImpl::GetLoadingUrl() const { |
| 4388 WebDataSource* ds = frame_->dataSource(); | 4403 WebDataSource* ds = frame_->dataSource(); |
| 4389 if (ds->hasUnreachableURL()) | 4404 if (ds->hasUnreachableURL()) |
| 4390 return ds->unreachableURL(); | 4405 return ds->unreachableURL(); |
| 4391 | 4406 |
| 4392 const WebURLRequest& request = ds->request(); | 4407 const WebURLRequest& request = ds->request(); |
| 4393 return request.url(); | 4408 return request.url(); |
| 4394 } | 4409 } |
| 4395 | 4410 |
| 4396 #if defined(OS_ANDROID) | 4411 #if defined(OS_ANDROID) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4448 | 4463 |
| 4449 #if defined(ENABLE_BROWSER_CDMS) | 4464 #if defined(ENABLE_BROWSER_CDMS) |
| 4450 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4465 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 4451 if (!cdm_manager_) | 4466 if (!cdm_manager_) |
| 4452 cdm_manager_ = new RendererCdmManager(this); | 4467 cdm_manager_ = new RendererCdmManager(this); |
| 4453 return cdm_manager_; | 4468 return cdm_manager_; |
| 4454 } | 4469 } |
| 4455 #endif // defined(ENABLE_BROWSER_CDMS) | 4470 #endif // defined(ENABLE_BROWSER_CDMS) |
| 4456 | 4471 |
| 4457 } // namespace content | 4472 } // namespace content |
| OLD | NEW |