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

Side by Side Diff: third_party/WebKit/Source/core/loader/BaseFetchContext.h

Issue 2823213002: Implement CanRequest in BaseFetchContext (Closed)
Patch Set: rebase, tests Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef BaseFetchContext_h 5 #ifndef BaseFetchContext_h
6 #define BaseFetchContext_h 6 #define BaseFetchContext_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/frame/UseCounter.h"
10 #include "core/frame/csp/ContentSecurityPolicy.h"
10 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
11 #include "platform/loader/fetch/FetchContext.h" 12 #include "platform/loader/fetch/FetchContext.h"
12 #include "platform/loader/fetch/ResourceRequest.h" 13 #include "platform/loader/fetch/ResourceRequest.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
17 class ContentSettingsClient;
18 class ExecutionContext;
19 class SecurityContext;
20 class Settings;
21 class SubresourceFilter;
22
23 // A core-level implementaiton of FetchContext that does not depend on
24 // Frame. This class provides basic default implementation for some methods.
16 class CORE_EXPORT BaseFetchContext : public FetchContext { 25 class CORE_EXPORT BaseFetchContext : public FetchContext {
17 public: 26 public:
18 explicit BaseFetchContext(ExecutionContext*); 27 explicit BaseFetchContext(ExecutionContext*);
19 ~BaseFetchContext() override { execution_context_ = nullptr; } 28 ~BaseFetchContext() override { execution_context_ = nullptr; }
20 29
21 void AddAdditionalRequestHeaders(ResourceRequest&, 30 void AddAdditionalRequestHeaders(ResourceRequest&,
22 FetchResourceType) override; 31 FetchResourceType) override;
32 ResourceRequestBlockedReason CanRequest(
33 Resource::Type,
34 const ResourceRequest&,
35 const KURL&,
36 const ResourceLoaderOptions&,
37 SecurityViolationReportingPolicy,
38 FetchParameters::OriginRestriction) const override;
39 ResourceRequestBlockedReason CanFollowRedirect(
40 Resource::Type,
41 const ResourceRequest&,
42 const KURL&,
43 const ResourceLoaderOptions&,
44 SecurityViolationReportingPolicy,
45 FetchParameters::OriginRestriction) const override;
46 ResourceRequestBlockedReason AllowResponse(
47 Resource::Type,
48 const ResourceRequest&,
49 const KURL&,
50 const ResourceLoaderOptions&) const override;
23 SecurityOrigin* GetSecurityOrigin() const override; 51 SecurityOrigin* GetSecurityOrigin() const override;
24 52
25 DECLARE_VIRTUAL_TRACE(); 53 DECLARE_VIRTUAL_TRACE();
26 54
27 protected: 55 protected:
56 // Used for security checks. It is valid that they return nullptr,
57 // while returning nullptr may result in disable some security checks.
58 virtual ContentSettingsClient* GetContentSettingsClient() const = 0;
59 virtual Settings* GetSettings() const = 0;
60 virtual SubresourceFilter* GetSubresourceFilter() const = 0;
61 virtual SecurityContext* GetMainResourceSecurityContext() const = 0;
62
63 // Note: subclasses are expected to override following methods.
64 // Used in the default implementation for CanRequest, CanFollowRedirect
65 // and AllowResponse.
66 virtual bool ShouldBlockRequestByInspector(const ResourceRequest&) const = 0;
67 virtual void DispatchDidBlockRequest(const ResourceRequest&,
68 const FetchInitiatorInfo&,
69 ResourceRequestBlockedReason) const = 0;
70 virtual void ReportLocalLoadFailed(const KURL&) const = 0;
71 virtual bool ShouldBypassMainWorldCSP() const = 0;
72 virtual bool IsSVGImageChromeClient() const = 0;
73 virtual void CountUsage(UseCounter::Feature) const = 0;
74 virtual void CountDeprecation(UseCounter::Feature) const = 0;
75 virtual bool ShouldBlockFetchByMixedContentCheck(
76 const ResourceRequest&,
77 const KURL&,
78 SecurityViolationReportingPolicy) const = 0;
79
80 // Utility method that can be used to implement other methods.
28 void PrintAccessDeniedMessage(const KURL&) const; 81 void PrintAccessDeniedMessage(const KURL&) const;
Nate Chapin 2017/04/21 18:33:07 Nit: I think this can be private now.
29 void AddCSPHeaderIfNecessary(Resource::Type, ResourceRequest&); 82 void AddCSPHeaderIfNecessary(Resource::Type, ResourceRequest&);
83 ResourceRequestBlockedReason CheckCSPForRequest(
84 const ResourceRequest&,
85 const KURL&,
86 const ResourceLoaderOptions&,
87 SecurityViolationReportingPolicy,
88 ResourceRequest::RedirectStatus,
89 ContentSecurityPolicy::CheckHeaderType) const;
90
91 // Utility methods that are used in default implement for CanRequest,
92 // CanFollowRedirect and AllowResponse.
93 ResourceRequestBlockedReason CanRequestInternal(
94 Resource::Type,
95 const ResourceRequest&,
96 const KURL&,
97 const ResourceLoaderOptions&,
98 SecurityViolationReportingPolicy,
99 FetchParameters::OriginRestriction,
100 ResourceRequest::RedirectStatus) const;
30 101
31 // FIXME: Oilpan: Ideally this should just be a traced Member but that will 102 // FIXME: Oilpan: Ideally this should just be a traced Member but that will
32 // currently leak because ComputedStyle and its data are not on the heap. 103 // currently leak because ComputedStyle and its data are not on the heap.
33 // See crbug.com/383860 for details. 104 // See crbug.com/383860 for details.
34 WeakMember<ExecutionContext> execution_context_; 105 WeakMember<ExecutionContext> execution_context_;
35 }; 106 };
36 107
37 } // namespace blink 108 } // namespace blink
38 109
39 #endif // BaseFetchContext_h 110 #endif // BaseFetchContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698