| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // 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/time.mojom"; |
| |
| enum ActivationLevel { |
| kDisabled, |
| kDryRun, |
| kEnabled |
| }; |
| |
| 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 a whitelist rule with DOCUMENT activation type. |
| // |
| // |generic_blocking_rules_disabled| indicates whether the document in this |
| // frame is subject to a whitelist 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; |
| }; |
| |
| interface SubresourceFilterHost { |
| // Called the first time a subresource load is disallowed for the most |
| // recently committed document load in a frame. It is used to trigger a UI |
| // prompt to inform the user and allow them to turn off filtering. |
| DidDisallowFirstSubresource(); |
| |
| // Called when a RenderFrame is created and is tagged as an ad subframe. The |
| // browser keeps track of this in case the frame later changes processes, at |
| // which point it will inform the new RenderFrame that it has been tagged as |
| // an ad via SubresourceFilterMsg_ActivateForNextCommittedLoad, at |
| // ReadyToCommitNavigation time. |
| FrameIsAdSubframe(); |
| |
| // This is sent to a RenderFrameHost in the browser when a document load is |
| // finished, just before the DidFinishLoad message, and contains statistics |
| // collected by the DocumentSubresourceFilter up until that point: the number |
| // of subresources evaluated/disallowed/etc, and total time spent on |
| // evaluating subresource loads in its allowLoad method. The time metrics are |
| // equal to zero if performance measurements were disabled for the load. |
| SetDocumentLoadStatistics(DocumentLoadStatistics statistics); |
| }; |