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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ScriptResource.h

Issue 1675183003: Fix SRI bypass by loading same resource twice in same origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Rebase on ToT Created 4 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
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 16 matching lines...) Expand all
27 #define ScriptResource_h 27 #define ScriptResource_h
28 28
29 #include "core/CoreExport.h" 29 #include "core/CoreExport.h"
30 #include "core/fetch/IntegrityMetadata.h" 30 #include "core/fetch/IntegrityMetadata.h"
31 #include "core/fetch/ResourceClient.h" 31 #include "core/fetch/ResourceClient.h"
32 #include "core/fetch/TextResource.h" 32 #include "core/fetch/TextResource.h"
33 #include "platform/text/CompressibleString.h" 33 #include "platform/text/CompressibleString.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 enum class ScriptIntegrityDisposition {
38 NotChecked = 0,
39 Failed,
40 Passed
41 };
42
37 class FetchRequest; 43 class FetchRequest;
38 class ScriptResource; 44 class ScriptResource;
39 45
40 class CORE_EXPORT ScriptResourceClient : public ResourceClient { 46 class CORE_EXPORT ScriptResourceClient : public ResourceClient {
41 public: 47 public:
42 ~ScriptResourceClient() override {} 48 ~ScriptResourceClient() override {}
43 static ResourceClientType expectedType() { return ScriptType; } 49 static ResourceClientType expectedType() { return ScriptType; }
44 ResourceClientType resourceClientType() const final { return expectedType(); } 50 ResourceClientType resourceClientType() const final { return expectedType(); }
45 51
46 virtual void notifyAppendData(ScriptResource* resource) { } 52 virtual void notifyAppendData(ScriptResource* resource) { }
(...skipping 20 matching lines...) Expand all
67 void destroyDecodedDataForFailedRevalidation() override; 73 void destroyDecodedDataForFailedRevalidation() override;
68 74
69 const CompressibleString& script(); 75 const CompressibleString& script();
70 76
71 AtomicString mimeType() const; 77 AtomicString mimeType() const;
72 78
73 bool mimeTypeAllowedByNosniff() const; 79 bool mimeTypeAllowedByNosniff() const;
74 80
75 void setIntegrityMetadata(const IntegrityMetadataSet& metadata) { m_integrit yMetadata = metadata; } 81 void setIntegrityMetadata(const IntegrityMetadataSet& metadata) { m_integrit yMetadata = metadata; }
76 const IntegrityMetadataSet& integrityMetadata() const { return m_integrityMe tadata; } 82 const IntegrityMetadataSet& integrityMetadata() const { return m_integrityMe tadata; }
77 void setIntegrityAlreadyChecked(bool checked) { m_integrityChecked = checked ; } 83 // The argument must never be |NotChecked|.
78 bool integrityAlreadyChecked() { return m_integrityChecked; } 84 void setIntegrityDisposition(ScriptIntegrityDisposition);
85 ScriptIntegrityDisposition integrityDisposition() { return m_integrityDispos ition; }
79 bool mustRefetchDueToIntegrityMetadata(const FetchRequest&) const override; 86 bool mustRefetchDueToIntegrityMetadata(const FetchRequest&) const override;
80 87
81 private: 88 private:
82 class ScriptResourceFactory : public ResourceFactory { 89 class ScriptResourceFactory : public ResourceFactory {
83 public: 90 public:
84 ScriptResourceFactory() 91 ScriptResourceFactory()
85 : ResourceFactory(Resource::Script) { } 92 : ResourceFactory(Resource::Script) { }
86 93
87 PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& request, const String& charset) const override 94 PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& request, const String& charset) const override
88 { 95 {
89 return adoptRefWillBeNoop(new ScriptResource(request, charset)); 96 return adoptRefWillBeNoop(new ScriptResource(request, charset));
90 } 97 }
91 }; 98 };
92 99
93 ScriptResource(const ResourceRequest&, const String& charset); 100 ScriptResource(const ResourceRequest&, const String& charset);
94 101
95 bool m_integrityChecked; 102 ScriptIntegrityDisposition m_integrityDisposition;
96 IntegrityMetadataSet m_integrityMetadata; 103 IntegrityMetadataSet m_integrityMetadata;
97 104
98 CompressibleString m_script; 105 CompressibleString m_script;
99 }; 106 };
100 107
101 DEFINE_RESOURCE_TYPE_CASTS(Script); 108 DEFINE_RESOURCE_TYPE_CASTS(Script);
102 109
103 } // namespace blink 110 } // namespace blink
104 111
105 #endif 112 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/PendingScript.cpp ('k') | third_party/WebKit/Source/core/fetch/ScriptResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698