Commit 5d3e0a1c authored by Dylan Cutler's avatar Dylan Cutler Committed by Commit Bot

Instrument HTMLCanvasElement.getContext() for identifiability study.

We are interested in seeing if using this method to see which rendering
context types a particular client supports leaks identifying information
about users that persists across different origins.

The previous instrumentation just recorded what types of rendering
contexts sites are using, but did not record whether those contexts were
supported. This information can be recovered from the new
instrumentation in the IdentifiableSurface type I created for this CL.

Bug: 973801
Change-Id: I353e8d65af50a4a8e994dfa7f603d5823b88f019
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442138
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813848}
parent 6ce39531
...@@ -187,6 +187,12 @@ class IdentifiableSurface { ...@@ -187,6 +187,12 @@ class IdentifiableSurface {
// Represents a call to GPU.requestAdapter. Input is the options filter. // Represents a call to GPU.requestAdapter. Input is the options filter.
kGPU_RequestAdapter = 20, kGPU_RequestAdapter = 20,
// For instrumenting HTMLCanvas.getContext() fingerprinting. Some scripts
// will iterate through the different possible arguments and record whether
// each type of context is supported.
// The input should be an instance of CanvasRenderingContext::ContextType.
kCanvasRenderingContext = 21,
// NavigatorUAData.getHighEntropyValues() is, shockingly, a high entropy // NavigatorUAData.getHighEntropyValues() is, shockingly, a high entropy
// API to provide more detailed User-Agent data. The output is keyed on // API to provide more detailed User-Agent data. The output is keyed on
// the hint parameter. // the hint parameter.
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h" #include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metrics.h" #include "third_party/blink/public/common/privacy_budget/identifiability_metrics.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_participation.h" #include "third_party/blink/public/common/privacy_budget/identifiability_study_participation.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_surface.h" #include "third_party/blink/public/common/privacy_budget/identifiable_surface.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h" #include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/mojom/gpu/gpu.mojom-blink.h" #include "third_party/blink/public/mojom/gpu/gpu.mojom-blink.h"
...@@ -315,6 +316,17 @@ CanvasRenderingContext* HTMLCanvasElement::GetCanvasRenderingContext( ...@@ -315,6 +316,17 @@ CanvasRenderingContext* HTMLCanvasElement::GetCanvasRenderingContext(
const CanvasContextCreationAttributesCore& attributes) { const CanvasContextCreationAttributesCore& attributes) {
auto* old_contents_cc_layer = ContentsCcLayer(); auto* old_contents_cc_layer = ContentsCcLayer();
auto* result = GetCanvasRenderingContextInternal(type, attributes); auto* result = GetCanvasRenderingContextInternal(type, attributes);
if (ukm_params_ && IdentifiabilityStudySettings::Get()->IsTypeAllowed(
IdentifiableSurface::Type::kCanvasRenderingContext)) {
IdentifiabilityMetricBuilder(ukm_params_->source_id)
.Set(IdentifiableSurface::FromTypeAndToken(
IdentifiableSurface::Type::kCanvasRenderingContext,
CanvasRenderingContext::ContextTypeFromId(type)),
!!result)
.Record(ukm_params_->ukm_recorder);
}
if (ContentsCcLayer() != old_contents_cc_layer) if (ContentsCcLayer() != old_contents_cc_layer)
OnContentsCcLayerChanged(); OnContentsCcLayerChanged();
return result; return result;
...@@ -333,13 +345,6 @@ CanvasRenderingContext* HTMLCanvasElement::GetCanvasRenderingContextInternal( ...@@ -333,13 +345,6 @@ CanvasRenderingContext* HTMLCanvasElement::GetCanvasRenderingContextInternal(
// Log the aliased context type used. // Log the aliased context type used.
if (!context_) { if (!context_) {
if (IsUserInIdentifiabilityStudy()) {
RecordIdentifiabilityMetric(
IdentifiableSurface::FromTypeAndToken(
blink::IdentifiableSurface::Type::kWebFeature,
blink::WebFeature::kCanvasRenderingContext),
context_type);
}
UMA_HISTOGRAM_ENUMERATION("Blink.Canvas.ContextType", context_type); UMA_HISTOGRAM_ENUMERATION("Blink.Canvas.ContextType", context_type);
} }
......
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