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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/AutoplayUmaHelper.h" 5 #include "core/html/AutoplayUmaHelper.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ElementVisibilityObserver.h" 8 #include "core/dom/ElementVisibilityObserver.h"
9 #include "core/events/Event.h" 9 #include "core/events/Event.h"
10 #include "core/frame/LocalDOMWindow.h" 10 #include "core/frame/LocalDOMWindow.h"
11 #include "core/frame/Settings.h"
11 #include "core/html/HTMLMediaElement.h" 12 #include "core/html/HTMLMediaElement.h"
12 #include "platform/Histogram.h" 13 #include "platform/Histogram.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 namespace { 17 namespace {
17 18
18 void recordVideoAutoplayMutedPlayMethodBecomesVisibleUma(bool visible) 19 void recordVideoAutoplayMutedPlayMethodBecomesVisibleUma(bool visible)
19 { 20 {
20 DEFINE_STATIC_LOCAL(BooleanHistogram, histogram, ("Media.Video.Autoplay.Mute d.PlayMethod.BecomesVisible")); 21 DEFINE_STATIC_LOCAL(BooleanHistogram, histogram, ("Media.Video.Autoplay.Mute d.PlayMethod.BecomesVisible"));
(...skipping 18 matching lines...) Expand all
39 bool AutoplayUmaHelper::operator==(const EventListener& other) const 40 bool AutoplayUmaHelper::operator==(const EventListener& other) const
40 { 41 {
41 return this == &other; 42 return this == &other;
42 } 43 }
43 44
44 void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source) 45 void AutoplayUmaHelper::onAutoplayInitiated(AutoplaySource source)
45 { 46 {
46 DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Auto play", static_cast<int>(AutoplaySource::NumberOfSources))); 47 DEFINE_STATIC_LOCAL(EnumerationHistogram, videoHistogram, ("Media.Video.Auto play", static_cast<int>(AutoplaySource::NumberOfSources)));
47 DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video .Autoplay.Muted", static_cast<int>(AutoplaySource::NumberOfSources))); 48 DEFINE_STATIC_LOCAL(EnumerationHistogram, mutedVideoHistogram, ("Media.Video .Autoplay.Muted", static_cast<int>(AutoplaySource::NumberOfSources)));
48 DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Auto play", static_cast<int>(AutoplaySource::NumberOfSources))); 49 DEFINE_STATIC_LOCAL(EnumerationHistogram, audioHistogram, ("Media.Audio.Auto play", static_cast<int>(AutoplaySource::NumberOfSources)));
50 DEFINE_STATIC_LOCAL(EnumerationHistogram, blockedMutedVideoHistogram, ("Medi a.Video.Autoplay.Muted.Blocked", AutoplayBlockedReasonMax));
49 51
50 m_source = source; 52 m_source = source;
51 53
54 // Record the source.
52 if (m_element->isHTMLVideoElement()) { 55 if (m_element->isHTMLVideoElement()) {
53 videoHistogram.count(static_cast<int>(m_source)); 56 videoHistogram.count(static_cast<int>(m_source));
54 if (m_element->muted()) 57 if (m_element->muted())
55 mutedVideoHistogram.count(static_cast<int>(m_source)); 58 mutedVideoHistogram.count(static_cast<int>(m_source));
56 } else { 59 } else {
57 audioHistogram.count(static_cast<int>(m_source)); 60 audioHistogram.count(static_cast<int>(m_source));
58 } 61 }
59 62
63 // Record if it will be blocked by Data Saver or Autoplay setting.
64 if (m_element->isHTMLVideoElement() && m_element->muted() && RuntimeEnabledF eatures::autoplayMutedVideosEnabled()) {
65 bool dataSaverEnabled = m_element->document().settings() && m_element->d ocument().settings()->dataSaverEnabled();
66 bool blockedBySetting = !m_element->isAutoplayAllowedPerSettings();
67
68 if (dataSaverEnabled && blockedBySetting) {
69 blockedMutedVideoHistogram.count(AutoplayBlockedReasonDataSaverAndSe tting);
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
70 } else if (dataSaverEnabled) {
71 blockedMutedVideoHistogram.count(AutoplayBlockedReasonDataSaver);
72 } else if (blockedBySetting) {
73 blockedMutedVideoHistogram.count(AutoplayBlockedReasonSetting);
74 }
75 }
76
60 if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted()) 77 if (m_source == AutoplaySource::Method && m_element->isHTMLVideoElement() && m_element->muted())
61 m_element->addEventListener(EventTypeNames::playing, this, false); 78 m_element->addEventListener(EventTypeNames::playing, this, false);
62 } 79 }
63 80
64 void AutoplayUmaHelper::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus st atus) 81 void AutoplayUmaHelper::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus st atus)
65 { 82 {
66 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", static_cast<int>(AutoplayUnmuteActionStatus:: NumberOfStatus))); 83 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", static_cast<int>(AutoplayUnmuteActionStatus:: NumberOfStatus)));
67 84
68 autoplayUnmuteHistogram.count(static_cast<int>(status)); 85 autoplayUnmuteHistogram.count(static_cast<int>(status));
69 } 86 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 143 }
127 144
128 DEFINE_TRACE(AutoplayUmaHelper) 145 DEFINE_TRACE(AutoplayUmaHelper)
129 { 146 {
130 EventListener::trace(visitor); 147 EventListener::trace(visitor);
131 visitor->trace(m_element); 148 visitor->trace(m_element);
132 visitor->trace(m_videoMutedPlayMethodVisibilityObserver); 149 visitor->trace(m_videoMutedPlayMethodVisibilityObserver);
133 } 150 }
134 151
135 } // namespace blink 152 } // namespace blink
OLDNEW
« 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