From 604168304f0d95d0fbaf3775b2bd4e1a3ab5dab4 Mon Sep 17 00:00:00 2001 From: xhwang Date: Mon, 17 Apr 2017 23:53:56 -0700 Subject: [PATCH] media: Add UMA to record whether encrypted media is enabled The UMA is recorded when requestMediaKeySystemAccess is called on non-ClearKey key system but will reported at most once per renderer process. BUG=711348 TEST=Manually tested Review-Url: https://codereview.chromium.org/2824643002 Cr-Commit-Position: refs/heads/master@{#465159} --- .../NavigatorRequestMediaKeySystemAccess.cpp | 17 ++++++++++++++--- tools/metrics/histograms/histograms.xml | 10 ++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp index 5fceee8b9526..1dee6dab1de4 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp @@ -278,9 +278,20 @@ ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( // // Do not check settings for Clear Key. if (key_system != "org.w3.clearkey") { - // For other key systems, check settings. - if (!document->GetSettings() || - !document->GetSettings()->GetEncryptedMediaEnabled()) { + // For other key systems, check settings and report UMA. + bool encypted_media_enabled = + document->GetSettings() && + document->GetSettings()->GetEncryptedMediaEnabled(); + + static bool has_reported_uma = false; + if (!has_reported_uma) { + has_reported_uma = true; + DEFINE_STATIC_LOCAL(BooleanHistogram, histogram, + ("Media.EME.EncryptedMediaEnabled")); + histogram.Count(encypted_media_enabled); + } + + if (!encypted_media_enabled) { return ScriptPromise::RejectWithDOMException( script_state, DOMException::Create(kNotSupportedError, "Unsupported keySystem")); diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index bbe303316c59..e83556234fa4 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -26939,6 +26939,16 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. + + xhwang@chromium.org + + Whether encrypted media is enabled when requestMediaKeySystemAccess() is + called. User can enable and disable encrypted media in content settings. + Recorded when requestMediaKeySystemAccess() is called but will be reported + at most once per renderer process. + + + xhwang@chromium.org