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

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

Issue 2052623002: [Android, Media] Enable autoplay settings for muted autoplay, wired them up to the media element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-settings-npe
Patch Set: Rebased, added a test 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/Source/core/html/HTMLMediaElement.h ('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 3691 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 } 3702 }
3703 3703
3704 bool HTMLMediaElement::isGestureNeededForPlayback() const 3704 bool HTMLMediaElement::isGestureNeededForPlayback() const
3705 { 3705 {
3706 if (!m_lockedPendingUserGesture) 3706 if (!m_lockedPendingUserGesture)
3707 return false; 3707 return false;
3708 3708
3709 // We want to allow muted video to autoplay if: 3709 // We want to allow muted video to autoplay if:
3710 // - the flag is enabled; 3710 // - the flag is enabled;
3711 // - Data Saver is not enabled; 3711 // - Data Saver is not enabled;
3712 if (muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled() 3712 // - Autoplay is enabled in settings;
3713 && !(document().settings() && document().settings()->dataSaverEnabled()) ) { 3713 if (muted()
3714 && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()
3715 && !(document().settings() && document().settings()->dataSaverEnabled())
3716 && isAutoplayAllowedPerSettings()) {
3714 return false; 3717 return false;
3715 } 3718 }
3716 3719
3717 if (m_autoplayHelper->isGestureRequirementOverridden()) 3720 if (m_autoplayHelper->isGestureRequirementOverridden())
3718 return false; 3721 return false;
3719 3722
3720 return true; 3723 return true;
3721 } 3724 }
3722 3725
3726 bool HTMLMediaElement::isAutoplayAllowedPerSettings() const
3727 {
3728 LocalFrame* frame = document().frame();
3729 if (!frame)
3730 return false;
3731 FrameLoaderClient* frameLoaderClient = frame->loader().client();
3732 return frameLoaderClient && frameLoaderClient->allowAutoplay(false);
3733 }
3734
3723 void HTMLMediaElement::setNetworkState(NetworkState state) 3735 void HTMLMediaElement::setNetworkState(NetworkState state)
3724 { 3736 {
3725 if (m_networkState != state) { 3737 if (m_networkState != state) {
3726 m_networkState = state; 3738 m_networkState = state;
3727 if (MediaControls* controls = mediaControls()) 3739 if (MediaControls* controls = mediaControls())
3728 controls->networkStateChanged(); 3740 controls->networkStateChanged();
3729 } 3741 }
3730 } 3742 }
3731 3743
3732 void HTMLMediaElement::notifyPositionMayHaveChanged(const IntRect& visibleRect) 3744 void HTMLMediaElement::notifyPositionMayHaveChanged(const IntRect& visibleRect)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
3952 { 3964 {
3953 String mode; 3965 String mode;
3954 if (m_element->document().settings()) 3966 if (m_element->document().settings())
3955 mode = m_element->document().settings()->autoplayExperimentMode(); 3967 mode = m_element->document().settings()->autoplayExperimentMode();
3956 3968
3957 return mode; 3969 return mode;
3958 } 3970 }
3959 3971
3960 bool HTMLMediaElement::AutoplayHelperClientImpl::isAutoplayAllowedPerSettings() const 3972 bool HTMLMediaElement::AutoplayHelperClientImpl::isAutoplayAllowedPerSettings() const
3961 { 3973 {
3962 LocalFrame* frame = m_element->document().frame(); 3974 return m_element->isAutoplayAllowedPerSettings();
3963 if (!frame)
3964 return false;
3965 FrameLoaderClient* frameLoaderClient = frame->loader().client();
3966 return frameLoaderClient && frameLoaderClient->allowAutoplay(false);
3967 } 3975 }
3968 3976
3969 void HTMLMediaElement::AutoplayHelperClientImpl::setRequestPositionUpdates(bool request) 3977 void HTMLMediaElement::AutoplayHelperClientImpl::setRequestPositionUpdates(bool request)
3970 { 3978 {
3971 if (LayoutObject* layoutObject = m_element->layoutObject()) { 3979 if (LayoutObject* layoutObject = m_element->layoutObject()) {
3972 LayoutMediaItem layoutMediaItem = LayoutMediaItem(toLayoutMedia(layoutOb ject)); 3980 LayoutMediaItem layoutMediaItem = LayoutMediaItem(toLayoutMedia(layoutOb ject));
3973 layoutMediaItem.setRequestPositionUpdates(request); 3981 layoutMediaItem.setRequestPositionUpdates(request);
3974 } 3982 }
3975 } 3983 }
3976 3984
3977 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 3985 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
3978 { 3986 {
3979 IntRect result; 3987 IntRect result;
3980 if (LayoutObject* object = m_element->layoutObject()) 3988 if (LayoutObject* object = m_element->layoutObject())
3981 result = object->absoluteBoundingBoxRect(); 3989 result = object->absoluteBoundingBoxRect();
3982 return result; 3990 return result;
3983 } 3991 }
3984 3992
3985 } // namespace blink 3993 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698