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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp

Issue 2737413003: [Presentation API] Remove references to presentation sessions. (Closed)
Patch Set: Update PresentationServiceDelegateImpl unittest Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/presentation/PresentationRequest.h" 5 #include "modules/presentation/PresentationRequest.h"
6 6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 WebPresentationClient* client = presentationClient(getExecutionContext()); 146 WebPresentationClient* client = presentationClient(getExecutionContext());
147 if (!client) 147 if (!client)
148 return ScriptPromise::rejectWithDOMException( 148 return ScriptPromise::rejectWithDOMException(
149 scriptState, 149 scriptState,
150 DOMException::create( 150 DOMException::create(
151 InvalidStateError, 151 InvalidStateError,
152 "The PresentationRequest is no longer associated to a frame.")); 152 "The PresentationRequest is no longer associated to a frame."));
153 153
154 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 154 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
155 client->startSession( 155 client->startPresentation(
156 m_urls, WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this)); 156 m_urls, WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
157 return resolver->promise(); 157 return resolver->promise();
158 } 158 }
159 159
160 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, 160 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState,
161 const String& id) { 161 const String& id) {
162 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) 162 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
163 return rejectWithSandBoxException(scriptState); 163 return rejectWithSandBoxException(scriptState);
164 164
165 WebPresentationClient* client = presentationClient(getExecutionContext()); 165 WebPresentationClient* client = presentationClient(getExecutionContext());
166 if (!client) 166 if (!client)
167 return ScriptPromise::rejectWithDOMException( 167 return ScriptPromise::rejectWithDOMException(
168 scriptState, 168 scriptState,
169 DOMException::create( 169 DOMException::create(
170 InvalidStateError, 170 InvalidStateError,
171 "The PresentationRequest is no longer associated to a frame.")); 171 "The PresentationRequest is no longer associated to a frame."));
172 172
173 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 173 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
174 174
175 PresentationController* controller = 175 PresentationController* controller =
176 presentationController(getExecutionContext()); 176 presentationController(getExecutionContext());
177 DCHECK(controller); 177 DCHECK(controller);
178 178
179 PresentationConnection* existingConnection = 179 PresentationConnection* existingConnection =
180 controller->findExistingConnection(m_urls, id); 180 controller->findExistingConnection(m_urls, id);
181 if (existingConnection) { 181 if (existingConnection) {
182 client->joinSession( 182 client->reconnectPresentation(
183 m_urls, id, WTF::makeUnique<ExistingPresentationConnectionCallbacks>( 183 m_urls, id,
184 resolver, existingConnection)); 184 WTF::makeUnique<ExistingPresentationConnectionCallbacks>(
185 resolver, existingConnection));
185 } else { 186 } else {
186 client->joinSession( 187 client->reconnectPresentation(
187 m_urls, id, 188 m_urls, id,
188 WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this)); 189 WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
189 } 190 }
190 return resolver->promise(); 191 return resolver->promise();
191 } 192 }
192 193
193 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) { 194 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) {
194 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) 195 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
195 return rejectWithSandBoxException(scriptState); 196 return rejectWithSandBoxException(scriptState);
196 197
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (executionContext->isSecureContext()) { 237 if (executionContext->isSecureContext()) {
237 UseCounter::count(executionContext, 238 UseCounter::count(executionContext,
238 UseCounter::PresentationRequestSecureOrigin); 239 UseCounter::PresentationRequestSecureOrigin);
239 } else { 240 } else {
240 UseCounter::count(executionContext, 241 UseCounter::count(executionContext,
241 UseCounter::PresentationRequestInsecureOrigin); 242 UseCounter::PresentationRequestInsecureOrigin);
242 } 243 }
243 } 244 }
244 245
245 } // namespace blink 246 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/presentation/PresentationReceiverTest.cpp ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698