Index: third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.h |
diff --git a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.h b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.h |
index c640a8e01091c018eb116d0ac4552c3963fbad6b..902785732efb00f6b92f9eab2d97f76f059c31d6 100644 |
--- a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.h |
+++ b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlCastButtonElement.h |
@@ -5,7 +5,9 @@ |
#ifndef MediaControlCastButtonElement_h |
#define MediaControlCastButtonElement_h |
+#include "core/events/EventListener.h" |
#include "core/html/shadow/MediaControlElementTypes.h" |
+#include "modules/remoteplayback/RemotePlayback.h" |
namespace blink { |
@@ -16,18 +18,22 @@ class MediaControlCastButtonElement final : public MediaControlInputElement { |
public: |
MediaControlCastButtonElement(MediaControlsImpl&, bool is_overlay_button); |
- // This will show a cast button if it is not covered by another element. |
- // This MUST be called for cast button elements that are overlay elements. |
- void TryShowOverlay(); |
- |
- void SetIsPlayingRemotely(bool); |
+ // If set to true, will show the button as long as the media element can be |
+ // played remotely (and the button is not covered by another element, if it's |
+ // an overlay). Will hide the button and stop watching for remote playback |
+ // availability if set to false. |
+ void SetIsWanted(bool) override; |
// MediaControlInputElement overrides. |
bool WillRespondToMouseClickEvents() override; |
WebLocalizedString::Name GetOverflowStringName() override; |
bool HasOverflowButton() override; |
+ DECLARE_VIRTUAL_TRACE(); |
+ |
private: |
+ friend class MediaControlsImpl; |
+ |
// This is used for UMA histogram (Cast.Sender.Overlay). New values should |
// be appended only and must be added before |Count|. |
enum class CastOverlayMetrics { |
@@ -40,14 +46,33 @@ class MediaControlCastButtonElement final : public MediaControlInputElement { |
void DefaultEventHandler(Event*) override; |
bool KeepEventInNode(Event*) override; |
+ // Whether the media element is being played remotely at the moment. |
+ bool IsPlayingRemotely() const; |
+ |
+ // Returns the element currently layed out under the center of the button. |
+ Element* UnderlyingElement(); |
+ |
+ // Updates the way the button is displayed (connected or not, overlay or not). |
+ void UpdateDisplayType(); |
+ |
+ // Returns true if the button can be shown at the moment it's called. |
+ // Not const for implementation reasons. |
+ bool ShouldShow(); |
+ |
void RecordMetrics(CastOverlayMetrics); |
bool is_overlay_button_; |
+ // Keeps track of whether the button needs to be shown from the |
+ // MediaControlsImpl perspective. |
+ bool is_wanted_by_controls_ = false; |
+ |
// UMA related boolean. They are used to prevent counting something twice |
// for the same media element. |
bool click_use_counted_ = false; |
bool show_use_counted_ = false; |
+ |
+ Member<RemotePlayback> remote_playback_; |
}; |
} // namespace blink |