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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 176883012: Set the original url correctly if the frame is loaded via loadData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments about const and null checks Created 6 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
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 209b20bd42ea3ed1cf75a673d3d1c1ef659e9f85..17be18ed370d4e89d0347bf7099834bae53a2ab7 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -2106,7 +2106,6 @@ void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) {
DCHECK(ds);
const WebURLRequest& request = ds->request();
- const WebURLRequest& original_request = ds->originalRequest();
const WebURLResponse& response = ds->response();
DocumentState* document_state = DocumentState::FromDataSource(ds);
@@ -2227,10 +2226,7 @@ void RenderFrameImpl::UpdateURL(blink::WebFrame* frame) {
// Track the URL of the original request. We use the first entry of the
// redirect chain if it exists because the chain may have started in another
// process.
- if (params.redirects.size() > 0)
- params.original_request_url = params.redirects.at(0);
- else
- params.original_request_url = original_request.url();
+ params.original_request_url = GetOriginalRequestUrl(ds);
params.history_list_was_cleared =
navigation_state->history_list_was_cleared();
@@ -2281,4 +2277,22 @@ void RenderFrameImpl::didStopLoading() {
Send(new FrameHostMsg_DidStopLoading(routing_id_));
}
+GURL RenderFrameImpl::GetOriginalRequestUrl(WebDataSource* ds) {
darin (slow to review) 2014/03/11 20:04:32 nit: We aren't terribly consistent, but a quick gr
hush (inactive) 2014/03/12 21:34:21 Done
+ std::vector<GURL> redirects;
darin (slow to review) 2014/03/11 20:04:32 nit: I'd move this below the hasUnreachableURL bra
hush (inactive) 2014/03/12 21:34:21 Done
+ GetRedirectChain(ds, &redirects);
+
+ // The frame is loaded via WebFrame::loadData, where we pass the
darin (slow to review) 2014/03/11 20:04:32 nit: This comment needs some work. It appears to b
hush (inactive) 2014/03/12 21:34:21 Okay. I just reworded the comments by only referri
+ // history_url_for_data_url as unreachableURL in blink. The
+ // base_url_for_data_url will be in the redirect chain, but we
+ // never actually visited base_url_for_data_url. So we need to set
+ // history_url_for_data_url as the original_request_url.
+ if (ds->hasUnreachableURL())
+ return ds->unreachableURL();
+
+ if (redirects.size() > 0)
darin (slow to review) 2014/03/11 20:04:32 nit: I'd use the .empty() method here instead: if
hush (inactive) 2014/03/12 21:34:21 Done
+ return redirects.at(0);
+
+ return ds->originalRequest().url();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698