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

Side by Side Diff: third_party/WebKit/Source/core/html/LinkResource.cpp

Issue 2495313002: Add referrerpolicy to style and import (Closed)
Patch Set: Fixed import tests Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/resources/pass-if-no-referrer.php ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/html/LinkResource.h" 31 #include "core/html/LinkResource.h"
32 32
33 #include "core/HTMLNames.h" 33 #include "core/HTMLNames.h"
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/html/HTMLLinkElement.h" 35 #include "core/html/HTMLLinkElement.h"
36 #include "core/html/imports/HTMLImportsController.h" 36 #include "core/html/imports/HTMLImportsController.h"
37 #include "platform/weborigin/SecurityPolicy.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
40 using namespace HTMLNames; 41 using namespace HTMLNames;
41 42
42 LinkResource::LinkResource(HTMLLinkElement* owner) : m_owner(owner) {} 43 LinkResource::LinkResource(HTMLLinkElement* owner) : m_owner(owner) {}
43 44
44 LinkResource::~LinkResource() {} 45 LinkResource::~LinkResource() {}
45 46
46 bool LinkResource::shouldLoadResource() const { 47 bool LinkResource::shouldLoadResource() const {
(...skipping 13 matching lines...) Expand all
60 } 61 }
61 62
62 LinkRequestBuilder::LinkRequestBuilder(HTMLLinkElement* owner) 63 LinkRequestBuilder::LinkRequestBuilder(HTMLLinkElement* owner)
63 : m_owner(owner), m_url(owner->getNonEmptyURLAttribute(hrefAttr)) { 64 : m_owner(owner), m_url(owner->getNonEmptyURLAttribute(hrefAttr)) {
64 m_charset = m_owner->getAttribute(charsetAttr); 65 m_charset = m_owner->getAttribute(charsetAttr);
65 if (m_charset.isEmpty() && m_owner->document().frame()) 66 if (m_charset.isEmpty() && m_owner->document().frame())
66 m_charset = m_owner->document().characterSet(); 67 m_charset = m_owner->document().characterSet();
67 } 68 }
68 69
69 FetchRequest LinkRequestBuilder::build(bool lowPriority) const { 70 FetchRequest LinkRequestBuilder::build(bool lowPriority) const {
70 FetchRequest request(ResourceRequest(m_owner->document().completeURL(m_url)), 71 ResourceRequest resourceRequest(m_owner->document().completeURL(m_url));
71 m_owner->localName(), m_charset); 72 ReferrerPolicy referrerPolicy = m_owner->referrerPolicy();
73 if (referrerPolicy != ReferrerPolicyDefault) {
jochen (gone - plz use gerrit) 2017/01/03 08:41:49 why this if() ?
Yoav Weiss 2017/01/03 09:03:48 I was basing that code on ImageLoader.cpp:304 whic
74 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer(
75 referrerPolicy, m_url, m_owner->document().outgoingReferrer()));
76 }
77 FetchRequest request(resourceRequest, m_owner->localName(), m_charset);
72 if (lowPriority) 78 if (lowPriority)
73 request.setDefer(FetchRequest::LazyLoad); 79 request.setDefer(FetchRequest::LazyLoad);
74 request.setContentSecurityPolicyNonce( 80 request.setContentSecurityPolicyNonce(
75 m_owner->fastGetAttribute(HTMLNames::nonceAttr)); 81 m_owner->fastGetAttribute(HTMLNames::nonceAttr));
76 return request; 82 return request;
77 } 83 }
78 84
79 } // namespace blink 85 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/resources/pass-if-no-referrer.php ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698