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

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

Issue 2047333002: Pause autoplay muted video when unmuting if there's no user gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay-flag
Patch Set: Addressed comments Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/media/autoplay-muted.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 2276
2277 bool HTMLMediaElement::muted() const 2277 bool HTMLMediaElement::muted() const
2278 { 2278 {
2279 return m_muted; 2279 return m_muted;
2280 } 2280 }
2281 2281
2282 void HTMLMediaElement::setMuted(bool muted) 2282 void HTMLMediaElement::setMuted(bool muted)
2283 { 2283 {
2284 DVLOG(MEDIA_LOG_LEVEL) << "setMuted(" << (void*)this << ", " << boolString(m uted) << ")"; 2284 DVLOG(MEDIA_LOG_LEVEL) << "setMuted(" << (void*)this << ", " << boolString(m uted) << ")";
2285 2285
2286 if (UserGestureIndicator::processingUserGesture())
2287 unlockUserGesture();
2288
2286 if (m_muted == muted) 2289 if (m_muted == muted)
2287 return; 2290 return;
2288 2291
2289 m_muted = muted; 2292 m_muted = muted;
2290 m_autoplayHelper->mutedChanged(); 2293 m_autoplayHelper->mutedChanged();
2291 2294
2292 updateVolume(); 2295 updateVolume();
2293 2296
2294 if (muted) 2297 if (muted)
2295 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _On")); 2298 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _On"));
2296 else 2299 else
2297 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off")); 2300 Platform::current()->recordAction(UserMetricsAction("Media_Playback_Mute _Off"));
2298 2301
2299 scheduleEvent(EventTypeNames::volumechange); 2302 scheduleEvent(EventTypeNames::volumechange);
2303
2304 // Pause the element when unmuting if it's still locked.
2305 if (!muted && isGestureNeededForPlayback())
2306 pause();
2300 } 2307 }
2301 2308
2302 void HTMLMediaElement::updateVolume() 2309 void HTMLMediaElement::updateVolume()
2303 { 2310 {
2304 if (webMediaPlayer()) 2311 if (webMediaPlayer())
2305 webMediaPlayer()->setVolume(effectiveMediaVolume()); 2312 webMediaPlayer()->setVolume(effectiveMediaVolume());
2306 2313
2307 if (mediaControls()) 2314 if (mediaControls())
2308 mediaControls()->updateVolume(); 2315 mediaControls()->updateVolume();
2309 } 2316 }
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 3976
3970 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 3977 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
3971 { 3978 {
3972 IntRect result; 3979 IntRect result;
3973 if (LayoutObject* object = m_element->layoutObject()) 3980 if (LayoutObject* object = m_element->layoutObject())
3974 result = object->absoluteBoundingBoxRect(); 3981 result = object->absoluteBoundingBoxRect();
3975 return result; 3982 return result;
3976 } 3983 }
3977 3984
3978 } // namespace blink 3985 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/media/autoplay-muted.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698