chromium/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc

// 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.

#include "components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.h"

#include <utility>

#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/debug/crash_logging.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "components/subresource_filter/content/browser/ad_tagging_utils.h"
#include "components/subresource_filter/content/browser/content_subresource_filter_web_contents_helper.h"
#include "components/subresource_filter/content/browser/profile_interaction_manager.h"
#include "components/subresource_filter/content/browser/safe_browsing_child_navigation_throttle.h"
#include "components/subresource_filter/content/browser/safe_browsing_page_activation_throttle.h"
#include "components/subresource_filter/content/mojom/subresource_filter.mojom.h"
#include "components/subresource_filter/content/shared/browser/activation_state_computing_navigation_throttle.h"
#include "components/subresource_filter/content/shared/browser/page_load_statistics.h"
#include "components/subresource_filter/content/shared/common/subresource_filter_utils.h"
#include "components/subresource_filter/core/browser/async_document_subresource_filter.h"
#include "components/subresource_filter/core/browser/subresource_filter_constants.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include "components/subresource_filter/core/common/common_features.h"
#include "components/subresource_filter/core/common/constants.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/page.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_utils.h"
#include "net/base/net_errors.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"

namespace subresource_filter {

// static
const int ContentSubresourceFilterThrottleManager::kUserDataKey;

// static
void ContentSubresourceFilterThrottleManager::BindReceiver(
    mojo::PendingAssociatedReceiver<mojom::SubresourceFilterHost>
        pending_receiver,
    content::RenderFrameHost* render_frame_host) {}

// static
std::unique_ptr<ContentSubresourceFilterThrottleManager>
ContentSubresourceFilterThrottleManager::CreateForNewPage(
    SubresourceFilterProfileContext* profile_context,
    scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager,
    VerifiedRulesetDealer::Handle* dealer_handle,
    ContentSubresourceFilterWebContentsHelper& web_contents_helper,
    content::NavigationHandle& initiating_navigation_handle) {}

// static
ContentSubresourceFilterThrottleManager*
ContentSubresourceFilterThrottleManager::FromPage(content::Page& page) {}

// static
ContentSubresourceFilterThrottleManager*
ContentSubresourceFilterThrottleManager::FromNavigationHandle(
    content::NavigationHandle& navigation_handle) {}

ContentSubresourceFilterThrottleManager::
    ContentSubresourceFilterThrottleManager(
        SubresourceFilterProfileContext* profile_context,
        scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager>
            database_manager,
        VerifiedRulesetDealer::Handle* dealer_handle,
        ContentSubresourceFilterWebContentsHelper& web_contents_helper,
        content::NavigationHandle& initiating_navigation_handle)
    :{}

ContentSubresourceFilterThrottleManager::
    ~ContentSubresourceFilterThrottleManager() {}

void ContentSubresourceFilterThrottleManager::RenderFrameDeleted(
    content::RenderFrameHost* frame_host) {}

void ContentSubresourceFilterThrottleManager::FrameDeleted(
    int frame_tree_node_id) {}

// Pull the AsyncDocumentSubresourceFilter and its associated
// mojom::ActivationState out of the activation state computing throttle. Store
// it for later filtering of child frame navigations.
void ContentSubresourceFilterThrottleManager::ReadyToCommitInFrameNavigation(
    content::NavigationHandle* navigation_handle) {}

mojom::ActivationState
ContentSubresourceFilterThrottleManager::ActivationStateForNextCommittedLoad(
    content::NavigationHandle* navigation_handle) {}

void ContentSubresourceFilterThrottleManager::DidFinishInFrameNavigation(
    content::NavigationHandle* navigation_handle,
    bool is_initial_navigation) {}

void ContentSubresourceFilterThrottleManager::
    RecordExperimentalUmaHistogramsForNavigation(
        content::NavigationHandle* navigation_handle,
        bool passed_through_ready_to_commit) {}

AsyncDocumentSubresourceFilter*
ContentSubresourceFilterThrottleManager::FilterForFinishedNavigation(
    content::NavigationHandle* navigation_handle,
    ActivationStateComputingNavigationThrottle* throttle,
    content::RenderFrameHost* frame_host,
    bool& did_inherit_opener_activation) {}

void ContentSubresourceFilterThrottleManager::
    RecordUmaHistogramsForRootNavigation(
        content::NavigationHandle* navigation_handle,
        const mojom::ActivationLevel& activation_level,
        bool did_inherit_opener_activation) {}

void ContentSubresourceFilterThrottleManager::DidFinishLoad(
    content::RenderFrameHost* render_frame_host,
    const GURL& validated_url) {}

void ContentSubresourceFilterThrottleManager::DidBecomePrimaryPage() {}

void ContentSubresourceFilterThrottleManager::OnPageCreated(
    content::Page& page) {}

// Sets the desired page-level |activation_state| for the currently ongoing
// page load, identified by its main-frame |navigation_handle|. If this method
// is not called for a main-frame navigation, the default behavior is no
// activation for that page load.
void ContentSubresourceFilterThrottleManager::OnPageActivationComputed(
    content::NavigationHandle* navigation_handle,
    const mojom::ActivationState& activation_state) {}

void ContentSubresourceFilterThrottleManager::OnChildFrameNavigationEvaluated(
    content::NavigationHandle* navigation_handle,
    LoadPolicy load_policy) {}

void ContentSubresourceFilterThrottleManager::MaybeAppendNavigationThrottles(
    content::NavigationHandle* navigation_handle,
    std::vector<std::unique_ptr<content::NavigationThrottle>>* throttles) {}

bool ContentSubresourceFilterThrottleManager::IsFrameTaggedAsAd(
    int frame_tree_node_id) const {}

bool ContentSubresourceFilterThrottleManager::IsRenderFrameHostTaggedAsAd(
    content::RenderFrameHost* frame_host) const {}

std::optional<LoadPolicy>
ContentSubresourceFilterThrottleManager::LoadPolicyForLastCommittedNavigation(
    int frame_tree_node_id) const {}

void ContentSubresourceFilterThrottleManager::OnReloadRequested() {}

void ContentSubresourceFilterThrottleManager::OnAdsViolationTriggered(
    content::RenderFrameHost* rfh,
    mojom::AdsViolation triggered_violation) {}

// static
void ContentSubresourceFilterThrottleManager::LogAction(
    SubresourceFilterAction action) {}

std::unique_ptr<SafeBrowsingChildNavigationThrottle>
ContentSubresourceFilterThrottleManager::MaybeCreateChildNavigationThrottle(
    content::NavigationHandle* navigation_handle) {}

std::unique_ptr<ActivationStateComputingNavigationThrottle>
ContentSubresourceFilterThrottleManager::
    MaybeCreateActivationStateComputingThrottle(
        content::NavigationHandle* navigation_handle) {}

AsyncDocumentSubresourceFilter*
ContentSubresourceFilterThrottleManager::GetParentFrameFilter(
    content::NavigationHandle* child_frame_navigation) {}

const std::optional<subresource_filter::mojom::ActivationState>
ContentSubresourceFilterThrottleManager::GetFrameActivationState(
    content::RenderFrameHost* frame_host) {}

AsyncDocumentSubresourceFilter*
ContentSubresourceFilterThrottleManager::GetFrameFilter(
    content::RenderFrameHost* frame_host) {}

void ContentSubresourceFilterThrottleManager::MaybeShowNotification(
    content::RenderFrameHost* frame_host) {}

VerifiedRuleset::Handle*
ContentSubresourceFilterThrottleManager::EnsureRulesetHandle() {}

void ContentSubresourceFilterThrottleManager::
    DestroyRulesetHandleIfNoLongerUsed() {}

void ContentSubresourceFilterThrottleManager::OnFrameIsAd(
    content::RenderFrameHost* render_frame_host) {}

void ContentSubresourceFilterThrottleManager::SetIsAdFrame(
    content::RenderFrameHost* render_frame_host,
    bool is_ad_frame) {}

void ContentSubresourceFilterThrottleManager::SetIsAdFrameForTesting(
    content::RenderFrameHost* render_frame_host,
    bool is_ad_frame) {}

std::optional<blink::FrameAdEvidence>
ContentSubresourceFilterThrottleManager::GetAdEvidenceForFrame(
    content::RenderFrameHost* render_frame_host) {}

void ContentSubresourceFilterThrottleManager::DidDisallowFirstSubresource() {}

void ContentSubresourceFilterThrottleManager::FrameIsAd() {}

void ContentSubresourceFilterThrottleManager::SetDocumentLoadStatistics(
    mojom::DocumentLoadStatisticsPtr statistics) {}

void ContentSubresourceFilterThrottleManager::OnAdsViolationTriggered(
    mojom::AdsViolation violation) {}

void ContentSubresourceFilterThrottleManager::FrameWasCreatedByAdScript() {}

void ContentSubresourceFilterThrottleManager::AdScriptDidCreateFencedFrame(
    const blink::RemoteFrameToken& placeholder_token) {}

void ContentSubresourceFilterThrottleManager::OnChildFrameWasCreatedByAdScript(
    content::RenderFrameHost* frame_host) {}

blink::FrameAdEvidence&
ContentSubresourceFilterThrottleManager::EnsureFrameAdEvidence(
    content::NavigationHandle* navigation_handle) {}

blink::FrameAdEvidence&
ContentSubresourceFilterThrottleManager::EnsureFrameAdEvidence(
    content::RenderFrameHost* render_frame_host) {}

blink::FrameAdEvidence&
ContentSubresourceFilterThrottleManager::EnsureFrameAdEvidence(
    int frame_tree_node_id,
    int parent_frame_tree_node_id) {}

}  // namespace subresource_filter