| OLD | NEW |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidAccessError, "PresentationRequest::start() requires user gesture."
)); | 98 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidAccessError, "PresentationRequest::start() requires user gesture."
)); |
| 99 | 99 |
| 100 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) | 100 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) |
| 101 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(SecurityError, "The document is sandboxed and lacks the 'allow-presentati
on' flag.")); | 101 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(SecurityError, "The document is sandboxed and lacks the 'allow-presentati
on' flag.")); |
| 102 | 102 |
| 103 WebPresentationClient* client = presentationClient(getExecutionContext()); | 103 WebPresentationClient* client = presentationClient(getExecutionContext()); |
| 104 if (!client) | 104 if (!client) |
| 105 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "The PresentationRequest is no longer associated to a
frame.")); | 105 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "The PresentationRequest is no longer associated to a
frame.")); |
| 106 | 106 |
| 107 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 107 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 108 client->startSession(m_url.getString(), new PresentationConnectionCallbacks(
resolver, this)); | 108 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. |
| 109 WebVector<WebString> presentationUrls(static_cast<size_t>(1)); |
| 110 presentationUrls[0] = m_url.getString(); |
| 111 client->startSession(presentationUrls, new PresentationConnectionCallbacks(r
esolver, this)); |
| 109 return resolver->promise(); | 112 return resolver->promise(); |
| 110 } | 113 } |
| 111 | 114 |
| 112 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, const Str
ing& id) | 115 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, const Str
ing& id) |
| 113 { | 116 { |
| 114 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) | 117 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) |
| 115 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(SecurityError, "The document is sandboxed and lacks the 'allow-presentati
on' flag.")); | 118 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(SecurityError, "The document is sandboxed and lacks the 'allow-presentati
on' flag.")); |
| 116 | 119 |
| 117 WebPresentationClient* client = presentationClient(getExecutionContext()); | 120 WebPresentationClient* client = presentationClient(getExecutionContext()); |
| 118 if (!client) | 121 if (!client) |
| 119 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "The PresentationRequest is no longer associated to a
frame.")); | 122 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "The PresentationRequest is no longer associated to a
frame.")); |
| 120 | 123 |
| 121 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 124 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 122 client->joinSession(m_url.getString(), id, new PresentationConnectionCallbac
ks(resolver, this)); | 125 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. |
| 126 WebVector<WebString> presentationUrls(static_cast<size_t>(1)); |
| 127 presentationUrls[0] = m_url.getString(); |
| 128 client->joinSession(presentationUrls, id, new PresentationConnectionCallback
s(resolver, this)); |
| 123 return resolver->promise(); | 129 return resolver->promise(); |
| 124 } | 130 } |
| 125 | 131 |
| 126 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) | 132 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) |
| 127 { | 133 { |
| 128 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) | 134 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) |
| 129 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(SecurityError, "The document is sandboxed and lacks the 'allow-presentati
on' flag.")); | 135 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(SecurityError, "The document is sandboxed and lacks the 'allow-presentati
on' flag.")); |
| 130 | 136 |
| 131 WebPresentationClient* client = presentationClient(getExecutionContext()); | 137 WebPresentationClient* client = presentationClient(getExecutionContext()); |
| 132 if (!client) | 138 if (!client) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 149 } | 155 } |
| 150 | 156 |
| 151 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) | 157 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) |
| 152 : ActiveScriptWrappable(this) | 158 : ActiveScriptWrappable(this) |
| 153 , ActiveDOMObject(executionContext) | 159 , ActiveDOMObject(executionContext) |
| 154 , m_url(url) | 160 , m_url(url) |
| 155 { | 161 { |
| 156 } | 162 } |
| 157 | 163 |
| 158 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |