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

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: Rebase correctly Created 6 years, 8 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/public/test/content_browser_test_utils.cc ('k') | content/shell/browser/shell.h » ('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 9286bf4967089a53745fd6c09ceb5058f9dbe691..a088661633d144135611d95f83b8200077448e13 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -176,6 +176,25 @@ void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
}
}
+// Returns the original request url. If there is no redirect, the original
+// url is the same as ds->request()->url(). If the WebDataSource belongs to a
+// frame was loaded by loadData, the original url will be ds->unreachableURL()
+static GURL GetOriginalRequestURL(WebDataSource* ds) {
+ // WebDataSource has unreachable URL means that the frame is loaded through
+ // blink::WebFrame::loadData(), and the base URL will be in the redirect
+ // chain. However, we never visited the baseURL. So in this case, we should
+ // use the unreachable URL as the original URL.
+ if (ds->hasUnreachableURL())
+ return ds->unreachableURL();
+
+ std::vector<GURL> redirects;
+ GetRedirectChain(ds, &redirects);
+ if (!redirects.empty())
+ return redirects.at(0);
+
+ return ds->originalRequest().url();
+}
+
NOINLINE static void CrashIntentionally() {
// NOTE(shess): Crash directly rather than using NOTREACHED() so
// that the signature is easier to triage in crash reports.
@@ -2642,7 +2661,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);
@@ -2763,10 +2781,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();
« no previous file with comments | « content/public/test/content_browser_test_utils.cc ('k') | content/shell/browser/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698