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

Side by Side Diff: Source/core/fetch/ResourceFetcher.h

Issue 47923008: Block execution of failed 'crossorigin' <script>s. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 7 years, 1 month 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 | « Source/core/fetch/FetchRequest.cpp ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | 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) 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 4 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
5 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 5 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 class XSLStyleSheetResource; 53 class XSLStyleSheetResource;
54 class Document; 54 class Document;
55 class DocumentLoader; 55 class DocumentLoader;
56 class Frame; 56 class Frame;
57 class FrameLoader; 57 class FrameLoader;
58 class ImageLoader; 58 class ImageLoader;
59 class KURL; 59 class KURL;
60 class ResourceTimingInfo; 60 class ResourceTimingInfo;
61 class ResourceLoaderSet; 61 class ResourceLoaderSet;
62 62
63 enum CORSEnabled {
64 NotCORSEnabled,
65 PotentiallyCORSEnabled // Indicates "potentially CORS-enabled fetch" in HTML standard.
66 };
67
63 // The ResourceFetcher provides a per-context interface to the MemoryCache 68 // The ResourceFetcher provides a per-context interface to the MemoryCache
64 // and enforces a bunch of security checks and rules for resource revalidation. 69 // and enforces a bunch of security checks and rules for resource revalidation.
65 // Its lifetime is roughly per-DocumentLoader, in that it is generally created 70 // Its lifetime is roughly per-DocumentLoader, in that it is generally created
66 // in the DocumentLoader constructor and loses its ability to generate network 71 // in the DocumentLoader constructor and loses its ability to generate network
67 // requests when the DocumentLoader is destroyed. Documents also hold a 72 // requests when the DocumentLoader is destroyed. Documents also hold a
68 // RefPtr<ResourceFetcher> for their lifetime (and will create one if they 73 // RefPtr<ResourceFetcher> for their lifetime (and will create one if they
69 // are initialized without a Frame), so a Document can keep a ResourceFetcher 74 // are initialized without a Frame), so a Document can keep a ResourceFetcher
70 // alive past detach if scripts still reference the Document. 75 // alive past detach if scripts still reference the Document.
71 class ResourceFetcher : public RefCounted<ResourceFetcher>, public ResourceLoade rHost { 76 class ResourceFetcher : public RefCounted<ResourceFetcher>, public ResourceLoade rHost {
72 WTF_MAKE_NONCOPYABLE(ResourceFetcher); WTF_MAKE_FAST_ALLOCATED; 77 WTF_MAKE_NONCOPYABLE(ResourceFetcher); WTF_MAKE_FAST_ALLOCATED;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 void garbageCollectDocumentResources(); 126 void garbageCollectDocumentResources();
122 127
123 int requestCount() const { return m_requestCount; } 128 int requestCount() const { return m_requestCount; }
124 129
125 bool isPreloaded(const String& urlString) const; 130 bool isPreloaded(const String& urlString) const;
126 void clearPreloads(); 131 void clearPreloads();
127 void clearPendingPreloads(); 132 void clearPendingPreloads();
128 void preload(Resource::Type, FetchRequest&, const String& charset); 133 void preload(Resource::Type, FetchRequest&, const String& charset);
129 void checkForPendingPreloads(); 134 void checkForPendingPreloads();
130 void printPreloadStats(); 135 void printPreloadStats();
131 bool canAccess(Resource*); 136 bool canAccess(Resource*, CORSEnabled, FetchRequest::OriginRestriction = Fet chRequest::UseDefaultOriginRestrictionForType);
132 137
133 void setDefersLoading(bool); 138 void setDefersLoading(bool);
134 void stopFetching(); 139 void stopFetching();
135 bool isFetching() const; 140 bool isFetching() const;
136 141
137 // ResourceLoaderHost 142 // ResourceLoaderHost
138 virtual void incrementRequestCount(const Resource*) OVERRIDE; 143 virtual void incrementRequestCount(const Resource*) OVERRIDE;
139 virtual void decrementRequestCount(const Resource*) OVERRIDE; 144 virtual void decrementRequestCount(const Resource*) OVERRIDE;
140 virtual void didLoadResource(Resource*) OVERRIDE; 145 virtual void didLoadResource(Resource*) OVERRIDE;
141 virtual void redirectReceived(Resource*, const ResourceResponse&) OVERRIDE; 146 virtual void redirectReceived(Resource*, const ResourceResponse&) OVERRIDE;
(...skipping 27 matching lines...) Expand all
169 void storeResourceTimingInitiatorInformation(const ResourcePtr<Resource>&, c onst FetchRequest&); 174 void storeResourceTimingInitiatorInformation(const ResourcePtr<Resource>&, c onst FetchRequest&);
170 void requestPreload(Resource::Type, FetchRequest&, const String& charset); 175 void requestPreload(Resource::Type, FetchRequest&, const String& charset);
171 176
172 enum RevalidationPolicy { Use, Revalidate, Reload, Load }; 177 enum RevalidationPolicy { Use, Revalidate, Reload, Load };
173 RevalidationPolicy determineRevalidationPolicy(Resource::Type, ResourceReque st&, bool forPreload, Resource* existingResource, FetchRequest::DeferOption) con st; 178 RevalidationPolicy determineRevalidationPolicy(Resource::Type, ResourceReque st&, bool forPreload, Resource* existingResource, FetchRequest::DeferOption) con st;
174 179
175 void determineTargetType(ResourceRequest&, Resource::Type); 180 void determineTargetType(ResourceRequest&, Resource::Type);
176 ResourceRequestCachePolicy resourceRequestCachePolicy(const ResourceRequest& , Resource::Type); 181 ResourceRequestCachePolicy resourceRequestCachePolicy(const ResourceRequest& , Resource::Type);
177 void addAdditionalRequestHeaders(ResourceRequest&, Resource::Type); 182 void addAdditionalRequestHeaders(ResourceRequest&, Resource::Type);
178 183
179 bool canRequest(Resource::Type, const KURL&, const ResourceLoaderOptions&, b ool forPreload = false); 184 bool canRequest(Resource::Type, const KURL&, const ResourceLoaderOptions&, b ool forPreload, FetchRequest::OriginRestriction);
180 bool checkInsecureContent(Resource::Type, const KURL&, MixedContentBlockingT reatment) const; 185 bool checkInsecureContent(Resource::Type, const KURL&, MixedContentBlockingT reatment) const;
181 186
182 static bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPo licy); 187 static bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPo licy);
183 188
184 void notifyLoadedFromMemoryCache(Resource*); 189 void notifyLoadedFromMemoryCache(Resource*);
185 190
186 void garbageCollectDocumentResourcesTimerFired(Timer<ResourceFetcher>*); 191 void garbageCollectDocumentResourcesTimerFired(Timer<ResourceFetcher>*);
187 void performPostLoadActions(); 192 void performPostLoadActions();
188 193
189 bool clientDefersImage(const KURL&) const; 194 bool clientDefersImage(const KURL&) const;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 m_loader->m_allowStaleResources = m_previousState; 242 m_loader->m_allowStaleResources = m_previousState;
238 } 243 }
239 private: 244 private:
240 ResourceFetcher* m_loader; 245 ResourceFetcher* m_loader;
241 bool m_previousState; 246 bool m_previousState;
242 }; 247 };
243 248
244 } // namespace WebCore 249 } // namespace WebCore
245 250
246 #endif 251 #endif
OLDNEW
« no previous file with comments | « Source/core/fetch/FetchRequest.cpp ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698