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

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

Issue 2563723002: [Autoplay] Add more rappor metrics for autoplay in cross-origin iframes (Closed)
Patch Set: rebased Created 4 years 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/AutoplayUmaHelper.h ('k') | tools/metrics/rappor/rappor.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/AutoplayUmaHelper.cpp
diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
index 0ab3aadbe30e92733cd7a183eb79e150895bf38b..bf2d6ffbe9d9b3952a08e4ee184f77283cc4e642 100644
--- a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
+++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
@@ -210,6 +210,7 @@ void AutoplayUmaHelper::handlePlayingEvent() {
void AutoplayUmaHelper::handlePauseEvent() {
maybeStopRecordingMutedVideoOffscreenDuration();
+ maybeRecordUserPausedAutoplayingCrossOriginVideo();
}
void AutoplayUmaHelper::contextDestroyed() {
@@ -299,21 +300,55 @@ void AutoplayUmaHelper::maybeStopRecordingMutedVideoOffscreenDuration() {
m_mutedVideoOffscreenDurationVisibilityObserver->stop();
m_mutedVideoOffscreenDurationVisibilityObserver = nullptr;
m_mutedVideoAutoplayOffscreenDurationMS = 0;
- m_element->removeEventListener(EventTypeNames::pause, this, false);
+ maybeUnregisterMediaElementPauseListener();
maybeUnregisterContextDestroyedObserver();
}
+void AutoplayUmaHelper::maybeRecordUserPausedAutoplayingCrossOriginVideo() {
+ if (!shouldRecordUserPausedAutoplayingCrossOriginVideo())
+ return;
+
+ if (m_element->ended() || m_element->seeking())
+ return;
+
+ Platform::current()->recordRapporURL(
+ "Media.Autoplay.CrossOrigin.UserPausedAutoplayingVideo.ChildFrame",
+ m_element->document().url());
+ Platform::current()->recordRapporURL(
+ "Media.Autoplay.CrossOrigin.UserPausedAutoplayingVideo."
+ "TopLevelFrame",
+ m_element->document().topDocument().url());
+
+ m_hasRecordedUserPausedAutoplayingCrossOriginVideo = true;
+ maybeUnregisterMediaElementPauseListener();
+}
+
void AutoplayUmaHelper::maybeUnregisterContextDestroyedObserver() {
if (!shouldListenToContextDestroyed()) {
setContext(nullptr);
}
}
+void AutoplayUmaHelper::maybeUnregisterMediaElementPauseListener() {
+ if (m_mutedVideoOffscreenDurationVisibilityObserver)
+ return;
+ if (shouldRecordUserPausedAutoplayingCrossOriginVideo())
+ return;
+ m_element->removeEventListener(EventTypeNames::pause, this, false);
+}
+
bool AutoplayUmaHelper::shouldListenToContextDestroyed() const {
return m_mutedVideoPlayMethodVisibilityObserver ||
m_mutedVideoOffscreenDurationVisibilityObserver;
}
+bool AutoplayUmaHelper::shouldRecordUserPausedAutoplayingCrossOriginVideo()
+ const {
+ return m_element->isInCrossOriginFrame() && m_element->isHTMLVideoElement() &&
+ m_source != AutoplaySource::NumberOfSources &&
+ !m_hasRecordedUserPausedAutoplayingCrossOriginVideo;
+}
+
DEFINE_TRACE(AutoplayUmaHelper) {
EventListener::trace(visitor);
ContextLifecycleObserver::trace(visitor);
« no previous file with comments | « third_party/WebKit/Source/core/html/AutoplayUmaHelper.h ('k') | tools/metrics/rappor/rappor.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698