#include "components/subresource_filter/content/renderer/subresource_filter_agent.h"
#include <utility>
#include "base/check.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/time/time.h"
#include "components/subresource_filter/content/renderer/unverified_ruleset_dealer.h"
#include "components/subresource_filter/content/shared/common/subresource_filter_utils.h"
#include "components/subresource_filter/content/shared/renderer/web_document_subresource_filter_impl.h"
#include "components/subresource_filter/core/common/document_subresource_filter.h"
#include "components/subresource_filter/core/common/memory_mapped_ruleset.h"
#include "components/subresource_filter/core/common/scoped_timers.h"
#include "components/subresource_filter/core/common/time_measurements.h"
#include "content/public/common/content_features.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/render_frame.h"
#include "ipc/ipc_message.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/frame/frame_ad_evidence.h"
#include "third_party/blink/public/platform/web_worker_fetch_context.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_document_loader.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "url/url_constants.h"
namespace {
bool IsFencedFrameRoot(content::RenderFrame* frame) { … }
}
namespace subresource_filter {
SubresourceFilterAgent::SubresourceFilterAgent(
content::RenderFrame* render_frame,
UnverifiedRulesetDealer* ruleset_dealer)
: … { … }
void SubresourceFilterAgent::Initialize() { … }
SubresourceFilterAgent::~SubresourceFilterAgent() = default;
GURL SubresourceFilterAgent::GetDocumentURL() { … }
bool SubresourceFilterAgent::IsSubresourceFilterChild() { … }
bool SubresourceFilterAgent::IsParentAdFrame() { … }
bool SubresourceFilterAgent::IsProvisional() { … }
bool SubresourceFilterAgent::IsFrameCreatedByAdScript() { … }
void SubresourceFilterAgent::SetSubresourceFilterForCurrentDocument(
std::unique_ptr<blink::WebDocumentSubresourceFilter> filter) { … }
void SubresourceFilterAgent::
SignalFirstSubresourceDisallowedForCurrentDocument() { … }
void SubresourceFilterAgent::SendDocumentLoadStatistics(
const mojom::DocumentLoadStatistics& statistics) { … }
void SubresourceFilterAgent::SendFrameIsAd() { … }
void SubresourceFilterAgent::SendFrameWasCreatedByAdScript() { … }
bool SubresourceFilterAgent::IsAdFrame() { … }
void SubresourceFilterAgent::SetAdEvidence(
const blink::FrameAdEvidence& ad_evidence) { … }
const std::optional<blink::FrameAdEvidence>&
SubresourceFilterAgent::AdEvidence() { … }
mojom::ActivationState SubresourceFilterAgent::GetInheritedActivationState(
content::RenderFrame* render_frame) { … }
void SubresourceFilterAgent::RecordHistogramsOnFilterCreation(
const mojom::ActivationState& activation_state) { … }
void SubresourceFilterAgent::ResetInfoForNextDocument() { … }
mojom::SubresourceFilterHost*
SubresourceFilterAgent::GetSubresourceFilterHost() { … }
void SubresourceFilterAgent::OnSubresourceFilterAgentRequest(
mojo::PendingAssociatedReceiver<mojom::SubresourceFilterAgent> receiver) { … }
void SubresourceFilterAgent::ActivateForNextCommittedLoad(
mojom::ActivationStatePtr activation_state,
const std::optional<blink::FrameAdEvidence>& ad_evidence) { … }
void SubresourceFilterAgent::OnDestruct() { … }
void SubresourceFilterAgent::SetAdEvidenceForInitialEmptySubframe() { … }
void SubresourceFilterAgent::DidCreateNewDocument() { … }
const mojom::ActivationState
SubresourceFilterAgent::GetInheritedActivationStateForNewDocument() { … }
void SubresourceFilterAgent::ConstructFilter(
const mojom::ActivationState activation_state,
const GURL& url) { … }
void SubresourceFilterAgent::DidFailProvisionalLoad() { … }
void SubresourceFilterAgent::DidFinishLoad() { … }
void SubresourceFilterAgent::WillCreateWorkerFetchContext(
blink::WebWorkerFetchContext* worker_fetch_context) { … }
void SubresourceFilterAgent::OnOverlayPopupAdDetected() { … }
void SubresourceFilterAgent::OnLargeStickyAdDetected() { … }
void SubresourceFilterAgent::DidCreateFencedFrame(
const blink::RemoteFrameToken& placeholder_token) { … }
}