Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Unified Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp

Issue 2782373002: Remove MediaControls methods needed for the Cast button (Closed)
Patch Set: Fixed more tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
diff --git a/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp b/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
index b31c8faab967c0c281f1f35b1a003a6e333a1bea..19fc1ccf5ebb531ed845582d21db0da5f1828722 100644
--- a/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
+++ b/third_party/WebKit/Source/modules/media_controls/MediaControlsImpl.cpp
@@ -112,28 +112,6 @@ bool ShouldShowFullscreenButton(const HTMLMediaElement& media_element) {
return true;
}
-bool ShouldShowCastButton(HTMLMediaElement& media_element) {
- if (media_element.FastHasAttribute(HTMLNames::disableremoteplaybackAttr))
- return false;
-
- // Explicitly do not show cast button when the mediaControlsEnabled setting is
- // false to make sure the overlay does not appear.
- Document& document = media_element.GetDocument();
- if (document.GetSettings() &&
- !document.GetSettings()->GetMediaControlsEnabled())
- return false;
-
- // The page disabled the button via the attribute.
- if (media_element.ControlsListInternal()->ShouldHideRemotePlayback()) {
- UseCounter::Count(
- media_element.GetDocument(),
- UseCounter::kHTMLMediaElementControlsListNoRemotePlayback);
- return false;
- }
-
- return media_element.HasRemoteRoutes();
-}
-
bool PreferHiddenVolumeControls(const Document& document) {
return !document.GetSettings() ||
document.GetSettings()->GetPreferHiddenVolumeControls();
@@ -494,6 +472,7 @@ void MediaControlsImpl::Show() {
panel_->SetIsDisplayed(true);
if (overlay_play_button_)
overlay_play_button_->UpdateDisplayType();
+ RefreshCastButtonVisibility();
}
void MediaControlsImpl::Hide() {
@@ -630,43 +609,25 @@ void MediaControlsImpl::RefreshCastButtonVisibility() {
}
void MediaControlsImpl::RefreshCastButtonVisibilityWithoutUpdate() {
- if (!ShouldShowCastButton(MediaElement())) {
- cast_button_->SetIsWanted(false);
- overlay_cast_button_->SetIsWanted(false);
- return;
- }
-
- // The reason for the autoplay test is that some pages (e.g. vimeo.com) have
- // an autoplay background video, which doesn't autoplay on Chrome for Android
- // (we prevent it) so starts paused. In such cases we don't want to
- // automatically show the cast button, since it looks strange and is unlikely
- // to correspond with anything the user wants to do. If a user does want to
- // cast a paused autoplay video then they can still do so by touching or
- // clicking on the video, which will cause the cast button to appear.
- if (!MediaElement().ShouldShowControls() && !MediaElement().Autoplay() &&
- MediaElement().paused()) {
- // Note that this is a case where we add the overlay cast button
- // without wanting the panel cast button. We depend on the fact
- // that computeWhichControlsFit() won't change overlay cast button
- // visibility in the case where the cast button isn't wanted.
- // We don't call compute...() here, but it will be called as
- // non-cast changes (e.g., resize) occur. If the panel button
- // is shown, however, compute...() will take control of the
- // overlay cast button if it needs to hide it from the panel.
- overlay_cast_button_->TryShowOverlay();
- cast_button_->SetIsWanted(false);
- } else if (MediaElement().ShouldShowControls()) {
- overlay_cast_button_->SetIsWanted(false);
- cast_button_->SetIsWanted(true);
+ MediaControlCastButtonElement* try_show_button = cast_button_.Get();
+ MediaControlCastButtonElement* hide_button = overlay_cast_button_.Get();
+ if (!MediaElement().ShouldShowControls()) {
+ try_show_button = overlay_cast_button_.Get();
+ hide_button = cast_button_.Get();
}
+ hide_button->SetIsWanted(false);
+ try_show_button->SetIsWanted(try_show_button->ShouldShow());
+ if (try_show_button->IsWanted())
+ try_show_button->UpdateDisplayType();
}
void MediaControlsImpl::ShowOverlayCastButtonIfNeeded() {
if (MediaElement().ShouldShowControls() ||
- !ShouldShowCastButton(MediaElement()))
+ !overlay_cast_button_->ShouldShow()) {
return;
+ }
- overlay_cast_button_->TryShowOverlay();
+ overlay_cast_button_->SetIsWanted(true);
ResetHideMediaControlsTimer();
}
@@ -678,16 +639,6 @@ void MediaControlsImpl::ExitFullscreen() {
Fullscreen::ExitFullscreen(GetDocument());
}
-void MediaControlsImpl::StartedCasting() {
- cast_button_->SetIsPlayingRemotely(true);
- overlay_cast_button_->SetIsPlayingRemotely(true);
-}
-
-void MediaControlsImpl::StoppedCasting() {
- cast_button_->SetIsPlayingRemotely(false);
- overlay_cast_button_->SetIsPlayingRemotely(false);
-}
-
void MediaControlsImpl::DefaultEventHandler(Event* event) {
HTMLDivElement::DefaultEventHandler(event);

Powered by Google App Engine
This is Rietveld 408576698