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

Side by Side Diff: third_party/WebKit/Source/core/loader/HttpEquiv.cpp

Issue 1833063002: Store the list of trial tokens in OriginTrialContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/loader/HttpEquiv.h" 5 #include "core/loader/HttpEquiv.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ScriptableDocumentParser.h"
8 #include "core/dom/StyleEngine.h" 9 #include "core/dom/StyleEngine.h"
9 #include "core/fetch/ClientHintsPreferences.h" 10 #include "core/fetch/ClientHintsPreferences.h"
10 #include "core/frame/UseCounter.h" 11 #include "core/frame/UseCounter.h"
11 #include "core/frame/csp/ContentSecurityPolicy.h" 12 #include "core/frame/csp/ContentSecurityPolicy.h"
12 #include "core/html/HTMLDocument.h" 13 #include "core/html/HTMLDocument.h"
13 #include "core/inspector/ConsoleMessage.h" 14 #include "core/inspector/ConsoleMessage.h"
14 #include "core/loader/DocumentLoader.h" 15 #include "core/loader/DocumentLoader.h"
16 #include "core/origin_trials/OriginTrials.h"
15 #include "platform/network/HTTPParsers.h" 17 #include "platform/network/HTTPParsers.h"
16 #include "platform/weborigin/KURL.h" 18 #include "platform/weborigin/KURL.h"
17 19
18 namespace blink { 20 namespace blink {
19 21
20 void HttpEquiv::process(Document& document, const AtomicString& equiv, const Ato micString& content, bool inDocumentHeadElement) 22 void HttpEquiv::process(Document& document, const AtomicString& equiv, const Ato micString& content, bool inDocumentHeadElement)
21 { 23 {
22 ASSERT(!equiv.isNull() && !content.isNull()); 24 ASSERT(!equiv.isNull() && !content.isNull());
23 25
24 if (equalIgnoringCase(equiv, "default-style")) { 26 if (equalIgnoringCase(equiv, "default-style")) {
(...skipping 10 matching lines...) Expand all
35 processHttpEquivXFrameOptions(document, content); 37 processHttpEquivXFrameOptions(document, content);
36 } else if (equalIgnoringCase(equiv, "accept-ch")) { 38 } else if (equalIgnoringCase(equiv, "accept-ch")) {
37 processHttpEquivAcceptCH(document, content); 39 processHttpEquivAcceptCH(document, content);
38 } else if (equalIgnoringCase(equiv, "content-security-policy") || equalIgnor ingCase(equiv, "content-security-policy-report-only")) { 40 } else if (equalIgnoringCase(equiv, "content-security-policy") || equalIgnor ingCase(equiv, "content-security-policy-report-only")) {
39 if (inDocumentHeadElement) 41 if (inDocumentHeadElement)
40 processHttpEquivContentSecurityPolicy(document, equiv, content); 42 processHttpEquivContentSecurityPolicy(document, equiv, content);
41 else 43 else
42 document.contentSecurityPolicy()->reportMetaOutsideHead(content); 44 document.contentSecurityPolicy()->reportMetaOutsideHead(content);
43 } else if (equalIgnoringCase(equiv, "suborigin")) { 45 } else if (equalIgnoringCase(equiv, "suborigin")) {
44 document.addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, "Error with Suborigin header: Suborigin header with value '" + content + "' was delivered via a <meta> element and not an HTTP header, which is disallowed. The Suborigin has been ignored.")); 46 document.addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, "Error with Suborigin header: Suborigin header with value '" + content + "' was delivered via a <meta> element and not an HTTP header, which is disallowed. The Suborigin has been ignored."));
47 } else if (equalIgnoringCase(equiv, HTTPNames::Origin_Trial)) {
iclelland 2016/03/31 15:00:00 I like using HTTPNames here -- do you have any ide
Marijn Kruisselbrink 2016/03/31 19:01:48 No idea, so maybe core/ owners will object to usin
iclelland 2016/04/01 15:19:09 Okay; we should be explicit and #include "platform
48 bool isScriptGenerated = document.hasFinishedParsing() || (document.scri ptableDocumentParser() && document.scriptableDocumentParser()->isExecutingScript ());
Marijn Kruisselbrink 2016/03/25 19:08:39 I'm not sure if this is entirely the right check t
iclelland 2016/03/31 15:00:00 You can see what I'd done in https://codereview.ch
Marijn Kruisselbrink 2016/03/31 19:01:48 Yeah, I wasn't sure what situations we actually wa
iclelland 2016/04/01 15:19:09 Let's keep this here, then -- I haven't been able
Marijn Kruisselbrink 2016/04/01 23:54:47 I started trying to specify what behavior we're ai
iclelland 2016/04/05 17:26:28 Out of a bunch of discussions, so a spec is probab
Marijn Kruisselbrink 2016/04/05 20:56:08 Hmmm, okay. At least it seems the code in this CL
49 if (!isScriptGenerated)
50 OriginTrials::from(&document)->addToken(content);
45 } 51 }
46 } 52 }
47 53
48 void HttpEquiv::processHttpEquivContentSecurityPolicy(Document& document, const AtomicString& equiv, const AtomicString& content) 54 void HttpEquiv::processHttpEquivContentSecurityPolicy(Document& document, const AtomicString& equiv, const AtomicString& content)
49 { 55 {
50 if (document.importLoader()) 56 if (document.importLoader())
51 return; 57 return;
52 if (equalIgnoringCase(equiv, "content-security-policy")) 58 if (equalIgnoringCase(equiv, "content-security-policy"))
53 document.contentSecurityPolicy()->didReceiveHeader(content, ContentSecur ityPolicyHeaderTypeEnforce, ContentSecurityPolicyHeaderSourceMeta); 59 document.contentSecurityPolicy()->didReceiveHeader(content, ContentSecur ityPolicyHeaderTypeEnforce, ContentSecurityPolicyHeaderSourceMeta);
54 else if (equalIgnoringCase(equiv, "content-security-policy-report-only")) 60 else if (equalIgnoringCase(equiv, "content-security-policy-report-only"))
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 frame->loader().stopAllLoaders(); 110 frame->loader().stopAllLoaders();
105 // Stopping the loader isn't enough, as we're already parsing the document; to honor the header's 111 // Stopping the loader isn't enough, as we're already parsing the document; to honor the header's
106 // intent, we must navigate away from the possibly partially-rendered docume nt to a location that 112 // intent, we must navigate away from the possibly partially-rendered docume nt to a location that
107 // doesn't inherit the parent's SecurityOrigin. 113 // doesn't inherit the parent's SecurityOrigin.
108 // TODO(dglazkov): This should probably check document lifecycle instead. 114 // TODO(dglazkov): This should probably check document lifecycle instead.
109 if (document.frame()) 115 if (document.frame())
110 frame->navigate(document, SecurityOrigin::urlWithUniqueSecurityOrigin(), true, UserGestureStatus::None); 116 frame->navigate(document, SecurityOrigin::urlWithUniqueSecurityOrigin(), true, UserGestureStatus::None);
111 } 117 }
112 118
113 } // namespace blink 119 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698