| Index: third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.cpp
|
| diff --git a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.cpp b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.cpp
|
| index 448fc43425c2810f310f59b399cc401f15187731..279d449a1441f1743f37e14a8edfb5e47c77433d 100644
|
| --- a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.cpp
|
| +++ b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.cpp
|
| @@ -10,6 +10,8 @@
|
| #include "core/html/HTMLMediaElement.h"
|
| #include "modules/media_controls/MediaControlsImpl.h"
|
| #include "modules/media_controls/elements/MediaControlElementsHelper.h"
|
| +#include "modules/remoteplayback/HTMLMediaElementRemotePlayback.h"
|
| +#include "modules/remoteplayback/RemotePlayback.h"
|
| #include "platform/Histogram.h"
|
| #include "public/platform/Platform.h"
|
|
|
| @@ -42,7 +44,7 @@ MediaControlCastButtonElement::MediaControlCastButtonElement(
|
|
|
| if (is_overlay_button_)
|
| RecordMetrics(CastOverlayMetrics::kCreated);
|
| - SetIsPlayingRemotely(false);
|
| + UpdateDisplayType();
|
| }
|
|
|
| void MediaControlCastButtonElement::TryShowOverlay() {
|
| @@ -61,9 +63,8 @@ void MediaControlCastButtonElement::TryShowOverlay() {
|
| }
|
| }
|
|
|
| -void MediaControlCastButtonElement::SetIsPlayingRemotely(
|
| - bool is_playing_remotely) {
|
| - if (is_playing_remotely) {
|
| +void MediaControlCastButtonElement::UpdateDisplayType() {
|
| + if (IsPlayingRemotely()) {
|
| if (is_overlay_button_) {
|
| SetDisplayType(kMediaOverlayCastOnButton);
|
| } else {
|
| @@ -85,7 +86,7 @@ bool MediaControlCastButtonElement::WillRespondToMouseClickEvents() {
|
|
|
| WebLocalizedString::Name
|
| MediaControlCastButtonElement::GetOverflowStringName() {
|
| - if (MediaElement().IsPlayingRemotely())
|
| + if (IsPlayingRemotely())
|
| return WebLocalizedString::kOverflowMenuStopCast;
|
| return WebLocalizedString::kOverflowMenuCast;
|
| }
|
| @@ -108,11 +109,10 @@ void MediaControlCastButtonElement::DefaultEventHandler(Event* event) {
|
| click_use_counted_ = true;
|
| RecordMetrics(CastOverlayMetrics::kClicked);
|
| }
|
| - if (MediaElement().IsPlayingRemotely()) {
|
| - MediaElement().RequestRemotePlaybackControl();
|
| - } else {
|
| - MediaElement().RequestRemotePlayback();
|
| - }
|
| + RemotePlayback* remote =
|
| + HTMLMediaElementRemotePlayback::remote(MediaElement());
|
| + if (remote)
|
| + remote->PromptInternal();
|
| }
|
| MediaControlInputElement::DefaultEventHandler(event);
|
| }
|
| @@ -129,4 +129,10 @@ void MediaControlCastButtonElement::RecordMetrics(CastOverlayMetrics metric) {
|
| overlay_histogram.Count(static_cast<int>(metric));
|
| }
|
|
|
| +bool MediaControlCastButtonElement::IsPlayingRemotely() const {
|
| + RemotePlayback* remote =
|
| + HTMLMediaElementRemotePlayback::remote(MediaElement());
|
| + return remote && remote->GetState() != WebRemotePlaybackState::kDisconnected;
|
| +}
|
| +
|
| } // namespace blink
|
|
|