Commit 3748ff56 authored by Dylan Cutler's avatar Dylan Cutler Committed by Commit Bot

Fix gating identifiability study in Dactyloscoper::RecordDirectSurface.

The method will only report digests to UKM if the study is enabled and
collection of the specified web feature is allowed.

Bug: 973801
Change-Id: Ia1f2dea99ce26a24d7130ebc6fed42edade287d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427363Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Cr-Commit-Position: refs/heads/master@{#810890}
parent 54943ea8
......@@ -23,6 +23,16 @@ void Dactyloscoper::Record(WebFeature feature) {
// here over time.
}
namespace {
bool IsStudyEnabled(WebFeature feature) {
return IdentifiabilityStudySettings::Get()->IsSurfaceAllowed(
IdentifiableSurface::FromTypeAndToken(
IdentifiableSurface::Type::kWebFeature, feature));
}
} // namespace
// static
void Dactyloscoper::Record(ExecutionContext* context, WebFeature feature) {
// TODO: Workers.
......@@ -38,7 +48,7 @@ void Dactyloscoper::Record(ExecutionContext* context, WebFeature feature) {
void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
WebFeature feature,
const IdentifiableToken& value) {
if (!IdentifiabilityStudySettings::Get()->IsActive() || !context)
if (!context || !IsStudyEnabled(feature))
return;
auto* window = DynamicTo<LocalDOMWindow>(context);
if (!window)
......@@ -53,7 +63,7 @@ void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
WebFeature feature,
const String& str) {
if (!IdentifiabilityStudySettings::Get()->IsActive() || !context)
if (!context || !IsStudyEnabled(feature))
return;
if (str.IsEmpty())
return;
......@@ -65,7 +75,7 @@ void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
WebFeature feature,
const Vector<String>& strs) {
if (!IdentifiabilityStudySettings::Get()->IsActive() || !context)
if (!context || !IsStudyEnabled(feature))
return;
if (strs.IsEmpty())
return;
......@@ -81,7 +91,7 @@ void Dactyloscoper::RecordDirectSurface(
ExecutionContext* context,
WebFeature feature,
const NotShared<DOMFloat32Array>& buffer) {
if (!IdentifiabilityStudySettings::Get()->IsActive() || !context)
if (!context || !IsStudyEnabled(feature))
return;
if (buffer.IsNull() || buffer->lengthAsSizeT() == 0)
return;
......
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