| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 case WebMediaPlayer::PreloadMetaData: | 281 case WebMediaPlayer::PreloadMetaData: |
| 282 return "metadata"; | 282 return "metadata"; |
| 283 case WebMediaPlayer::PreloadAuto: | 283 case WebMediaPlayer::PreloadAuto: |
| 284 return "auto"; | 284 return "auto"; |
| 285 } | 285 } |
| 286 | 286 |
| 287 NOTREACHED(); | 287 NOTREACHED(); |
| 288 return String(); | 288 return String(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 bool isDocumentCrossOrigin(Document& document) { |
| 292 const LocalFrame* frame = document.frame(); |
| 293 return frame && frame->isCrossOriginSubframe(); |
| 294 } |
| 295 |
| 296 // Return true if and only if the document settings specifies media playback |
| 297 // requires user gesture. |
| 298 bool computeLockedPendingUserGesture(Document& document) { |
| 299 if (!document.settings()) |
| 300 return false; |
| 301 |
| 302 if (document.settings()->crossOriginMediaPlaybackRequiresUserGesture() && |
| 303 isDocumentCrossOrigin(document)) { |
| 304 return true; |
| 305 } |
| 306 |
| 307 return document.settings()->mediaPlaybackRequiresUserGesture(); |
| 308 } |
| 309 |
| 291 } // anonymous namespace | 310 } // anonymous namespace |
| 292 | 311 |
| 293 MIMETypeRegistry::SupportsType HTMLMediaElement::supportsType( | 312 MIMETypeRegistry::SupportsType HTMLMediaElement::supportsType( |
| 294 const ContentType& contentType) { | 313 const ContentType& contentType) { |
| 295 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 314 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
| 296 | 315 |
| 297 String type = contentType.type().lower(); | 316 String type = contentType.type().lower(); |
| 298 // The codecs string is not lower-cased because MP4 values are case sensitive | 317 // The codecs string is not lower-cased because MP4 values are case sensitive |
| 299 // per http://tools.ietf.org/html/rfc4281#page-7. | 318 // per http://tools.ietf.org/html/rfc4281#page-7. |
| 300 String typeCodecs = contentType.parameter(codecs); | 319 String typeCodecs = contentType.parameter(codecs); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 m_videoTracks(this, VideoTrackList::create(*this)), | 414 m_videoTracks(this, VideoTrackList::create(*this)), |
| 396 m_textTracks(this, nullptr), | 415 m_textTracks(this, nullptr), |
| 397 m_audioSourceNode(nullptr), | 416 m_audioSourceNode(nullptr), |
| 398 m_autoplayUmaHelper(AutoplayUmaHelper::create(this)), | 417 m_autoplayUmaHelper(AutoplayUmaHelper::create(this)), |
| 399 m_remotePlaybackClient(nullptr), | 418 m_remotePlaybackClient(nullptr), |
| 400 m_autoplayVisibilityObserver(nullptr) { | 419 m_autoplayVisibilityObserver(nullptr) { |
| 401 ThreadState::current()->registerPreFinalizer(this); | 420 ThreadState::current()->registerPreFinalizer(this); |
| 402 | 421 |
| 403 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; | 422 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; |
| 404 | 423 |
| 405 // If any experiment is enabled, then we want to enable a user gesture by | 424 m_lockedPendingUserGesture = computeLockedPendingUserGesture(document); |
| 406 // default, otherwise the experiment does nothing. | |
| 407 if ((document.settings() && | |
| 408 document.settings()->mediaPlaybackRequiresUserGesture())) { | |
| 409 m_lockedPendingUserGesture = true; | |
| 410 } | |
| 411 | 425 |
| 412 LocalFrame* frame = document.frame(); | 426 LocalFrame* frame = document.frame(); |
| 413 if (frame) { | 427 if (frame) { |
| 414 m_remotePlaybackClient = | 428 m_remotePlaybackClient = |
| 415 frame->loader().client()->createWebRemotePlaybackClient(*this); | 429 frame->loader().client()->createWebRemotePlaybackClient(*this); |
| 416 } | 430 } |
| 417 | 431 |
| 418 setHasCustomStyleCallbacks(); | 432 setHasCustomStyleCallbacks(); |
| 419 addElementToDocumentMap(this, &document); | 433 addElementToDocumentMap(this, &document); |
| 420 | 434 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 444 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 458 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 445 } | 459 } |
| 446 | 460 |
| 447 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) { | 461 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) { |
| 448 BLINK_MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")"; | 462 BLINK_MEDIA_LOG << "didMoveToNewDocument(" << (void*)this << ")"; |
| 449 | 463 |
| 450 m_autoplayUmaHelper->didMoveToNewDocument(oldDocument); | 464 m_autoplayUmaHelper->didMoveToNewDocument(oldDocument); |
| 451 // If any experiment is enabled, then we want to enable a user gesture by | 465 // If any experiment is enabled, then we want to enable a user gesture by |
| 452 // default, otherwise the experiment does nothing. | 466 // default, otherwise the experiment does nothing. |
| 453 bool oldDocumentRequiresUserGesture = | 467 bool oldDocumentRequiresUserGesture = |
| 454 (oldDocument.settings() && | 468 computeLockedPendingUserGesture(oldDocument); |
| 455 oldDocument.settings()->mediaPlaybackRequiresUserGesture()); | |
| 456 bool newDocumentRequiresUserGesture = | 469 bool newDocumentRequiresUserGesture = |
| 457 (document().settings() && | 470 computeLockedPendingUserGesture(document()); |
| 458 document().settings()->mediaPlaybackRequiresUserGesture()); | |
| 459 if (newDocumentRequiresUserGesture && !oldDocumentRequiresUserGesture) { | 471 if (newDocumentRequiresUserGesture && !oldDocumentRequiresUserGesture) { |
| 460 m_lockedPendingUserGesture = true; | 472 m_lockedPendingUserGesture = true; |
| 461 } | 473 } |
| 462 | 474 |
| 463 if (m_shouldDelayLoadEvent) { | 475 if (m_shouldDelayLoadEvent) { |
| 464 document().incrementLoadEventDelayCount(); | 476 document().incrementLoadEventDelayCount(); |
| 465 // Note: Keeping the load event delay count increment on oldDocument that | 477 // Note: Keeping the load event delay count increment on oldDocument that |
| 466 // was added when m_shouldDelayLoadEvent was set so that destruction of | 478 // was added when m_shouldDelayLoadEvent was set so that destruction of |
| 467 // m_webMediaPlayer can not cause load event dispatching in oldDocument. | 479 // m_webMediaPlayer can not cause load event dispatching in oldDocument. |
| 468 } else { | 480 } else { |
| (...skipping 3584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4053 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); | 4065 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); |
| 4054 } | 4066 } |
| 4055 | 4067 |
| 4056 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { | 4068 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { |
| 4057 m_mostlyFillingViewport = true; | 4069 m_mostlyFillingViewport = true; |
| 4058 if (m_webMediaPlayer) | 4070 if (m_webMediaPlayer) |
| 4059 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); | 4071 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); |
| 4060 } | 4072 } |
| 4061 | 4073 |
| 4062 } // namespace blink | 4074 } // namespace blink |
| OLD | NEW |