// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module subresource_filter.mojom;
import "mojo/public/mojom/base/file.mojom";
import "mojo/public/mojom/base/time.mojom";
enum ActivationLevel {
kDisabled,
kDryRun,
kEnabled
};
// Enumerates which ads violations are recorded for a page.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. Please update the enum named
// AdsViolations in enums.xml when adding a new entry here.
enum AdsViolation {
kMobileAdDensityByHeightAbove30,
kHeavyAdsInterventionAtHostLimit,
kLargeStickyAd,
kOverlayPopupAd,
};
struct ActivationState {
// The degree to which subresource filtering is activated for the page load.
ActivationLevel activation_level = kDisabled;
// Even when subresource filtering is activated at the page level, a document
// in the current frame (and/or ancestors thereof) may still match special
// filtering rules that specifically disable using certain types of rules for
// filtering subresources of that document (and/or of documents in descendent
// frames). See proto::ActivationType for details.
//
// |filtering_disabled_for_document| indicates whether the document in this
// frame is subject to an allowlist rule with DOCUMENT activation type.
//
// |generic_blocking_rules_disabled| indicates whether the document in this
// frame is subject to an allowlist rule with GENERICBLOCK activation type, and
// is only defined if |filtering_disabled_for_document| is false.
bool filtering_disabled_for_document = false;
bool generic_blocking_rules_disabled = false;
// Whether or not extended performance measurements are enabled for the
// current page load (across all frames).
bool measure_performance = false;
// Whether or not to log messages in the devtools console.
bool enable_logging = false;
};
// Contains statistics and performance metrics collected by the
// DocumentSubresourceFilter.
struct DocumentLoadStatistics {
// The number of subresource loads that went through the
// DocumentSubresouceFilter filtering methods.
int32 num_loads_total = 0;
// Statistics on the number of subresource loads that were evaluated, were
// matched by filtering rules, and were disallowed, respectively, during the
// lifetime of a DocumentSubresourceFilter.
int32 num_loads_evaluated = 0;
int32 num_loads_matching_rules = 0;
int32 num_loads_disallowed = 0;
// Total time spent in GetLoadPolicy() calls evaluating subresource loads.
mojo_base.mojom.TimeDelta evaluation_total_wall_duration;
mojo_base.mojom.TimeDelta evaluation_total_cpu_duration;
};
// Subresource filter implemented by the renderer.
interface SubresourceFilterRulesetObserver {
// Sends a read-only mode file handle with the ruleset data to a renderer
// process, containing the subresource filtering rules to be consulted for all
// subsequent document loads that have subresource filtering activated.
SetRulesetForProcess(mojo_base.mojom.File ruleset_file);
};