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

Side by Side Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp

Issue 2348703002: [Blink, RemotePlayback] Added the disableRemotePlayback check to prompt(). (Closed)
Patch Set: Removed the newline from expected.txt Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/media/remoteplayback/disable-remote-playback-prompt-throws.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "modules/remoteplayback/RemotePlayback.h" 5 #include "modules/remoteplayback/RemotePlayback.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/HTMLNames.h"
8 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
9 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
10 #include "core/events/Event.h" 11 #include "core/events/Event.h"
11 #include "core/html/HTMLMediaElement.h" 12 #include "core/html/HTMLMediaElement.h"
12 #include "modules/EventTargetModules.h" 13 #include "modules/EventTargetModules.h"
13 #include "modules/remoteplayback/RemotePlaybackAvailability.h" 14 #include "modules/remoteplayback/RemotePlaybackAvailability.h"
14 #include "platform/UserGestureIndicator.h" 15 #include "platform/UserGestureIndicator.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // no default controls, we should also start tracking availability on demand 76 // no default controls, we should also start tracking availability on demand
76 // meaning the Promise returned by getAvailability() will be resolved asynch ronously. 77 // meaning the Promise returned by getAvailability() will be resolved asynch ronously.
77 RemotePlaybackAvailability* availability = RemotePlaybackAvailability::take( resolver, m_availability); 78 RemotePlaybackAvailability* availability = RemotePlaybackAvailability::take( resolver, m_availability);
78 m_availabilityObjects.append(availability); 79 m_availabilityObjects.append(availability);
79 resolver->resolve(availability); 80 resolver->resolve(availability);
80 return promise; 81 return promise;
81 } 82 }
82 83
83 ScriptPromise RemotePlayback::prompt(ScriptState* scriptState) 84 ScriptPromise RemotePlayback::prompt(ScriptState* scriptState)
84 { 85 {
85 // TODO(avayvod): implement steps 3, 4, 5, 8, 9 of the algorithm. 86 // TODO(avayvod): implement steps 4, 5, 8, 9 of the algorithm.
86 // https://crbug.com/647441 87 // https://crbug.com/647441
87 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 88 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
88 ScriptPromise promise = resolver->promise(); 89 ScriptPromise promise = resolver->promise();
89 90
91 if (m_mediaElement->fastHasAttribute(HTMLNames::disableremoteplaybackAttr)) {
92 resolver->reject(DOMException::create(InvalidStateError, "disableRemoteP layback attribute is present."));
93 return promise;
94 }
95
90 // TODO(avayvod): should we have a separate flag to disable the user gesture 96 // TODO(avayvod): should we have a separate flag to disable the user gesture
91 // requirement (for tests) or reuse the one for the PresentationRequest::sta rt()? 97 // requirement (for tests) or reuse the one for the PresentationRequest::sta rt()?
92 if (!UserGestureIndicator::utilizeUserGesture()) { 98 if (!UserGestureIndicator::utilizeUserGesture()) {
93 resolver->reject(DOMException::create(InvalidAccessError, "RemotePlaybac k::prompt() requires user gesture.")); 99 resolver->reject(DOMException::create(InvalidAccessError, "RemotePlaybac k::prompt() requires user gesture."));
94 return promise; 100 return promise;
95 } 101 }
96 102
97 if (m_state == WebRemotePlaybackState::Disconnected) { 103 if (m_state == WebRemotePlaybackState::Disconnected) {
98 m_promptPromiseResolvers.append(resolver); 104 m_promptPromiseResolvers.append(resolver);
99 m_mediaElement->requestRemotePlayback(); 105 m_mediaElement->requestRemotePlayback();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 169
164 DEFINE_TRACE(RemotePlayback) 170 DEFINE_TRACE(RemotePlayback)
165 { 171 {
166 visitor->trace(m_availabilityObjects); 172 visitor->trace(m_availabilityObjects);
167 visitor->trace(m_promptPromiseResolvers); 173 visitor->trace(m_promptPromiseResolvers);
168 visitor->trace(m_mediaElement); 174 visitor->trace(m_mediaElement);
169 EventTargetWithInlineData::trace(visitor); 175 EventTargetWithInlineData::trace(visitor);
170 } 176 }
171 177
172 } // namespace blink 178 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/media/remoteplayback/disable-remote-playback-prompt-throws.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698