| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { | 105 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { |
| 106 resolver->reject(DOMException::create(SecurityError, "The document is sa
ndboxed and lacks the 'allow-presentation' flag.")); | 106 resolver->reject(DOMException::create(SecurityError, "The document is sa
ndboxed and lacks the 'allow-presentation' flag.")); |
| 107 return promise; | 107 return promise; |
| 108 } | 108 } |
| 109 | 109 |
| 110 WebPresentationClient* client = presentationClient(getExecutionContext()); | 110 WebPresentationClient* client = presentationClient(getExecutionContext()); |
| 111 if (!client) { | 111 if (!client) { |
| 112 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); | 112 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); |
| 113 return promise; | 113 return promise; |
| 114 } | 114 } |
| 115 client->startSession(m_url.getString(), new PresentationConnectionCallbacks(
resolver, this)); | 115 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. |
| 116 WebVector<WebString> presentationUrls(static_cast<size_t>(1)); |
| 117 presentationUrls[0] = m_url.getString(); |
| 118 client->startSession(presentationUrls, new PresentationConnectionCallbacks(r
esolver, this)); |
| 116 return promise; | 119 return promise; |
| 117 } | 120 } |
| 118 | 121 |
| 119 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, const Str
ing& id) | 122 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, const Str
ing& id) |
| 120 { | 123 { |
| 121 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 124 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 122 ScriptPromise promise = resolver->promise(); | 125 ScriptPromise promise = resolver->promise(); |
| 123 | 126 |
| 124 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { | 127 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { |
| 125 resolver->reject(DOMException::create(SecurityError, "The document is sa
ndboxed and lacks the 'allow-presentation' flag.")); | 128 resolver->reject(DOMException::create(SecurityError, "The document is sa
ndboxed and lacks the 'allow-presentation' flag.")); |
| 126 return promise; | 129 return promise; |
| 127 } | 130 } |
| 128 | 131 |
| 129 WebPresentationClient* client = presentationClient(getExecutionContext()); | 132 WebPresentationClient* client = presentationClient(getExecutionContext()); |
| 130 if (!client) { | 133 if (!client) { |
| 131 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); | 134 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); |
| 132 return promise; | 135 return promise; |
| 133 } | 136 } |
| 134 client->joinSession(m_url.getString(), id, new PresentationConnectionCallbac
ks(resolver, this)); | 137 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. |
| 138 WebVector<WebString> presentationUrls(static_cast<size_t>(1)); |
| 139 presentationUrls[0] = m_url.getString(); |
| 140 client->joinSession(presentationUrls, id, new PresentationConnectionCallback
s(resolver, this)); |
| 135 return promise; | 141 return promise; |
| 136 } | 142 } |
| 137 | 143 |
| 138 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) | 144 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) |
| 139 { | 145 { |
| 140 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 146 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 141 ScriptPromise promise = resolver->promise(); | 147 ScriptPromise promise = resolver->promise(); |
| 142 | 148 |
| 143 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { | 149 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { |
| 144 resolver->reject(DOMException::create(SecurityError, "The document is sa
ndboxed and lacks the 'allow-presentation' flag.")); | 150 resolver->reject(DOMException::create(SecurityError, "The document is sa
ndboxed and lacks the 'allow-presentation' flag.")); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 166 } | 172 } |
| 167 | 173 |
| 168 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) | 174 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) |
| 169 : ActiveScriptWrappable(this) | 175 : ActiveScriptWrappable(this) |
| 170 , ActiveDOMObject(executionContext) | 176 , ActiveDOMObject(executionContext) |
| 171 , m_url(url) | 177 , m_url(url) |
| 172 { | 178 { |
| 173 } | 179 } |
| 174 | 180 |
| 175 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |