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

Side by Side Diff: content/renderer/fetchers/resource_fetcher_impl.cc

Issue 135973009: Don't try to guess the referrer policy, but use the one associated with the request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/fetchers/resource_fetcher_impl.h" 5 #include "content/renderer/fetchers/resource_fetcher_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h"
8 #include "base/time/time.h" 9 #include "base/time/time.h"
9 #include "third_party/WebKit/public/platform/Platform.h" 10 #include "third_party/WebKit/public/platform/Platform.h"
10 #include "third_party/WebKit/public/platform/WebHTTPBody.h" 11 #include "third_party/WebKit/public/platform/WebHTTPBody.h"
11 #include "third_party/WebKit/public/platform/WebURL.h" 12 #include "third_party/WebKit/public/platform/WebURL.h"
12 #include "third_party/WebKit/public/platform/WebURLError.h" 13 #include "third_party/WebKit/public/platform/WebURLError.h"
13 #include "third_party/WebKit/public/platform/WebURLLoader.h" 14 #include "third_party/WebKit/public/platform/WebURLLoader.h"
14 #include "third_party/WebKit/public/platform/WebURLRequest.h" 15 #include "third_party/WebKit/public/platform/WebURLRequest.h"
15 #include "third_party/WebKit/public/web/WebDocument.h" 16 #include "third_party/WebKit/public/web/WebDocument.h"
16 #include "third_party/WebKit/public/web/WebFrame.h" 17 #include "third_party/WebKit/public/web/WebFrame.h"
17 #include "third_party/WebKit/public/web/WebKit.h" 18 #include "third_party/WebKit/public/web/WebKit.h"
19 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
18 20
19 using base::TimeDelta; 21 using base::TimeDelta;
20 using blink::WebFrame; 22 using blink::WebFrame;
21 using blink::WebHTTPBody; 23 using blink::WebHTTPBody;
24 using blink::WebSecurityPolicy;
22 using blink::WebURLError; 25 using blink::WebURLError;
23 using blink::WebURLLoader; 26 using blink::WebURLLoader;
24 using blink::WebURLRequest; 27 using blink::WebURLRequest;
25 using blink::WebURLResponse; 28 using blink::WebURLResponse;
26 29
27 namespace content { 30 namespace content {
28 31
29 // static 32 // static
30 ResourceFetcher* ResourceFetcher::Create(const GURL& url) { 33 ResourceFetcher* ResourceFetcher::Create(const GURL& url) {
31 return new ResourceFetcherImpl(url); 34 return new ResourceFetcherImpl(url);
(...skipping 24 matching lines...) Expand all
56 web_http_body.initialize(); 59 web_http_body.initialize();
57 web_http_body.appendData(blink::WebData(body)); 60 web_http_body.appendData(blink::WebData(body));
58 request_.setHTTPBody(web_http_body); 61 request_.setHTTPBody(web_http_body);
59 } 62 }
60 63
61 void ResourceFetcherImpl::SetHeader(const std::string& header, 64 void ResourceFetcherImpl::SetHeader(const std::string& header,
62 const std::string& value) { 65 const std::string& value) {
63 DCHECK(!request_.isNull()); 66 DCHECK(!request_.isNull());
64 DCHECK(!loader_); 67 DCHECK(!loader_);
65 68
66 request_.setHTTPHeaderField(blink::WebString::fromUTF8(header), 69 if (LowerCaseEqualsASCII(header, "referer")) {
67 blink::WebString::fromUTF8(value)); 70 blink::WebString referrer = WebSecurityPolicy::generateReferrerHeader(
71 blink::WebReferrerPolicyDefault,
72 request_.url(),
73 blink::WebString::fromUTF8(value));
74 request_.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault);
75 } else {
76 request_.setHTTPHeaderField(blink::WebString::fromUTF8(header),
77 blink::WebString::fromUTF8(value));
78 }
68 } 79 }
69 80
70 void ResourceFetcherImpl::Start(WebFrame* frame, 81 void ResourceFetcherImpl::Start(WebFrame* frame,
71 WebURLRequest::TargetType target_type, 82 WebURLRequest::TargetType target_type,
72 const Callback& callback) { 83 const Callback& callback) {
73 DCHECK(!loader_); 84 DCHECK(!loader_);
74 DCHECK(!request_.isNull()); 85 DCHECK(!request_.isNull());
75 DCHECK(callback_.is_null()); 86 DCHECK(callback_.is_null());
76 DCHECK(!completed_); 87 DCHECK(!completed_);
77 if (!request_.httpBody().isNull()) 88 if (!request_.httpBody().isNull())
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 172
162 void ResourceFetcherImpl::didFail(WebURLLoader* loader, 173 void ResourceFetcherImpl::didFail(WebURLLoader* loader,
163 const WebURLError& error) { 174 const WebURLError& error) {
164 DCHECK(!completed_); 175 DCHECK(!completed_);
165 176
166 // Go ahead and tell our delegate that we're done. 177 // Go ahead and tell our delegate that we're done.
167 RunCallback(WebURLResponse(), std::string()); 178 RunCallback(WebURLResponse(), std::string());
168 } 179 }
169 180
170 } // namespace content 181 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/renderer/internal_document_state_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698