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

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

Issue 2046403002: Autoplay: disable muted video autoplay if data saver is on. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@video-as-images-flag
Patch Set: 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
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 3646 matching lines...) Expand 10 before | Expand all | Expand 10 after
3657 void HTMLMediaElement::unlockUserGesture() 3657 void HTMLMediaElement::unlockUserGesture()
3658 { 3658 {
3659 m_lockedPendingUserGesture = false; 3659 m_lockedPendingUserGesture = false;
3660 } 3660 }
3661 3661
3662 bool HTMLMediaElement::isGestureNeededForPlayback() 3662 bool HTMLMediaElement::isGestureNeededForPlayback()
3663 { 3663 {
3664 if (!m_lockedPendingUserGesture) 3664 if (!m_lockedPendingUserGesture)
3665 return false; 3665 return false;
3666 3666
3667 if (muted() && RuntimeEnabledFeatures::videosAsImagesEnabled()) 3667 // We want to allow muted video to autoplay if:
3668 // - the flag is enabled;
3669 // - Data Saver is not enabled;
3670 if (muted() && RuntimeEnabledFeatures::videosAsImagesEnabled()
3671 && !(document().settings() && document().settings()->dataSaverEnabled()) ) {
3668 return false; 3672 return false;
3673 }
3669 3674
3670 if (m_autoplayHelper->isGestureRequirementOverridden()) 3675 if (m_autoplayHelper->isGestureRequirementOverridden())
3671 return false; 3676 return false;
3672 3677
3673 return true; 3678 return true;
3674 } 3679 }
3675 3680
3676 void HTMLMediaElement::setNetworkState(NetworkState state) 3681 void HTMLMediaElement::setNetworkState(NetworkState state)
3677 { 3682 {
3678 if (m_networkState != state) { 3683 if (m_networkState != state) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 3894
3890 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 3895 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
3891 { 3896 {
3892 IntRect result; 3897 IntRect result;
3893 if (LayoutObject* object = m_element->layoutObject()) 3898 if (LayoutObject* object = m_element->layoutObject())
3894 result = object->absoluteBoundingBoxRect(); 3899 result = object->absoluteBoundingBoxRect();
3895 return result; 3900 return result;
3896 } 3901 }
3897 3902
3898 } // namespace blink 3903 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698