Chromium Code Reviews| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 m_autoplaying(true), | 437 m_autoplaying(true), |
| 438 m_muted(false), | 438 m_muted(false), |
| 439 m_paused(true), | 439 m_paused(true), |
| 440 m_seeking(false), | 440 m_seeking(false), |
| 441 m_sentStalledEvent(false), | 441 m_sentStalledEvent(false), |
| 442 m_ignorePreloadNone(false), | 442 m_ignorePreloadNone(false), |
| 443 m_textTracksVisible(false), | 443 m_textTracksVisible(false), |
| 444 m_shouldPerformAutomaticTrackSelection(true), | 444 m_shouldPerformAutomaticTrackSelection(true), |
| 445 m_tracksAreReady(true), | 445 m_tracksAreReady(true), |
| 446 m_processingPreferenceChange(false), | 446 m_processingPreferenceChange(false), |
| 447 m_remoteRoutesAvailable(false), | |
| 448 m_playingRemotely(false), | 447 m_playingRemotely(false), |
| 449 m_inOverlayFullscreenVideo(false), | 448 m_inOverlayFullscreenVideo(false), |
| 450 m_audioTracks(this, AudioTrackList::create(*this)), | 449 m_audioTracks(this, AudioTrackList::create(*this)), |
| 451 m_videoTracks(this, VideoTrackList::create(*this)), | 450 m_videoTracks(this, VideoTrackList::create(*this)), |
| 452 m_textTracks(this, nullptr), | 451 m_textTracks(this, nullptr), |
| 453 m_playPromiseResolveTask(CancellableTaskFactory::create( | 452 m_playPromiseResolveTask(CancellableTaskFactory::create( |
| 454 this, | 453 this, |
| 455 &HTMLMediaElement::resolveScheduledPlayPromises)), | 454 &HTMLMediaElement::resolveScheduledPlayPromises)), |
| 456 m_playPromiseRejectTask(CancellableTaskFactory::create( | 455 m_playPromiseRejectTask(CancellableTaskFactory::create( |
| 457 this, | 456 this, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 468 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; | 467 BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")"; |
| 469 | 468 |
| 470 // If any experiment is enabled, then we want to enable a user gesture by | 469 // If any experiment is enabled, then we want to enable a user gesture by |
| 471 // default, otherwise the experiment does nothing. | 470 // default, otherwise the experiment does nothing. |
| 472 if ((document.settings() && | 471 if ((document.settings() && |
| 473 document.settings()->mediaPlaybackRequiresUserGesture()) || | 472 document.settings()->mediaPlaybackRequiresUserGesture()) || |
| 474 m_autoplayHelper->isExperimentEnabled()) { | 473 m_autoplayHelper->isExperimentEnabled()) { |
| 475 m_lockedPendingUserGesture = true; | 474 m_lockedPendingUserGesture = true; |
| 476 } | 475 } |
| 477 | 476 |
| 477 LocalFrame* frame = document.frame(); | |
| 478 if (frame) { | |
| 479 m_remotePlaybackClient = | |
| 480 frame->loader().client()->createWebRemotePlaybackClient( | |
| 481 *this, ScriptState::forMainWorld(frame)); | |
|
haraken
2016/11/08 05:13:11
Is it not possible that this code runs on an isola
whywhat
2016/11/08 17:55:17
I don't think we plan to enable this for extension
| |
| 482 } | |
| 483 | |
| 478 setHasCustomStyleCallbacks(); | 484 setHasCustomStyleCallbacks(); |
| 479 addElementToDocumentMap(this, &document); | 485 addElementToDocumentMap(this, &document); |
| 480 | 486 |
| 481 UseCounter::count(document, UseCounter::HTMLMediaElement); | 487 UseCounter::count(document, UseCounter::HTMLMediaElement); |
| 482 } | 488 } |
| 483 | 489 |
| 484 HTMLMediaElement::~HTMLMediaElement() { | 490 HTMLMediaElement::~HTMLMediaElement() { |
| 485 BLINK_MEDIA_LOG << "~HTMLMediaElement(" << (void*)this << ")"; | 491 BLINK_MEDIA_LOG << "~HTMLMediaElement(" << (void*)this << ")"; |
| 486 | 492 |
| 487 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). | 493 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). |
| (...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3148 pauseInternal(); | 3154 pauseInternal(); |
| 3149 else | 3155 else |
| 3150 playInternal(); | 3156 playInternal(); |
| 3151 } | 3157 } |
| 3152 | 3158 |
| 3153 void HTMLMediaElement::requestSeek(double time) { | 3159 void HTMLMediaElement::requestSeek(double time) { |
| 3154 // The player is the source of this seek request. | 3160 // The player is the source of this seek request. |
| 3155 setCurrentTime(time); | 3161 setCurrentTime(time); |
| 3156 } | 3162 } |
| 3157 | 3163 |
| 3158 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) { | 3164 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool isRouteAvailable, |
| 3159 m_remoteRoutesAvailable = routesAvailable; | 3165 bool isSourceCompatible) { |
| 3166 if (remotePlaybackClient()) { | |
| 3167 remotePlaybackClient()->availabilityChanged(isRouteAvailable, | |
| 3168 isSourceCompatible); | |
| 3169 } | |
| 3160 if (mediaControls()) | 3170 if (mediaControls()) |
| 3161 mediaControls()->refreshCastButtonVisibility(); | 3171 mediaControls()->refreshCastButtonVisibility(); |
| 3162 if (remotePlaybackClient()) | 3172 } |
| 3163 remotePlaybackClient()->availabilityChanged(routesAvailable); | 3173 |
| 3174 bool HTMLMediaElement::hasRemoteRoutes() const { | |
| 3175 return remotePlaybackClient() && | |
| 3176 remotePlaybackClient()->remotePlaybackAvailable(); | |
| 3164 } | 3177 } |
| 3165 | 3178 |
| 3166 void HTMLMediaElement::connectedToRemoteDevice() { | 3179 void HTMLMediaElement::connectedToRemoteDevice() { |
| 3167 m_playingRemotely = true; | 3180 m_playingRemotely = true; |
| 3168 if (mediaControls()) | 3181 if (mediaControls()) |
| 3169 mediaControls()->startedCasting(); | 3182 mediaControls()->startedCasting(); |
| 3170 if (remotePlaybackClient()) | 3183 if (remotePlaybackClient()) |
| 3171 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connecting); | 3184 remotePlaybackClient()->stateChanged(WebRemotePlaybackState::Connecting); |
| 3172 } | 3185 } |
| 3173 | 3186 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3383 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3396 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 3384 } | 3397 } |
| 3385 | 3398 |
| 3386 stopPeriodicTimers(); | 3399 stopPeriodicTimers(); |
| 3387 m_loadTimer.stop(); | 3400 m_loadTimer.stop(); |
| 3388 | 3401 |
| 3389 m_pendingActionFlags = 0; | 3402 m_pendingActionFlags = 0; |
| 3390 m_loadState = WaitingForSource; | 3403 m_loadState = WaitingForSource; |
| 3391 | 3404 |
| 3392 // We can't cast if we don't have a media player. | 3405 // We can't cast if we don't have a media player. |
| 3393 m_remoteRoutesAvailable = false; | |
| 3394 m_playingRemotely = false; | 3406 m_playingRemotely = false; |
| 3395 if (mediaControls()) | 3407 remoteRouteAvailabilityChanged(false, false); |
| 3396 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); | |
| 3397 | 3408 |
| 3398 if (layoutObject()) | 3409 if (layoutObject()) |
| 3399 layoutObject()->setShouldDoFullPaintInvalidation(); | 3410 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 3400 } | 3411 } |
| 3401 | 3412 |
| 3402 void HTMLMediaElement::contextDestroyed() { | 3413 void HTMLMediaElement::contextDestroyed() { |
| 3403 BLINK_MEDIA_LOG << "contextDestroyed(" << (void*)this << ")"; | 3414 BLINK_MEDIA_LOG << "contextDestroyed(" << (void*)this << ")"; |
| 3404 | 3415 |
| 3405 // Close the async event queue so that no events are enqueued. | 3416 // Close the async event queue so that no events are enqueued. |
| 3406 cancelPendingEventsAndCallbacks(); | 3417 cancelPendingEventsAndCallbacks(); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3744 // TODO(srirama.m): Merge it to resetMediaElement if possible and remove it. | 3755 // TODO(srirama.m): Merge it to resetMediaElement if possible and remove it. |
| 3745 void HTMLMediaElement::resetMediaPlayerAndMediaSource() { | 3756 void HTMLMediaElement::resetMediaPlayerAndMediaSource() { |
| 3746 closeMediaSource(); | 3757 closeMediaSource(); |
| 3747 | 3758 |
| 3748 { | 3759 { |
| 3749 AudioSourceProviderClientLockScope scope(*this); | 3760 AudioSourceProviderClientLockScope scope(*this); |
| 3750 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3761 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 3751 } | 3762 } |
| 3752 | 3763 |
| 3753 // We haven't yet found out if any remote routes are available. | 3764 // We haven't yet found out if any remote routes are available. |
| 3754 m_remoteRoutesAvailable = false; | |
| 3755 m_playingRemotely = false; | 3765 m_playingRemotely = false; |
| 3766 remoteRouteAvailabilityChanged(false, false); | |
| 3756 | 3767 |
| 3757 if (m_audioSourceNode) | 3768 if (m_audioSourceNode) |
| 3758 getAudioSourceProvider().setClient(m_audioSourceNode); | 3769 getAudioSourceProvider().setClient(m_audioSourceNode); |
| 3759 } | 3770 } |
| 3760 | 3771 |
| 3761 void HTMLMediaElement::setAudioSourceNode( | 3772 void HTMLMediaElement::setAudioSourceNode( |
| 3762 AudioSourceProviderClient* sourceNode) { | 3773 AudioSourceProviderClient* sourceNode) { |
| 3763 DCHECK(isMainThread()); | 3774 DCHECK(isMainThread()); |
| 3764 m_audioSourceNode = sourceNode; | 3775 m_audioSourceNode = sourceNode; |
| 3765 | 3776 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3932 | 3943 |
| 3933 void HTMLMediaElement::notifyPositionMayHaveChanged( | 3944 void HTMLMediaElement::notifyPositionMayHaveChanged( |
| 3934 const IntRect& visibleRect) { | 3945 const IntRect& visibleRect) { |
| 3935 m_autoplayHelper->positionChanged(visibleRect); | 3946 m_autoplayHelper->positionChanged(visibleRect); |
| 3936 } | 3947 } |
| 3937 | 3948 |
| 3938 void HTMLMediaElement::updatePositionNotificationRegistration() { | 3949 void HTMLMediaElement::updatePositionNotificationRegistration() { |
| 3939 m_autoplayHelper->updatePositionNotificationRegistration(); | 3950 m_autoplayHelper->updatePositionNotificationRegistration(); |
| 3940 } | 3951 } |
| 3941 | 3952 |
| 3942 void HTMLMediaElement::setRemotePlaybackClient( | |
| 3943 WebRemotePlaybackClient* client) { | |
| 3944 m_remotePlaybackClient = client; | |
| 3945 } | |
| 3946 | |
| 3947 // TODO(liberato): remove once autoplay gesture override experiment concludes. | 3953 // TODO(liberato): remove once autoplay gesture override experiment concludes. |
| 3948 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() { | 3954 void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() { |
| 3949 if (FrameView* view = document().view()) | 3955 if (FrameView* view = document().view()) |
| 3950 m_autoplayHelper->positionChanged( | 3956 m_autoplayHelper->positionChanged( |
| 3951 view->rootFrameToContents(view->computeVisibleArea())); | 3957 view->rootFrameToContents(view->computeVisibleArea())); |
| 3952 m_autoplayHelper->triggerAutoplayViewportCheckForTesting(); | 3958 m_autoplayHelper->triggerAutoplayViewportCheckForTesting(); |
| 3953 } | 3959 } |
| 3954 | 3960 |
| 3955 void HTMLMediaElement::scheduleResolvePlayPromises() { | 3961 void HTMLMediaElement::scheduleResolvePlayPromises() { |
| 3956 // TODO(mlamouri): per spec, we should create a new task but we can't create | 3962 // TODO(mlamouri): per spec, we should create a new task but we can't create |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4178 | 4184 |
| 4179 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() | 4185 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() |
| 4180 const { | 4186 const { |
| 4181 IntRect result; | 4187 IntRect result; |
| 4182 if (LayoutObject* object = m_element->layoutObject()) | 4188 if (LayoutObject* object = m_element->layoutObject()) |
| 4183 result = object->absoluteBoundingBoxRect(); | 4189 result = object->absoluteBoundingBoxRect(); |
| 4184 return result; | 4190 return result; |
| 4185 } | 4191 } |
| 4186 | 4192 |
| 4187 } // namespace blink | 4193 } // namespace blink |
| OLD | NEW |