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

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

Issue 1920863005: Disable autoplay experiments if the autoplay content settings is set to block. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay-ifsameorigin-ormuted
Patch Set: rebase with tests Created 4 years, 7 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 PageVisibilityState pageVisibilityState() const override; 317 PageVisibilityState pageVisibilityState() const override;
318 String autoplayExperimentMode() const override; 318 String autoplayExperimentMode() const override;
319 319
320 // Frame 320 // Frame
321 bool isCrossOrigin() const override 321 bool isCrossOrigin() const override
322 { 322 {
323 const Frame* frame = m_element->document().frame(); 323 const Frame* frame = m_element->document().frame();
324 return frame && frame->isCrossOrigin(); 324 return frame && frame->isCrossOrigin();
325 } 325 }
326 326
327 bool isAutoplayAllowedPerSettings() const override;
328
327 // LayoutObject 329 // LayoutObject
328 void setRequestPositionUpdates(bool) override; 330 void setRequestPositionUpdates(bool) override;
329 IntRect absoluteBoundingBoxRect() const override; 331 IntRect absoluteBoundingBoxRect() const override;
330 332
331 DEFINE_INLINE_VIRTUAL_TRACE() 333 DEFINE_INLINE_VIRTUAL_TRACE()
332 { 334 {
333 visitor->trace(m_element); 335 visitor->trace(m_element);
334 Client::trace(visitor); 336 Client::trace(visitor);
335 } 337 }
336 338
(...skipping 3494 matching lines...) Expand 10 before | Expand all | Expand 10 after
3831 3833
3832 String HTMLMediaElement::AutoplayHelperClientImpl::autoplayExperimentMode() cons t 3834 String HTMLMediaElement::AutoplayHelperClientImpl::autoplayExperimentMode() cons t
3833 { 3835 {
3834 String mode; 3836 String mode;
3835 if (m_element->document().settings()) 3837 if (m_element->document().settings())
3836 mode = m_element->document().settings()->autoplayExperimentMode(); 3838 mode = m_element->document().settings()->autoplayExperimentMode();
3837 3839
3838 return mode; 3840 return mode;
3839 } 3841 }
3840 3842
3843 bool HTMLMediaElement::AutoplayHelperClientImpl::isAutoplayAllowedPerSettings() const
3844 {
3845 LocalFrame* frame = m_element->document().frame();
3846 if (!frame)
3847 return false;
3848 FrameLoaderClient* frameLoaderClient = frame->loader().client();
3849 return frameLoaderClient && frameLoaderClient->allowAutoplay(false);
3850 }
3851
3841 void HTMLMediaElement::AutoplayHelperClientImpl::setRequestPositionUpdates(bool request) 3852 void HTMLMediaElement::AutoplayHelperClientImpl::setRequestPositionUpdates(bool request)
3842 { 3853 {
3843 if (LayoutObject* layoutObject = m_element->layoutObject()) { 3854 if (LayoutObject* layoutObject = m_element->layoutObject()) {
3844 LayoutMediaItem layoutMediaItem = LayoutMediaItem(toLayoutMedia(layoutOb ject)); 3855 LayoutMediaItem layoutMediaItem = LayoutMediaItem(toLayoutMedia(layoutOb ject));
3845 layoutMediaItem.setRequestPositionUpdates(request); 3856 layoutMediaItem.setRequestPositionUpdates(request);
3846 } 3857 }
3847 } 3858 }
3848 3859
3849 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst 3860 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co nst
3850 { 3861 {
3851 IntRect result; 3862 IntRect result;
3852 if (LayoutObject* object = m_element->layoutObject()) 3863 if (LayoutObject* object = m_element->layoutObject())
3853 result = object->absoluteBoundingBoxRect(); 3864 result = object->absoluteBoundingBoxRect();
3854 return result; 3865 return result;
3855 } 3866 }
3856 3867
3857 } // namespace blink 3868 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698