1 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_DOCUMENT_SUBRESOURCE_FILTER_H_ 6 #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_DOCUMENT_SUBRESOURCE_FILTER_H_ 7 8 #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h" 9 10 namespace blink { 11 12 class WebURL; 13 14 class WebDocumentSubresourceFilter { 15 public: 16 // This builder class is created on the main thread and passed to a worker 17 // thread to create the subresource filter for the worker thread. 18 class Builder { 19 public: 20 virtual ~Builder() = default; 21 virtual std::unique_ptr<WebDocumentSubresourceFilter> Build() = 0; 22 }; 23 24 enum LoadPolicy { kAllow, kDisallow, kWouldDisallow }; 25 26 virtual ~WebDocumentSubresourceFilter() = default; 27 virtual LoadPolicy GetLoadPolicy(const WebURL& resource_url, 28 mojom::RequestContextType) = 0; 29 virtual LoadPolicy GetLoadPolicyForWebSocketConnect(const WebURL&) = 0; 30 31 // Report that a resource loaded by the document (not a preload) was 32 // disallowed. 33 virtual void ReportDisallowedLoad() = 0; 34 35 // Returns true if disallowed resource loads should be logged to the devtools 36 // console. 37 virtual bool ShouldLogToConsole() = 0; 38 39 // Report that the resource request corresponding to |request_id| was tagged 40 // as an ad. ReportAdRequestId(int request_id)41 virtual void ReportAdRequestId(int request_id) {} 42 }; 43 44 } // namespace blink 45 46 #endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_DOCUMENT_SUBRESOURCE_FILTER_H_ 47