| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 if (!m_playPending && !client().shouldAutoplay()) | 321 if (!m_playPending && !client().shouldAutoplay()) |
| 322 return false; | 322 return false; |
| 323 | 323 |
| 324 // Note that the viewport test always returns false on desktop, which is | 324 // Note that the viewport test always returns false on desktop, which is |
| 325 // why video-autoplay-experiment.html doesn't check -ifmobile . | 325 // why video-autoplay-experiment.html doesn't check -ifmobile . |
| 326 if (enabled(IfMobile) | 326 if (enabled(IfMobile) |
| 327 && !client().isLegacyViewportType()) | 327 && !client().isLegacyViewportType()) |
| 328 return false; | 328 return false; |
| 329 | 329 |
| 330 // If we require same-origin, then check the origin. |
| 331 if (enabled(IfSameOrigin) && client().isCrossOrigin()) |
| 332 return false; |
| 333 |
| 330 // If we require muted media and this is muted, then it is eligible. | 334 // If we require muted media and this is muted, then it is eligible. |
| 331 if (enabled(IfMuted)) | 335 if (enabled(IfMuted)) |
| 332 return client().muted(); | 336 return client().muted(); |
| 333 | 337 |
| 334 // Element is eligible for gesture override, maybe muted. | 338 // Element is eligible for gesture override, maybe muted. |
| 335 return true; | 339 return true; |
| 336 } | 340 } |
| 337 | 341 |
| 338 void AutoplayExperimentHelper::muteIfNeeded() | 342 void AutoplayExperimentHelper::muteIfNeeded() |
| 339 { | 343 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 if (mode.contains("-ifpagevisible")) | 391 if (mode.contains("-ifpagevisible")) |
| 388 value |= IfPageVisible; | 392 value |= IfPageVisible; |
| 389 if (mode.contains("-ifviewport")) | 393 if (mode.contains("-ifviewport")) |
| 390 value |= IfViewport; | 394 value |= IfViewport; |
| 391 if (mode.contains("-ifpartialviewport")) | 395 if (mode.contains("-ifpartialviewport")) |
| 392 value |= IfPartialViewport; | 396 value |= IfPartialViewport; |
| 393 if (mode.contains("-ifmuted")) | 397 if (mode.contains("-ifmuted")) |
| 394 value |= IfMuted; | 398 value |= IfMuted; |
| 395 if (mode.contains("-ifmobile")) | 399 if (mode.contains("-ifmobile")) |
| 396 value |= IfMobile; | 400 value |= IfMobile; |
| 401 if (mode.contains("-ifsameorigin")) |
| 402 value |= IfSameOrigin; |
| 397 if (mode.contains("-playmuted")) | 403 if (mode.contains("-playmuted")) |
| 398 value |= PlayMuted; | 404 value |= PlayMuted; |
| 399 | 405 |
| 400 return value; | 406 return value; |
| 401 } | 407 } |
| 402 | 408 |
| 403 void AutoplayExperimentHelper::autoplayMediaEncountered() | 409 void AutoplayExperimentHelper::autoplayMediaEncountered() |
| 404 { | 410 { |
| 405 if (!m_autoplayMediaEncountered) { | 411 if (!m_autoplayMediaEncountered) { |
| 406 m_autoplayMediaEncountered = true; | 412 m_autoplayMediaEncountered = true; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 ? AnyVideoElement | 490 ? AnyVideoElement |
| 485 : AnyAudioElement); | 491 : AnyAudioElement); |
| 486 } | 492 } |
| 487 | 493 |
| 488 bool AutoplayExperimentHelper::requiresViewportVisibility() const | 494 bool AutoplayExperimentHelper::requiresViewportVisibility() const |
| 489 { | 495 { |
| 490 return enabled(IfViewport) || enabled(IfPartialViewport); | 496 return enabled(IfViewport) || enabled(IfPartialViewport); |
| 491 } | 497 } |
| 492 | 498 |
| 493 } // namespace blink | 499 } // namespace blink |
| OLD | NEW |