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

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

Issue 2111673004: When autoplay of muted videos is disabled, record the reason why. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
Index: third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
index 406483be3fc232f1c2cbc80ec0bd140d996d56b5..50e0091a8a0dd77bb29aee80af1bf0bf1be7f354 100644
--- a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
+++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
@@ -8,6 +8,7 @@
#include "core/dom/ElementVisibilityObserver.h"
#include "core/events/Event.h"
#include "core/frame/LocalDOMWindow.h"
+#include "core/frame/Settings.h"
#include "core/html/HTMLMediaElement.h"
#include "platform/Histogram.h"
@@ -46,9 +47,11 @@ void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source)
DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Autoplay", static_cast<int>(AutoplaySource::NumberOfSources)));
DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video.Autoplay.Muted", static_cast<int>(AutoplaySource::NumberOfSources)));
DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Autoplay", static_cast<int>(AutoplaySource::NumberOfSources)));
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, blockedMutedVideoHistogram, ("Media.Video.Autoplay.Muted.Blocked", AutoplayBlockedReasonMax));
m_source = source;
+ // Record the source.
if (m_element->isHTMLVideoElement()) {
videoHistogram.count(static_cast<int>(m_source));
if (m_element->muted())
@@ -57,6 +60,20 @@ void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source)
audioHistogram.count(static_cast<int>(m_source));
}
+ // Record if it will be blocked by Data Saver or Autoplay setting.
+ if (m_element->isHTMLVideoElement() && m_element->muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) {
+ bool dataSaverEnabled = m_element->document().settings() && m_element->document().settings()->dataSaverEnabled();
+ bool blockedBySetting = !m_element->isAutoplayAllowedPerSettings();
+
+ if (dataSaverEnabled && blockedBySetting) {
+ blockedMutedVideoHistogram.count(AutoplayBlockedReasonDataSaverAndSetting);
Zhiqiang Zhang (Slow) 2016/08/24 16:50:47 Autoplay is gray when DataSaver is on, might not b
mlamouri (slow - plz ping) 2016/08/24 21:39:24 It's really in the spirit of not leaking chrome/ b
+ } else if (dataSaverEnabled) {
+ blockedMutedVideoHistogram.count(AutoplayBlockedReasonDataSaver);
+ } else if (blockedBySetting) {
+ blockedMutedVideoHistogram.count(AutoplayBlockedReasonSetting);
+ }
+ }
+
if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted())
m_element->addEventListener(EventTypeNames::playing, this, false);
}
« no previous file with comments | « third_party/WebKit/Source/core/html/AutoplayUmaHelper.h ('k') | third_party/WebKit/Source/core/html/HTMLMediaElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698