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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2091253002: When autoplaying muted video, record when unmute happen and the result. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments and rebase Created 4 years, 5 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 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 2283
2284 bool HTMLMediaElement::muted() const 2284 bool HTMLMediaElement::muted() const
2285 { 2285 {
2286 return m_muted; 2286 return m_muted;
2287 } 2287 }
2288 2288
2289 void HTMLMediaElement::setMuted(bool muted) 2289 void HTMLMediaElement::setMuted(bool muted)
2290 { 2290 {
2291 MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) << ")"; 2291 MEDIA_LOG << "setMuted(" << (void*)this << ", " << boolString(muted) << ")";
2292 2292
2293 if (m_muted == muted)
2294 return;
2295
2296 bool wasAutoplayingMuted = !paused() && m_muted && isLockedPendingUserGestur e();
2297
2293 if (UserGestureIndicator::processingUserGesture()) 2298 if (UserGestureIndicator::processingUserGesture())
whywhat 2016/06/29 19:44:18 nit: you could avoid moving that if calculating wa
mlamouri (slow - plz ping) 2016/06/29 19:47:59 ACK :)
2294 unlockUserGesture(); 2299 unlockUserGesture();
2295 2300
2296 if (m_muted == muted)
2297 return;
2298
2299 m_muted = muted; 2301 m_muted = muted;
2300 m_autoplayHelper->mutedChanged(); 2302 m_autoplayHelper->mutedChanged();
2301 2303
2302 updateVolume(); 2304 updateVolume();
2303 2305
2304 if (muted) 2306 if (muted)
2305 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _On")); 2307 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _On"));
2306 else 2308 else
2307 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off")); 2309 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off"));
2308 2310
2309 scheduleEvent(EventTypeNames::volumechange); 2311 scheduleEvent(EventTypeNames::volumechange);
2310 2312
2311 // Pause the element when unmuting if it's still locked. 2313 // If an element autoplayed while muted, it needs to be unlocked to unmute,
2312 if (!muted && isGestureNeededForPlayback()) 2314 // otherwise, it will be paused.
2313 pause(); 2315 if (wasAutoplayingMuted) {
2316 if (isGestureNeededForPlayback()) {
2317 pause();
2318 recordAutoplayUnmuteStatus(AutoplayUnmuteActionFailure);
2319 } else {
2320 recordAutoplayUnmuteStatus(AutoplayUnmuteActionSuccess);
2321 }
2322 }
2314 } 2323 }
2315 2324
2316 void HTMLMediaElement::updateVolume() 2325 void HTMLMediaElement::updateVolume()
2317 { 2326 {
2318 if (webMediaPlayer()) 2327 if (webMediaPlayer())
2319 webMediaPlayer()->setVolume(effectiveMediaVolume()); 2328 webMediaPlayer()->setVolume(effectiveMediaVolume());
2320 2329
2321 if (mediaControls()) 2330 if (mediaControls())
2322 mediaControls()->updateVolume(); 2331 mediaControls()->updateVolume();
2323 } 2332 }
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
3891 3900
3892 if (isHTMLVideoElement()) { 3901 if (isHTMLVideoElement()) {
3893 videoHistogram.count(source); 3902 videoHistogram.count(source);
3894 if (muted()) 3903 if (muted())
3895 mutedVideoHistogram.count(source); 3904 mutedVideoHistogram.count(source);
3896 } else { 3905 } else {
3897 audioHistogram.count(source); 3906 audioHistogram.count(source);
3898 } 3907 }
3899 } 3908 }
3900 3909
3910 void HTMLMediaElement::recordAutoplayUnmuteStatus(AutoplayUnmuteActionStatus sta tus)
3911 {
3912 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayUnmuteHistogram, ("Media.V ideo.Autoplay.Muted.UnmuteAction", AutoplayUnmuteActionMax));
3913
3914 autoplayUnmuteHistogram.count(status);
3915 }
3916
3901 void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible) 3917 void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible)
3902 { 3918 {
3903 if (!isVisible) 3919 if (!isVisible)
3904 return; 3920 return;
3905 3921
3906 if (shouldAutoplay()) { 3922 if (shouldAutoplay()) {
3907 m_paused = false; 3923 m_paused = false;
3908 invalidateCachedTime(); 3924 invalidateCachedTime();
3909 scheduleEvent(EventTypeNames::play); 3925 scheduleEvent(EventTypeNames::play);
3910 scheduleNotifyPlaying(); 3926 scheduleNotifyPlaying();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
4023 4039
4024 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 4040 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
4025 { 4041 {
4026 IntRect result; 4042 IntRect result;
4027 if (LayoutObject* object = m_element->layoutObject()) 4043 if (LayoutObject* object = m_element->layoutObject())
4028 result = object->absoluteBoundingBoxRect(); 4044 result = object->absoluteBoundingBoxRect();
4029 return result; 4045 return result;
4030 } 4046 }
4031 4047
4032 } // namespace blink 4048 } // namespace blink
OLDNEW
« 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