OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MediaControlCastButtonElement_h | 5 #ifndef MediaControlCastButtonElement_h |
6 #define MediaControlCastButtonElement_h | 6 #define MediaControlCastButtonElement_h |
7 | 7 |
| 8 #include "core/events/EventListener.h" |
8 #include "core/html/shadow/MediaControlElementTypes.h" | 9 #include "core/html/shadow/MediaControlElementTypes.h" |
| 10 #include "modules/remoteplayback/RemotePlayback.h" |
9 | 11 |
10 namespace blink { | 12 namespace blink { |
11 | 13 |
12 class Event; | 14 class Event; |
13 class MediaControlsImpl; | 15 class MediaControlsImpl; |
14 | 16 |
15 class MediaControlCastButtonElement final : public MediaControlInputElement { | 17 class MediaControlCastButtonElement final : public MediaControlInputElement { |
16 public: | 18 public: |
17 MediaControlCastButtonElement(MediaControlsImpl&, bool is_overlay_button); | 19 MediaControlCastButtonElement(MediaControlsImpl&, bool is_overlay_button); |
18 | 20 |
19 // This will show a cast button if it is not covered by another element. | 21 // If set to true, will show the button as long as the media element can be |
20 // This MUST be called for cast button elements that are overlay elements. | 22 // played remotely (and the button is not covered by another element, if it's |
21 void TryShowOverlay(); | 23 // an overlay). Will hide the button and stop watching for remote playback |
22 | 24 // availability if set to false. |
23 void SetIsPlayingRemotely(bool); | 25 void SetIsWanted(bool) override; |
24 | 26 |
25 // MediaControlInputElement overrides. | 27 // MediaControlInputElement overrides. |
26 bool WillRespondToMouseClickEvents() override; | 28 bool WillRespondToMouseClickEvents() override; |
27 WebLocalizedString::Name GetOverflowStringName() override; | 29 WebLocalizedString::Name GetOverflowStringName() override; |
28 bool HasOverflowButton() override; | 30 bool HasOverflowButton() override; |
29 | 31 |
| 32 DECLARE_VIRTUAL_TRACE(); |
| 33 |
30 private: | 34 private: |
| 35 friend class MediaControlsImpl; |
| 36 |
31 // This is used for UMA histogram (Cast.Sender.Overlay). New values should | 37 // This is used for UMA histogram (Cast.Sender.Overlay). New values should |
32 // be appended only and must be added before |Count|. | 38 // be appended only and must be added before |Count|. |
33 enum class CastOverlayMetrics { | 39 enum class CastOverlayMetrics { |
34 kCreated = 0, | 40 kCreated = 0, |
35 kShown, | 41 kShown, |
36 kClicked, | 42 kClicked, |
37 kCount // Keep last. | 43 kCount // Keep last. |
38 }; | 44 }; |
39 | 45 |
40 void DefaultEventHandler(Event*) override; | 46 void DefaultEventHandler(Event*) override; |
41 bool KeepEventInNode(Event*) override; | 47 bool KeepEventInNode(Event*) override; |
42 | 48 |
| 49 // Whether the media element is being played remotely at the moment. |
| 50 bool IsPlayingRemotely() const; |
| 51 |
| 52 // Returns the element currently layed out under the center of the button. |
| 53 Element* UnderlyingElement(); |
| 54 |
| 55 // Updates the way the button is displayed (connected or not, overlay or not). |
| 56 void UpdateDisplayType(); |
| 57 |
| 58 // Returns true if the button can be shown at the moment it's called. |
| 59 // Not const for implementation reasons. |
| 60 bool ShouldShow(); |
| 61 |
43 void RecordMetrics(CastOverlayMetrics); | 62 void RecordMetrics(CastOverlayMetrics); |
44 | 63 |
45 bool is_overlay_button_; | 64 bool is_overlay_button_; |
46 | 65 |
| 66 // Keeps track of whether the button needs to be shown from the |
| 67 // MediaControlsImpl perspective. |
| 68 bool is_wanted_by_controls_ = false; |
| 69 |
47 // UMA related boolean. They are used to prevent counting something twice | 70 // UMA related boolean. They are used to prevent counting something twice |
48 // for the same media element. | 71 // for the same media element. |
49 bool click_use_counted_ = false; | 72 bool click_use_counted_ = false; |
50 bool show_use_counted_ = false; | 73 bool show_use_counted_ = false; |
| 74 |
| 75 Member<RemotePlayback> remote_playback_; |
51 }; | 76 }; |
52 | 77 |
53 } // namespace blink | 78 } // namespace blink |
54 | 79 |
55 #endif // MediaControlCastButtonElement_h | 80 #endif // MediaControlCastButtonElement_h |
OLD | NEW |