Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 #include "platform/loader/fetch/FetchContext.h" | 11 #include "platform/loader/fetch/FetchContext.h" |
| 12 #include "platform/loader/fetch/ResourceRequest.h" | 12 #include "platform/loader/fetch/ResourceRequest.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class ContentSettingsClient; | |
| 17 class ExecutionContext; | |
| 18 class SecurityContext; | |
| 19 class Settings; | |
| 20 class SubresourceFilter; | |
| 21 | |
| 22 // A core-level implementaiton of FetchContext that does not depend on | |
| 23 // Frame. This class provides basic default implementation for some methods. | |
| 16 class CORE_EXPORT BaseFetchContext : public FetchContext { | 24 class CORE_EXPORT BaseFetchContext : public FetchContext { |
| 17 public: | 25 public: |
| 18 explicit BaseFetchContext(ExecutionContext*); | 26 explicit BaseFetchContext(ExecutionContext*); |
| 19 ~BaseFetchContext() override { execution_context_ = nullptr; } | 27 ~BaseFetchContext() override { execution_context_ = nullptr; } |
| 20 | 28 |
| 21 void AddAdditionalRequestHeaders(ResourceRequest&, | 29 void AddAdditionalRequestHeaders(ResourceRequest&, |
| 22 FetchResourceType) override; | 30 FetchResourceType) override; |
| 31 ResourceRequestBlockedReason CanRequest( | |
| 32 Resource::Type, | |
| 33 const ResourceRequest&, | |
| 34 const KURL&, | |
| 35 const ResourceLoaderOptions&, | |
| 36 SecurityViolationReportingPolicy, | |
| 37 FetchParameters::OriginRestriction) const override; | |
| 38 ResourceRequestBlockedReason AllowResponse( | |
| 39 Resource::Type, | |
| 40 const ResourceRequest&, | |
| 41 const KURL&, | |
| 42 const ResourceLoaderOptions&) const override; | |
| 23 SecurityOrigin* GetSecurityOrigin() const override; | 43 SecurityOrigin* GetSecurityOrigin() const override; |
| 24 | 44 |
| 25 DECLARE_VIRTUAL_TRACE(); | 45 DECLARE_VIRTUAL_TRACE(); |
| 26 | 46 |
| 27 protected: | 47 protected: |
| 48 // Used for security checks. It is valid that they return nullptr, | |
| 49 // while returning nullptr may result in disable some security checks. | |
| 50 virtual ContentSettingsClient* GetContentSettingsClient() const = 0; | |
| 51 virtual Settings* GetSettings() const = 0; | |
| 52 virtual SubresourceFilter* GetSubresourceFilter() const = 0; | |
| 53 virtual SecurityContext* GetMainResourceSecurityContext() const = 0; | |
| 54 | |
| 55 // Note: subclasses are expected to override following methods. | |
| 56 // Used in the default implementation for CanRequest() and AllowResponse(). | |
| 57 virtual bool ShouldBlockRequestByInspector(const ResourceRequest&) const = 0; | |
| 58 virtual void DispatchDidBlockRequest(const ResourceRequest&, | |
| 59 const FetchInitiatorInfo&, | |
| 60 ResourceRequestBlockedReason) const = 0; | |
| 61 virtual void ReportLocalLoadFailed(const KURL&) const = 0; | |
| 62 virtual bool ShouldBypassMainWorldCSP() const = 0; | |
| 63 virtual bool IsSVGImageChromeClient() const = 0; | |
| 64 virtual void CountUsage(UseCounter::Feature) const = 0; | |
|
horo
2017/04/19 11:38:39
Why don't you directly call CountUsage(execution_c
kinuko
2017/04/20 02:33:22
This one's a bit tricky, GetFrame()->GetDocument()
horo
2017/04/20 06:00:48
Ah, I got it.
| |
| 65 virtual void CountDeprecation(UseCounter::Feature) const = 0; | |
|
horo
2017/04/19 11:38:39
same as CountUsage.
| |
| 66 virtual bool ShouldBlockFetchByMixedContentCheck( | |
| 67 const ResourceRequest&, | |
| 68 const KURL&, | |
| 69 SecurityViolationReportingPolicy) const = 0; | |
| 70 | |
| 71 // Utility method that can be used to implement other methods. | |
| 28 void PrintAccessDeniedMessage(const KURL&) const; | 72 void PrintAccessDeniedMessage(const KURL&) const; |
| 29 void AddCSPHeaderIfNecessary(Resource::Type, ResourceRequest&); | 73 void AddCSPHeaderIfNecessary(Resource::Type, ResourceRequest&); |
| 30 | 74 |
| 75 // Utility method that is used in default implement for CanRequest and | |
| 76 // AllowResponse. | |
| 77 ResourceRequestBlockedReason CanRequestInternal( | |
| 78 Resource::Type, | |
| 79 const ResourceRequest&, | |
| 80 const KURL&, | |
| 81 const ResourceLoaderOptions&, | |
| 82 SecurityViolationReportingPolicy, | |
| 83 FetchParameters::OriginRestriction, | |
| 84 ResourceRequest::RedirectStatus) const; | |
| 85 | |
| 31 // FIXME: Oilpan: Ideally this should just be a traced Member but that will | 86 // 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. | 87 // currently leak because ComputedStyle and its data are not on the heap. |
| 33 // See crbug.com/383860 for details. | 88 // See crbug.com/383860 for details. |
| 34 WeakMember<ExecutionContext> execution_context_; | 89 WeakMember<ExecutionContext> execution_context_; |
| 35 }; | 90 }; |
| 36 | 91 |
| 37 } // namespace blink | 92 } // namespace blink |
| 38 | 93 |
| 39 #endif // BaseFetchContext_h | 94 #endif // BaseFetchContext_h |
| OLD | NEW |