Commit a80e0326 authored by John Delaney's avatar John Delaney Committed by Commit Bot

Require adtagging enabled for AdTracker creation

Only provision an AdTracker to a local frame if AdTagging is
enabled. Useful to measure the performance impact of the AdTracker.
AdTagging feature declaration moved to support RuntimeEnabledFeature

Bug: 856273
Change-Id: I898c78d5be916583744b445afad885d445b440bf
Reviewed-on: https://chromium-review.googlesource.com/1115374Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: John Delaney <johnidel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576493}
parent f8c5a0bb
...@@ -36,6 +36,7 @@ include_rules = [ ...@@ -36,6 +36,7 @@ include_rules = [
"+components/strings/grit", "+components/strings/grit",
"+components/subresource_filter/content/common", "+components/subresource_filter/content/common",
"+components/subresource_filter/content/renderer", "+components/subresource_filter/content/renderer",
"+components/subresource_filter/core/common/common_features.h",
"+components/task_scheduler_util", "+components/task_scheduler_util",
"+components/translate/content/common", "+components/translate/content/common",
"+components/translate/content/renderer", "+components/translate/content/renderer",
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
#include "components/startup_metric_utils/common/startup_metric.mojom.h" #include "components/startup_metric_utils/common/startup_metric.mojom.h"
#include "components/subresource_filter/content/renderer/subresource_filter_agent.h" #include "components/subresource_filter/content/renderer/subresource_filter_agent.h"
#include "components/subresource_filter/content/renderer/unverified_ruleset_dealer.h" #include "components/subresource_filter/content/renderer/unverified_ruleset_dealer.h"
#include "components/subresource_filter/core/common/common_features.h"
#include "components/task_scheduler_util/variations_util.h" #include "components/task_scheduler_util/variations_util.h"
#include "components/variations/variations_switches.h" #include "components/variations/variations_switches.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
...@@ -1577,6 +1578,9 @@ void ChromeContentRendererClient:: ...@@ -1577,6 +1578,9 @@ void ChromeContentRendererClient::
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
blink::WebRuntimeFeatures::EnableWebShare(true); blink::WebRuntimeFeatures::EnableWebShare(true);
#endif #endif
if (base::FeatureList::IsEnabled(subresource_filter::kAdTagging))
blink::WebRuntimeFeatures::EnableAdTagging(true);
} }
void ChromeContentRendererClient:: void ChromeContentRendererClient::
......
...@@ -72,6 +72,7 @@ class WebRuntimeFeatures { ...@@ -72,6 +72,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableAccelerated2dCanvas(bool); BLINK_PLATFORM_EXPORT static void EnableAccelerated2dCanvas(bool);
BLINK_PLATFORM_EXPORT static void EnableAccessibilityObjectModel(bool); BLINK_PLATFORM_EXPORT static void EnableAccessibilityObjectModel(bool);
BLINK_PLATFORM_EXPORT static void EnableAdTagging(bool);
BLINK_PLATFORM_EXPORT static void EnableAllowActivationDelegationAttr(bool); BLINK_PLATFORM_EXPORT static void EnableAllowActivationDelegationAttr(bool);
BLINK_PLATFORM_EXPORT static void EnableAudioOutputDevices(bool); BLINK_PLATFORM_EXPORT static void EnableAudioOutputDevices(bool);
BLINK_PLATFORM_EXPORT static void EnableBlinkHeapIncrementalMarking(bool); BLINK_PLATFORM_EXPORT static void EnableBlinkHeapIncrementalMarking(bool);
......
...@@ -288,4 +288,34 @@ TEST_F(AdTrackerSimTest, SameOriginDocWrittenSubframeFromAdScript) { ...@@ -288,4 +288,34 @@ TEST_F(AdTrackerSimTest, SameOriginDocWrittenSubframeFromAdScript) {
EXPECT_TRUE(local_subframe->IsAdSubframe()); EXPECT_TRUE(local_subframe->IsAdSubframe());
} }
class AdTrackerDisabledSimTest : public SimTest {
protected:
void SetUp() override {
RuntimeEnabledFeatures::SetAdTaggingEnabled(false);
SimTest::SetUp();
main_resource_ = std::make_unique<SimRequest>(
"https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
main_resource_->Start();
}
void TearDown() override { SimTest::TearDown(); }
std::unique_ptr<SimRequest> main_resource_;
};
TEST_F(AdTrackerDisabledSimTest, ResourceLoadedWhenAdTaggingDisabled) {
SimRequest iframe_resource("https://example.com/iframe.html", "text/html");
main_resource_->Complete(R"HTML(
<iframe src=https://example.com/iframe.html></iframe>
)HTML");
iframe_resource.Complete("<body></body>");
EXPECT_FALSE(GetDocument().GetFrame()->IsAdSubframe());
}
} // namespace blink } // namespace blink
...@@ -353,7 +353,8 @@ void LocalFrame::Detach(FrameDetachType type) { ...@@ -353,7 +353,8 @@ void LocalFrame::Detach(FrameDetachType type) {
if (IsLocalRoot()) { if (IsLocalRoot()) {
performance_monitor_->Shutdown(); performance_monitor_->Shutdown();
ad_tracker_->Shutdown(); if (ad_tracker_)
ad_tracker_->Shutdown();
} }
idleness_detector_->Shutdown(); idleness_detector_->Shutdown();
if (inspector_trace_events_) if (inspector_trace_events_)
...@@ -941,10 +942,12 @@ inline LocalFrame::LocalFrame(LocalFrameClient* client, ...@@ -941,10 +942,12 @@ inline LocalFrame::LocalFrame(LocalFrameClient* client,
interface_registry_(interface_registry) { interface_registry_(interface_registry) {
if (IsLocalRoot()) { if (IsLocalRoot()) {
probe_sink_ = new CoreProbeSink(); probe_sink_ = new CoreProbeSink();
ad_tracker_ = new AdTracker(this);
performance_monitor_ = new PerformanceMonitor(this); performance_monitor_ = new PerformanceMonitor(this);
inspector_trace_events_ = new InspectorTraceEvents(); inspector_trace_events_ = new InspectorTraceEvents();
probe_sink_->addInspectorTraceEvents(inspector_trace_events_); probe_sink_->addInspectorTraceEvents(inspector_trace_events_);
if (RuntimeEnabledFeatures::AdTaggingEnabled()) {
ad_tracker_ = new AdTracker(this);
}
} else { } else {
// Inertness only needs to be updated if this frame might inherit the // Inertness only needs to be updated if this frame might inherit the
// inert state from a higher-level frame. If this is an OOPIF local root, // inert state from a higher-level frame. If this is an OOPIF local root,
...@@ -958,7 +961,11 @@ inline LocalFrame::LocalFrame(LocalFrameClient* client, ...@@ -958,7 +961,11 @@ inline LocalFrame::LocalFrame(LocalFrameClient* client,
idleness_detector_ = new IdlenessDetector(this); idleness_detector_ = new IdlenessDetector(this);
inspector_task_runner_->InitIsolate(V8PerIsolateData::MainThreadIsolate()); inspector_task_runner_->InitIsolate(V8PerIsolateData::MainThreadIsolate());
SetIsAdSubframeIfNecessary(); if (ad_tracker_) {
SetIsAdSubframeIfNecessary();
}
DCHECK(ad_tracker_ ? RuntimeEnabledFeatures::AdTaggingEnabled()
: !RuntimeEnabledFeatures::AdTaggingEnabled());
} }
FrameScheduler* LocalFrame::GetFrameScheduler() { FrameScheduler* LocalFrame::GetFrameScheduler() {
...@@ -1262,7 +1269,8 @@ PluginData* LocalFrame::GetPluginData() const { ...@@ -1262,7 +1269,8 @@ PluginData* LocalFrame::GetPluginData() const {
} }
void LocalFrame::SetAdTrackerForTesting(AdTracker* ad_tracker) { void LocalFrame::SetAdTrackerForTesting(AdTracker* ad_tracker) {
ad_tracker_->Shutdown(); if (ad_tracker_)
ad_tracker_->Shutdown();
ad_tracker_ = ad_tracker; ad_tracker_ = ad_tracker;
} }
......
...@@ -92,6 +92,10 @@ void WebRuntimeFeatures::EnableAccessibilityObjectModel(bool enable) { ...@@ -92,6 +92,10 @@ void WebRuntimeFeatures::EnableAccessibilityObjectModel(bool enable) {
RuntimeEnabledFeatures::SetAccessibilityObjectModelEnabled(enable); RuntimeEnabledFeatures::SetAccessibilityObjectModelEnabled(enable);
} }
void WebRuntimeFeatures::EnableAdTagging(bool enable) {
RuntimeEnabledFeatures::SetAdTaggingEnabled(enable);
}
void WebRuntimeFeatures::EnableAllowActivationDelegationAttr(bool enable) { void WebRuntimeFeatures::EnableAllowActivationDelegationAttr(bool enable) {
RuntimeEnabledFeatures::SetAllowActivationDelegationAttrEnabled(enable); RuntimeEnabledFeatures::SetAllowActivationDelegationAttrEnabled(enable);
} }
......
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
name: "AccessibilityObjectModel", name: "AccessibilityObjectModel",
status: "experimental", status: "experimental",
}, },
{
name: "AdTagging",
status: "test",
},
{ {
name: "AllowActivationDelegationAttr", name: "AllowActivationDelegationAttr",
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment