| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef AutoplayExperimentConfig_h | 5 #ifndef AutoplayExperimentConfig_h |
| 6 #define AutoplayExperimentConfig_h | 6 #define AutoplayExperimentConfig_h |
| 7 | 7 |
| 8 namespace WTF { | 8 namespace WTF { |
| 9 class String; | 9 class String; |
| 10 } | 10 } |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class AutoplayExperimentConfig { | 14 class AutoplayExperimentConfig { |
| 15 public: | 15 public: |
| 16 // Experiment configuration bits. These maybe combined. For example, | 16 // Experiment configuration bits. These maybe combined. For example, |
| 17 // ForVideo|IfMuted will override the user gesture requirement for | 17 // ForVideo|IfViewport will override the user gesture requirement for |
| 18 // playing video that has no audio or is muted. ForVideo, by itself, | 18 // playing video that is visible in the viewport. ForVideo, by itself, |
| 19 // will entirely override the user gesture requirement for all video | 19 // will entirely override the user gesture requirement for all video |
| 20 // elements, but not for audio elements. | 20 // elements, but not for audio elements. |
| 21 enum Mode { | 21 enum Mode { |
| 22 // Do not enable the autoplay experiment. | 22 // Do not enable the autoplay experiment. |
| 23 Off = 0, | 23 Off = 0, |
| 24 // Enable gestureless autoplay for video elements. | 24 // Enable gestureless autoplay for video elements. |
| 25 ForVideo = 1 << 0, | 25 ForVideo = 1 << 0, |
| 26 // Enable gestureless autoplay for audio elements. | 26 // Enable gestureless autoplay for audio elements. |
| 27 ForAudio = 1 << 1, | 27 ForAudio = 1 << 1, |
| 28 // Restrict gestureless autoplay to media that is in a visible page. |
| 29 IfPageVisible = 1 << 2, |
| 30 // Restrict gestureless autoplay to media that is visible in |
| 31 // the viewport. |
| 32 IfViewport = 1 << 3, |
| 28 // Restrict gestureless autoplay to audio-less or muted media. | 33 // Restrict gestureless autoplay to audio-less or muted media. |
| 29 IfMuted = 1 << 2, | 34 IfMuted = 1 << 4, |
| 30 // Restrict gestureless autoplay to sites which contain the | 35 // Restrict gestureless autoplay to sites which contain the |
| 31 // viewport tag. | 36 // viewport tag. |
| 32 IfMobile = 1 << 3, | 37 IfMobile = 1 << 5, |
| 33 // If gestureless autoplay is allowed, then mute the media before | 38 // If gestureless autoplay is allowed, then mute the media before |
| 34 // starting to play. | 39 // starting to play. |
| 35 PlayMuted = 1 << 4, | 40 PlayMuted = 1 << 6, |
| 36 }; | 41 }; |
| 37 | 42 |
| 38 static Mode fromString(const WTF::String& token); | 43 static Mode fromString(const WTF::String& token); |
| 39 }; | 44 }; |
| 40 | 45 |
| 41 inline AutoplayExperimentConfig::Mode& operator|=(AutoplayExperimentConfig::Mode
& a, const AutoplayExperimentConfig::Mode& b) | 46 inline AutoplayExperimentConfig::Mode& operator|=(AutoplayExperimentConfig::Mode
& a, const AutoplayExperimentConfig::Mode& b) |
| 42 { | 47 { |
| 43 a = static_cast<AutoplayExperimentConfig::Mode>( | 48 a = static_cast<AutoplayExperimentConfig::Mode>( |
| 44 static_cast<int>(a) | static_cast<int>(b)); | 49 static_cast<int>(a) | static_cast<int>(b)); |
| 45 return a; | 50 return a; |
| 46 } | 51 } |
| 47 | 52 |
| 48 } // namespace blink | 53 } // namespace blink |
| 49 | 54 |
| 50 #endif // AutoplayExperimentConfig_h | 55 #endif // AutoplayExperimentConfig_h |
| OLD | NEW |