// 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_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER_THROTTLE_MANAGER_H_ #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER_THROTTLE_MANAGER_H_ #include <map> #include <memory> #include <optional> #include <vector> #include "base/containers/flat_set.h" #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/raw_ref.h" #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "components/safe_browsing/core/browser/db/database_manager.h" #include "components/subresource_filter/content/browser/safe_browsing_child_navigation_throttle.h" #include "components/subresource_filter/content/mojom/subresource_filter.mojom.h" #include "components/subresource_filter/content/shared/common/subresource_filter_utils.h" #include "components/subresource_filter/core/browser/verified_ruleset_dealer.h" #include "components/subresource_filter/core/common/activation_decision.h" #include "components/subresource_filter/core/mojom/subresource_filter.mojom.h" #include "content/public/browser/render_frame_host_receiver_set.h" #include "third_party/blink/public/common/frame/frame_ad_evidence.h" namespace content { class NavigationHandle; class NavigationThrottle; class Page; class RenderFrameHost; } // namespace content namespace subresource_filter { class AsyncDocumentSubresourceFilter; class ActivationStateComputingNavigationThrottle; class ContentSubresourceFilterThrottleManager; class ContentSubresourceFilterWebContentsHelper; class PageLoadStatistics; class ProfileInteractionManager; class SubresourceFilterProfileContext; // This enum backs a histogram. Make sure new elements are only added to the // end. Keep histograms.xml up to date with any changes. enum class SubresourceFilterAction { … }; // The ContentSubresourceFilterThrottleManager manages NavigationThrottles in // order to calculate frame activation states and child frame navigation // filtering, within a given Page. It contains a mapping of all activated // RenderFrameHosts, along with their associated DocumentSubresourceFilters. // // This class is created for each Page that is a "subresource filter root". // Most Pages are subresource filter roots so that each of (e.g. primary page, // prerender, BFCache'd page, etc.) uses its own separate and independent // subresource filter (e.g. each computes main frame activation separately). // Fenced frames are an exception. A fenced frame does create a separate Page // but is considered a "subresource filter child" of its embedder; // behaviorally, the subresource filter treats it like a regular iframe. See // IsInSubresourceFilterRoot in // content_subresource_filter_web_contents_helper.cc. The term "main frame" is // avoided in subresource filter code to avoid ambiguity; instead, the main // frame of a page that is a subresource filter root is called a "root frame" // while other frames are called "child frames". // // Since this class is associated with a Page, cross document navigation to a // new Page will create a new instance of this class. // // Instances of this class are created by the // ContentSubresourceFilterWebContentsHelper class, of which there is 1 per // WebContents, on navigation starts that will create a new eligible Page. This // class is initially owned by the NavigationHandle that creates it. If the // navigation commits, this class will be transferred to be owned by the Page // it is associated with. Otherwise it will be destroyed with the // NavigationHandle. // // TODO(bokan): The lifetime management and observer pattern seems like it will // be common to all features that want to observe events and track state on a // per Page basis. The ContentSubresourceFilterWebContentsHelper pattern or // something like it should be wrapped up into a common and reusable //content // API. See: // https://docs.google.com/document/d/1p-IXk8hI5ucWRf5vJEi9K_YvJXsTr8kbvzGrjMcALDE/edit?usp=sharing class ContentSubresourceFilterThrottleManager : public base::SupportsUserData::Data, public mojom::SubresourceFilterHost { … }; } // namespace subresource_filter #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER_THROTTLE_MANAGER_H_