OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/html/AutoplayExperimentHelper.h" | 5 #include "core/html/AutoplayExperimentHelper.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
9 #include "core/html/HTMLMediaElement.h" | 9 #include "core/html/HTMLMediaElement.h" |
10 #include "core/layout/LayoutBox.h" | 10 #include "core/layout/LayoutBox.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 client().playInternal(); | 294 client().playInternal(); |
295 | 295 |
296 return true; | 296 return true; |
297 } | 297 } |
298 | 298 |
299 bool AutoplayExperimentHelper::isEligible() const | 299 bool AutoplayExperimentHelper::isEligible() const |
300 { | 300 { |
301 if (m_mode == Mode::ExperimentOff) | 301 if (m_mode == Mode::ExperimentOff) |
302 return false; | 302 return false; |
303 | 303 |
| 304 // If autoplay is disabled, no one is eligible. |
| 305 if (!client().isAutoplayAllowedPerSettings()) |
| 306 return false; |
| 307 |
304 // If no user gesture is required, then the experiment doesn't apply. | 308 // If no user gesture is required, then the experiment doesn't apply. |
305 // This is what prevents us from starting playback more than once. | 309 // This is what prevents us from starting playback more than once. |
306 // Since this flag is never set to true once it's cleared, it will block | 310 // Since this flag is never set to true once it's cleared, it will block |
307 // the autoplay experiment forever. | 311 // the autoplay experiment forever. |
308 if (!isUserGestureRequiredForPlay()) | 312 if (!isUserGestureRequiredForPlay()) |
309 return false; | 313 return false; |
310 | 314 |
311 // Make sure that this is an element of the right type. | 315 // Make sure that this is an element of the right type. |
312 if (!enabled(ForVideo) && client().isHTMLVideoElement()) | 316 if (!enabled(ForVideo) && client().isHTMLVideoElement()) |
313 return false; | 317 return false; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 ? AnyVideoElement | 494 ? AnyVideoElement |
491 : AnyAudioElement); | 495 : AnyAudioElement); |
492 } | 496 } |
493 | 497 |
494 bool AutoplayExperimentHelper::requiresViewportVisibility() const | 498 bool AutoplayExperimentHelper::requiresViewportVisibility() const |
495 { | 499 { |
496 return enabled(IfViewport) || enabled(IfPartialViewport); | 500 return enabled(IfViewport) || enabled(IfPartialViewport); |
497 } | 501 } |
498 | 502 |
499 } // namespace blink | 503 } // namespace blink |
OLD | NEW |