Chromium Code Reviews| Index: content/renderer/render_frame_impl.cc |
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
| index b3bca5aff559363f8665610ff4391643f6a73c87..c1addbfbe31e8a235f9d25c6c71d0d07e3adf47f 100644 |
| --- a/content/renderer/render_frame_impl.cc |
| +++ b/content/renderer/render_frame_impl.cc |
| @@ -217,6 +217,7 @@ const char kDefaultAcceptHeader[] = |
| "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" |
| "*;q=0.8"; |
| const char kAcceptHeader[] = "Accept"; |
| +const char kHtmlMimeType[] = "text/html"; |
| const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| @@ -1092,22 +1093,8 @@ void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { |
| CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); |
| } |
| - } else if (!params.base_url_for_data_url.is_empty()) { |
| - // A loadData request with a specified base URL. |
| - std::string mime_type, charset, data; |
| - if (net::DataURL::Parse( |
| - params.common_params.url, &mime_type, &charset, &data)) { |
| - frame->loadData( |
| - WebData(data.c_str(), data.length()), |
| - WebString::fromUTF8(mime_type), |
| - WebString::fromUTF8(charset), |
| - params.base_url_for_data_url, |
| - params.history_url_for_data_url, |
| - false); |
| - } else { |
| - CHECK(false) << "Invalid URL passed: " |
| - << params.common_params.url.possibly_invalid_spec(); |
| - } |
| + } else if (!params.common_params.base_url_for_data_url.is_empty()) { |
| + LoadDataURL(params.common_params, frame); |
| } else { |
| // Navigate to the given URL. |
| WebURLRequest request = |
| @@ -3889,6 +3876,12 @@ void RenderFrameImpl::OnCommitNavigation( |
| GetContentClient()->SetActiveURL(common_params.url); |
| + if (!common_params.base_url_for_data_url.is_empty() || |
| + 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.
|
| + LoadDataURL(common_params, frame_); |
| + return; |
| + } |
| + |
| // Create a WebURLRequest that blink can use to get access to the body of the |
| // response through a stream in the browser. Blink will then commit the |
| // navigation. |
| @@ -4384,6 +4377,28 @@ void RenderFrameImpl::BeginNavigation(blink::WebURLRequest* request) { |
| GetRequestBodyForWebURLRequest(*request))); |
| } |
| +void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, |
| + WebFrame* frame) { |
| + // A loadData request with a specified base URL. |
| + std::string mime_type, charset, data; |
| + if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
| + CHECK(mime_type != kHtmlMimeType || |
| + !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
|
| + const GURL base_url = params.base_url_for_data_url.is_empty() ? |
| + params.url : params.base_url_for_data_url; |
| + frame->loadData( |
| + WebData(data.c_str(), data.length()), |
| + WebString::fromUTF8(mime_type), |
| + WebString::fromUTF8(charset), |
| + base_url, |
| + params.history_url_for_data_url, |
| + false); |
| + } else { |
| + CHECK(false) << "Invalid URL passed: " |
| + << params.url.possibly_invalid_spec(); |
| + } |
| +} |
| + |
| GURL RenderFrameImpl::GetLoadingUrl() const { |
| WebDataSource* ds = frame_->dataSource(); |
| if (ds->hasUnreachableURL()) |