OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 RemotePlayback_h | 5 #ifndef RemotePlayback_h |
6 #define RemotePlayback_h | 6 #define RemotePlayback_h |
7 | 7 |
8 #include "bindings/core/v8/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/TraceWrapperMember.h" | 10 #include "bindings/core/v8/TraceWrapperMember.h" |
11 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
12 #include "core/events/EventTarget.h" | 12 #include "core/events/EventTarget.h" |
13 #include "modules/ModulesExport.h" | 13 #include "modules/ModulesExport.h" |
14 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
15 #include "platform/wtf/Compiler.h" | 15 #include "platform/wtf/Compiler.h" |
16 #include "platform/wtf/text/AtomicString.h" | 16 #include "platform/wtf/text/AtomicString.h" |
17 #include "platform/wtf/text/WTFString.h" | 17 #include "platform/wtf/text/WTFString.h" |
18 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h
" | 18 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h
" |
19 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" | 19 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" |
20 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" | 20 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" |
21 | 21 |
22 namespace blink { | 22 namespace blink { |
23 | 23 |
| 24 class AvailabilityCallbackWrapper; |
24 class HTMLMediaElement; | 25 class HTMLMediaElement; |
25 class RemotePlaybackAvailabilityCallback; | 26 class RemotePlaybackAvailabilityCallback; |
26 class ScriptPromiseResolver; | 27 class ScriptPromiseResolver; |
27 class ScriptState; | 28 class ScriptState; |
28 | 29 |
29 class MODULES_EXPORT RemotePlayback final | 30 class MODULES_EXPORT RemotePlayback final |
30 : public EventTargetWithInlineData, | 31 : public EventTargetWithInlineData, |
31 public ActiveScriptWrappable<RemotePlayback>, | 32 public ActiveScriptWrappable<RemotePlayback>, |
32 NON_EXPORTED_BASE(public WebRemotePlaybackClient) { | 33 NON_EXPORTED_BASE(public WebRemotePlaybackClient) { |
33 DEFINE_WRAPPERTYPEINFO(); | 34 DEFINE_WRAPPERTYPEINFO(); |
(...skipping 22 matching lines...) Expand all Loading... |
56 // Cancels all the callbacks watching remote playback availability changes | 57 // Cancels all the callbacks watching remote playback availability changes |
57 // registered with this element. | 58 // registered with this element. |
58 ScriptPromise cancelWatchAvailability(ScriptState*); | 59 ScriptPromise cancelWatchAvailability(ScriptState*); |
59 | 60 |
60 // Shows the UI allowing user to change the remote playback state of the media | 61 // Shows the UI allowing user to change the remote playback state of the media |
61 // element (by picking a remote playback device from the list, for example). | 62 // element (by picking a remote playback device from the list, for example). |
62 ScriptPromise prompt(ScriptState*); | 63 ScriptPromise prompt(ScriptState*); |
63 | 64 |
64 String state() const; | 65 String state() const; |
65 | 66 |
| 67 // The implementation of prompt(). Used by the native remote playback button. |
| 68 void PromptInternal(); |
| 69 |
| 70 // The implementation of watchAvailability() and cancelWatchAvailability(). |
| 71 int WatchAvailabilityInternal(AvailabilityCallbackWrapper*); |
| 72 bool CancelWatchAvailabilityInternal(int id); |
| 73 |
| 74 WebRemotePlaybackState GetState() const { return state_; } |
| 75 |
| 76 // WebRemotePlaybackClient implementation. |
| 77 void StateChanged(WebRemotePlaybackState) override; |
| 78 void AvailabilityChanged(WebRemotePlaybackAvailability) override; |
| 79 void PromptCancelled() override; |
| 80 bool RemotePlaybackAvailable() const override; |
| 81 |
66 // ScriptWrappable implementation. | 82 // ScriptWrappable implementation. |
67 bool HasPendingActivity() const final; | 83 bool HasPendingActivity() const final; |
68 | 84 |
69 DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting); | 85 DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting); |
70 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 86 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
71 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 87 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
72 | 88 |
73 DECLARE_VIRTUAL_TRACE(); | 89 DECLARE_VIRTUAL_TRACE(); |
74 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 90 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
75 | 91 |
76 private: | 92 private: |
77 friend class V8RemotePlayback; | 93 friend class V8RemotePlayback; |
78 friend class RemotePlaybackTest; | 94 friend class RemotePlaybackTest; |
| 95 friend class MediaControlsImplTest; |
79 | 96 |
80 explicit RemotePlayback(HTMLMediaElement&); | 97 explicit RemotePlayback(HTMLMediaElement&); |
81 | 98 |
82 // Calls the specified availability callback with the current availability. | 99 // Calls the specified availability callback with the current availability. |
83 // Need a void() method to post it as a task. | 100 // Need a void() method to post it as a task. |
84 void NotifyInitialAvailability(int callback_id); | 101 void NotifyInitialAvailability(int callback_id); |
85 | 102 |
86 // WebRemotePlaybackClient implementation. | |
87 void StateChanged(WebRemotePlaybackState) override; | |
88 void AvailabilityChanged(WebRemotePlaybackAvailability) override; | |
89 void PromptCancelled() override; | |
90 bool RemotePlaybackAvailable() const override; | |
91 | |
92 WebRemotePlaybackState state_; | 103 WebRemotePlaybackState state_; |
93 WebRemotePlaybackAvailability availability_; | 104 WebRemotePlaybackAvailability availability_; |
94 HeapHashMap<int, TraceWrapperMember<RemotePlaybackAvailabilityCallback>> | 105 HeapHashMap<int, TraceWrapperMember<AvailabilityCallbackWrapper>> |
95 availability_callbacks_; | 106 availability_callbacks_; |
96 Member<HTMLMediaElement> media_element_; | 107 Member<HTMLMediaElement> media_element_; |
97 Member<ScriptPromiseResolver> prompt_promise_resolver_; | 108 Member<ScriptPromiseResolver> prompt_promise_resolver_; |
98 }; | 109 }; |
99 | 110 |
100 } // namespace blink | 111 } // namespace blink |
101 | 112 |
102 #endif // RemotePlayback_h | 113 #endif // RemotePlayback_h |
OLD | NEW |