// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_ASYNC_DOCUMENT_SUBRESOURCE_FILTER_H_ #define COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_ASYNC_DOCUMENT_SUBRESOURCE_FILTER_H_ #include <memory> #include <optional> #include <vector> #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/sequence_checker.h" #include "base/task/sequenced_task_runner.h" #include "components/subresource_filter/core/browser/verified_ruleset_dealer.h" #include "components/subresource_filter/core/common/document_subresource_filter.h" #include "components/subresource_filter/core/common/load_policy.h" #include "components/subresource_filter/core/mojom/subresource_filter.mojom.h" #include "url/gurl.h" #include "url/origin.h" namespace subresource_filter { class MemoryMappedRuleset; // Computes whether/how subresource filtering should be activated while loading // |document_url| in a frame, based on the parent document's |activation_state|, // the |parent_document_origin|, as well as any applicable deactivation rules in // non-null |ruleset|. mojom::ActivationState ComputeActivationState( const GURL& document_url, const url::Origin& parent_document_origin, const mojom::ActivationState& parent_activation_state, const MemoryMappedRuleset* ruleset); // An asynchronous wrapper around DocumentSubresourceFilter (DSF). // // It is accessed on the UI thread and owns a DSF living on a dedicated // sequenced |task_runner|. Provides asynchronous access to the DSF and destroys // it asynchronously. // // Initially holds an empty filter in the synchronously created Core object, and // initializes the filter on the |task_runner| asynchronously. This lets ADSF be // created synchronously and be immediately used by clients on the UI thread, // while the DSF is retrieved on the |task_runner| in a deferred manner. class AsyncDocumentSubresourceFilter { … }; // Holds a DocumentSubresourceFilter that is created in a deferred manner in // Initialize(), provided there is a valid ruleset to work with. class AsyncDocumentSubresourceFilter::Core { … }; } // namespace subresource_filter #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_ASYNC_DOCUMENT_SUBRESOURCE_FILTER_H_