Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2172)

Unified Diff: content/renderer/render_frame_impl.cc

Issue 906283003: PlzNavigate: Support data urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Charlie's comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« content/common/navigation_params.h ('K') | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« content/common/navigation_params.h ('K') | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698