Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 1700743003: Record whether and why the media default controls are being shown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media-controls-usecount
Patch Set: review comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index a10491cfbac6f7463e57e54240a6abec84fb8f2e..31187d887237c852d3593574fe45e9f87b59c304 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -111,6 +111,14 @@ namespace {
// URL protocol used to signal that the media source API is being used.
const char mediaSourceBlobProtocol[] = "blob";
+enum MediaControlsShow {
+ MediaControlsShowAttribute = 0,
+ MediaControlsShowFullscreen,
+ MediaControlsShowNoScript,
+ MediaControlsShowNotShown,
+ MediaControlsShowMax
+};
+
#if !LOG_DISABLED
String urlForLoggingMedia(const KURL& url)
{
@@ -2078,19 +2086,32 @@ void HTMLMediaElement::setLoop(bool b)
setBooleanAttribute(loopAttr, b);
}
-bool HTMLMediaElement::shouldShowControls() const
+bool HTMLMediaElement::shouldShowControls(const RecordMetricsBehavior recordMetrics) const
{
- LocalFrame* frame = document().frame();
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, showControlsHistogram, ("Media.Controls.Show", MediaControlsShowMax));
- // always show controls when scripting is disabled
- if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript))
+ if (fastHasAttribute(controlsAttr)) {
+ if (recordMetrics == RecordMetricsBehavior::DoRecord)
+ showControlsHistogram.count(MediaControlsShowAttribute);
return true;
+ }
- // Always show controls when in full screen mode.
- if (isFullscreen())
+ if (isFullscreen()) {
+ if (recordMetrics == RecordMetricsBehavior::DoRecord)
+ showControlsHistogram.count(MediaControlsShowFullscreen);
return true;
+ }
- return fastHasAttribute(controlsAttr);
+ LocalFrame* frame = document().frame();
+ if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) {
+ if (recordMetrics == RecordMetricsBehavior::DoRecord)
+ showControlsHistogram.count(MediaControlsShowNoScript);
+ return true;
+ }
+
+ if (recordMetrics == RecordMetricsBehavior::DoRecord)
+ showControlsHistogram.count(MediaControlsShowNotShown);
+ return false;
}
double HTMLMediaElement::volume() const
@@ -3346,7 +3367,8 @@ void HTMLMediaElement::configureMediaControls()
ensureMediaControls();
mediaControls()->reset();
- if (shouldShowControls())
+
+ if (shouldShowControls(RecordMetricsBehavior::DoRecord))
mediaControls()->show();
else
mediaControls()->hide();
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698