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

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: 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 3671 matching lines...) Expand 10 before | Expand all | Expand 10 after
3682 m_lockedPendingUserGesture = false; 3682 m_lockedPendingUserGesture = false;
3683 } 3683 }
3684 3684
3685 bool HTMLMediaElement::isGestureNeededForPlayback() 3685 bool HTMLMediaElement::isGestureNeededForPlayback()
3686 { 3686 {
3687 m_isAutoplayingMuted = false; 3687 m_isAutoplayingMuted = false;
3688 3688
3689 if (!m_lockedPendingUserGesture) 3689 if (!m_lockedPendingUserGesture)
3690 return false; 3690 return false;
3691 3691
3692 if (!isAutoplayAllowedPerSettings())
3693 return true;
mlamouri (slow - plz ping) 2016/06/09 11:15:07 I don't think that's okay. It will allow content s
whywhat 2016/06/09 19:42:39 Only check it after the check below.
3694
3692 if (muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) { 3695 if (muted() && RuntimeEnabledFeatures::autoplayMutedVideosEnabled()) {
3693 m_isAutoplayingMuted = true; 3696 m_isAutoplayingMuted = true;
3694 return false; 3697 return false;
3695 } 3698 }
3696 3699
3697 if (m_autoplayHelper->isGestureRequirementOverridden()) 3700 if (m_autoplayHelper->isGestureRequirementOverridden())
3698 return false; 3701 return false;
3699 3702
3700 return true; 3703 return true;
3701 } 3704 }
3702 3705
3706 bool HTMLMediaElement::isAutoplayAllowedPerSettings() const
3707 {
3708 LocalFrame* frame = document().frame();
3709 if (!frame)
3710 return false;
3711 FrameLoaderClient* frameLoaderClient = frame->loader().client();
3712 return frameLoaderClient && frameLoaderClient->allowAutoplay(false);
3713 }
3714
3703 void HTMLMediaElement::setNetworkState(NetworkState state) 3715 void HTMLMediaElement::setNetworkState(NetworkState state)
3704 { 3716 {
3705 if (m_networkState != state) { 3717 if (m_networkState != state) {
3706 m_networkState = state; 3718 m_networkState = state;
3707 if (MediaControls* controls = mediaControls()) 3719 if (MediaControls* controls = mediaControls())
3708 controls->networkStateChanged(); 3720 controls->networkStateChanged();
3709 } 3721 }
3710 } 3722 }
3711 3723
3712 void HTMLMediaElement::notifyPositionMayHaveChanged(const IntRect& visibleRect) 3724 void HTMLMediaElement::notifyPositionMayHaveChanged(const IntRect& visibleRect)
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3917 { 3929 {
3918 String mode; 3930 String mode;
3919 if (m_element->document().settings()) 3931 if (m_element->document().settings())
3920 mode = m_element->document().settings()->autoplayExperimentMode(); 3932 mode = m_element->document().settings()->autoplayExperimentMode();
3921 3933
3922 return mode; 3934 return mode;
3923 } 3935 }
3924 3936
3925 bool HTMLMediaElement::AutoplayHelperClientImpl::isAutoplayAllowedPerSettings() const 3937 bool HTMLMediaElement::AutoplayHelperClientImpl::isAutoplayAllowedPerSettings() const
3926 { 3938 {
3927 LocalFrame* frame = m_element->document().frame(); 3939 return m_element->isAutoplayAllowedPerSettings();
3928 if (!frame)
3929 return false;
3930 FrameLoaderClient* frameLoaderClient = frame->loader().client();
3931 return frameLoaderClient && frameLoaderClient->allowAutoplay(false);
3932 } 3940 }
3933 3941
3934 void HTMLMediaElement::AutoplayHelperClientImpl::setRequestPositionUpdates(bool request) 3942 void HTMLMediaElement::AutoplayHelperClientImpl::setRequestPositionUpdates(bool request)
3935 { 3943 {
3936 if (LayoutObject* layoutObject = m_element->layoutObject()) { 3944 if (LayoutObject* layoutObject = m_element->layoutObject()) {
3937 LayoutMediaItem layoutMediaItem = LayoutMediaItem(toLayoutMedia(layoutOb ject)); 3945 LayoutMediaItem layoutMediaItem = LayoutMediaItem(toLayoutMedia(layoutOb ject));
3938 layoutMediaItem.setRequestPositionUpdates(request); 3946 layoutMediaItem.setRequestPositionUpdates(request);
3939 } 3947 }
3940 } 3948 }
3941 3949
3942 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 3950 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
3943 { 3951 {
3944 IntRect result; 3952 IntRect result;
3945 if (LayoutObject* object = m_element->layoutObject()) 3953 if (LayoutObject* object = m_element->layoutObject())
3946 result = object->absoluteBoundingBoxRect(); 3954 result = object->absoluteBoundingBoxRect();
3947 return result; 3955 return result;
3948 } 3956 }
3949 3957
3950 } // namespace blink 3958 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698