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

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: 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_impl_unittest.cc » ('j') | 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 209b20bd42ea3ed1cf75a673d3d1c1ef659e9f85..9680817bca827e9b6571da58717822efb7689bd5 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -135,7 +135,10 @@ WebURLResponseExtraDataImpl* GetExtraDataFromResponse(
response.extraData());
}
-void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
+void GetRedirectChain(const WebDataSource* ds, std::vector<GURL>* result) {
Charlie Reis 2014/03/03 18:21:11 Please don't change this signature. (Why make the
hush (inactive) 2014/03/03 23:12:52 http://google-styleguide.googlecode.com/svn/trunk/
Charlie Reis 2014/03/04 20:32:03 Yes, we generally don't put const on pointer param
hush (inactive) 2014/03/04 23:22:33 Done.
+ if (!result || !ds) {
Charlie Reis 2014/03/03 18:21:11 style nit: No braces for a one-line body. In what
hush (inactive) 2014/03/03 23:12:52 I was just doing this defensively in case that cod
Charlie Reis 2014/03/04 20:32:03 Yes, please remove them. Better to crash early if
hush (inactive) 2014/03/04 23:22:33 Done.
+ return;
+ }
// Replace any occurrences of swappedout:// with about:blank.
const WebURL& blank_url = GURL(kAboutBlankURL);
WebVector<WebURL> urls;
@@ -2106,7 +2109,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 +2229,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 +2280,29 @@ void RenderFrameImpl::didStopLoading() {
Send(new FrameHostMsg_DidStopLoading(routing_id_));
}
+const GURL RenderFrameImpl::GetOriginalRequestUrl(const WebDataSource* ds) {
Charlie Reis 2014/03/03 18:21:11 No const in either part.
hush (inactive) 2014/03/03 23:12:52 Please see the previous reply about "const"
+ if (!ds) {
Charlie Reis 2014/03/03 18:21:11 This check seems unnecessary.
hush (inactive) 2014/03/03 23:12:52 Please the previous reply about null check.
+ return GURL();
+ }
+
+ std::vector<GURL> redirects;
+ GetRedirectChain(ds, &redirects);
+
+ if (ds->hasUnreachableURL()) {
+ // The frame is loaded via WebFrame::loadData, where we pass the
+ // history_url_for_data_url as unreachableURL in blink. The
Charlie Reis 2014/03/03 18:21:11 I'm not sure this comment is accurate. That's not
hush (inactive) 2014/03/03 23:12:52 You are right, error page uses unreachableURL as w
Charlie Reis 2014/03/04 20:32:03 That's a behavior change that I'm not sure how to
+ // 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.
+ return ds->unreachableURL();
+ }
+
+ if (redirects.size() > 0) {
Charlie Reis 2014/03/03 18:21:11 No braces for a one-line body.
hush (inactive) 2014/03/03 23:12:52 Okay
+ return redirects.at(0);
+ }
+ else {
Charlie Reis 2014/03/03 18:21:11 No need for an else block if your if block returns
hush (inactive) 2014/03/03 23:12:52 okay
+ return ds->originalRequest().url();
+ }
+}
+
} // namespace content
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698