Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| index be3968b5e56dd5f10eacdd3546f0864afe956048..978cbf2c6ab96f979b5a64067380ba2a99e3d989 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp |
| @@ -444,7 +444,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
| m_shouldPerformAutomaticTrackSelection(true), |
| m_tracksAreReady(true), |
| m_processingPreferenceChange(false), |
| - m_remoteRoutesAvailable(false), |
| m_playingRemotely(false), |
| m_inOverlayFullscreenVideo(false), |
| m_audioTracks(this, AudioTrackList::create(*this)), |
| @@ -475,6 +474,13 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, |
| m_lockedPendingUserGesture = true; |
| } |
| + LocalFrame* frame = document.frame(); |
| + if (frame) { |
| + m_remotePlaybackClient = |
| + frame->loader().client()->createWebRemotePlaybackClient( |
| + *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
|
| + } |
| + |
| setHasCustomStyleCallbacks(); |
| addElementToDocumentMap(this, &document); |
| @@ -3155,12 +3161,19 @@ void HTMLMediaElement::requestSeek(double time) { |
| setCurrentTime(time); |
| } |
| -void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) { |
| - m_remoteRoutesAvailable = routesAvailable; |
| +void HTMLMediaElement::remoteRouteAvailabilityChanged(bool isRouteAvailable, |
| + bool isSourceCompatible) { |
| + if (remotePlaybackClient()) { |
| + remotePlaybackClient()->availabilityChanged(isRouteAvailable, |
| + isSourceCompatible); |
| + } |
| if (mediaControls()) |
| mediaControls()->refreshCastButtonVisibility(); |
| - if (remotePlaybackClient()) |
| - remotePlaybackClient()->availabilityChanged(routesAvailable); |
| +} |
| + |
| +bool HTMLMediaElement::hasRemoteRoutes() const { |
| + return remotePlaybackClient() && |
| + remotePlaybackClient()->remotePlaybackAvailable(); |
| } |
| void HTMLMediaElement::connectedToRemoteDevice() { |
| @@ -3390,10 +3403,8 @@ void HTMLMediaElement::clearMediaPlayer() { |
| m_loadState = WaitingForSource; |
| // We can't cast if we don't have a media player. |
| - m_remoteRoutesAvailable = false; |
| m_playingRemotely = false; |
| - if (mediaControls()) |
| - mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); |
| + remoteRouteAvailabilityChanged(false, false); |
| if (layoutObject()) |
| layoutObject()->setShouldDoFullPaintInvalidation(); |
| @@ -3751,8 +3762,8 @@ void HTMLMediaElement::resetMediaPlayerAndMediaSource() { |
| } |
| // We haven't yet found out if any remote routes are available. |
| - m_remoteRoutesAvailable = false; |
| m_playingRemotely = false; |
| + remoteRouteAvailabilityChanged(false, false); |
| if (m_audioSourceNode) |
| getAudioSourceProvider().setClient(m_audioSourceNode); |
| @@ -3939,11 +3950,6 @@ void HTMLMediaElement::updatePositionNotificationRegistration() { |
| m_autoplayHelper->updatePositionNotificationRegistration(); |
| } |
| -void HTMLMediaElement::setRemotePlaybackClient( |
| - WebRemotePlaybackClient* client) { |
| - m_remotePlaybackClient = client; |
| -} |
| - |
| // TODO(liberato): remove once autoplay gesture override experiment concludes. |
| void HTMLMediaElement::triggerAutoplayViewportCheckForTesting() { |
| if (FrameView* view = document().view()) |