| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 Settings* settings(ExecutionContext* executionContext) { | 47 Settings* settings(ExecutionContext* executionContext) { |
| 48 DCHECK(executionContext); | 48 DCHECK(executionContext); |
| 49 | 49 |
| 50 Document* document = toDocument(executionContext); | 50 Document* document = toDocument(executionContext); |
| 51 return document->settings(); | 51 return document->settings(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 ScriptPromise rejectWithSandBoxException(ScriptState* scriptState) { | 54 ScriptPromise rejectWithSandBoxException(ScriptState* scriptState) { |
| 55 return ScriptPromise::rejectWithDOMException( | 55 return ScriptPromise::rejectWithDOMException( |
| 56 scriptState, DOMException::create(SecurityError, | 56 scriptState, |
| 57 "The document is sandboxed and lacks " | 57 DOMException::create(SecurityError, |
| 58 "the 'allow-presentation' flag.")); | 58 "The document is sandboxed and lacks " |
| 59 "the 'allow-presentation' flag.")); |
| 59 } | 60 } |
| 60 | 61 |
| 61 } // anonymous namespace | 62 } // anonymous namespace |
| 62 | 63 |
| 63 // static | 64 // static |
| 64 PresentationRequest* PresentationRequest::create( | 65 PresentationRequest* PresentationRequest::create( |
| 65 ExecutionContext* executionContext, | 66 ExecutionContext* executionContext, |
| 66 const String& url, | 67 const String& url, |
| 67 ExceptionState& exceptionState) { | 68 ExceptionState& exceptionState) { |
| 68 Vector<String> urls(1); | 69 Vector<String> urls(1); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 174 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 174 | 175 |
| 175 PresentationController* controller = | 176 PresentationController* controller = |
| 176 presentationController(getExecutionContext()); | 177 presentationController(getExecutionContext()); |
| 177 DCHECK(controller); | 178 DCHECK(controller); |
| 178 | 179 |
| 179 PresentationConnection* existingConnection = | 180 PresentationConnection* existingConnection = |
| 180 controller->findExistingConnection(m_urls, id); | 181 controller->findExistingConnection(m_urls, id); |
| 181 if (existingConnection) { | 182 if (existingConnection) { |
| 182 client->joinSession( | 183 client->joinSession( |
| 183 m_urls, id, WTF::makeUnique<ExistingPresentationConnectionCallbacks>( | 184 m_urls, id, |
| 184 resolver, existingConnection)); | 185 WTF::makeUnique<ExistingPresentationConnectionCallbacks>( |
| 186 resolver, existingConnection)); |
| 185 } else { | 187 } else { |
| 186 client->joinSession( | 188 client->joinSession( |
| 187 m_urls, id, | 189 m_urls, id, |
| 188 WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this)); | 190 WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this)); |
| 189 } | 191 } |
| 190 return resolver->promise(); | 192 return resolver->promise(); |
| 191 } | 193 } |
| 192 | 194 |
| 193 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) { | 195 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) { |
| 194 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) | 196 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if (executionContext->isSecureContext()) { | 238 if (executionContext->isSecureContext()) { |
| 237 UseCounter::count(executionContext, | 239 UseCounter::count(executionContext, |
| 238 UseCounter::PresentationRequestSecureOrigin); | 240 UseCounter::PresentationRequestSecureOrigin); |
| 239 } else { | 241 } else { |
| 240 UseCounter::count(executionContext, | 242 UseCounter::count(executionContext, |
| 241 UseCounter::PresentationRequestInsecureOrigin); | 243 UseCounter::PresentationRequestInsecureOrigin); |
| 242 } | 244 } |
| 243 } | 245 } |
| 244 | 246 |
| 245 } // namespace blink | 247 } // namespace blink |
| OLD | NEW |