| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 ScriptPromise PresentationRequest::start(ScriptState* scriptState) | 92 ScriptPromise PresentationRequest::start(ScriptState* scriptState) |
| 93 { | 93 { |
| 94 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 94 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 95 ScriptPromise promise = resolver->promise(); | 95 ScriptPromise promise = resolver->promise(); |
| 96 | 96 |
| 97 Settings* contextSettings = settings(getExecutionContext()); | 97 Settings* contextSettings = settings(getExecutionContext()); |
| 98 bool isUserGestureRequired = !contextSettings || contextSettings->presentati
onRequiresUserGesture(); | 98 bool isUserGestureRequired = !contextSettings || contextSettings->presentati
onRequiresUserGesture(); |
| 99 | 99 |
| 100 if (isUserGestureRequired && !UserGestureIndicator::processingUserGesture())
{ | 100 if (isUserGestureRequired && !UserGestureIndicator::utilizeUserGesture()) { |
| 101 resolver->reject(DOMException::create(InvalidAccessError, "PresentationR
equest::start() requires user gesture.")); | 101 resolver->reject(DOMException::create(InvalidAccessError, "PresentationR
equest::start() requires user gesture.")); |
| 102 return promise; | 102 return promise; |
| 103 } | 103 } |
| 104 | 104 |
| 105 WebPresentationClient* client = presentationClient(getExecutionContext()); | 105 WebPresentationClient* client = presentationClient(getExecutionContext()); |
| 106 if (!client) { | 106 if (!client) { |
| 107 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); | 107 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); |
| 108 return promise; | 108 return promise; |
| 109 } | 109 } |
| 110 client->startSession(m_url.getString(), new PresentationConnectionCallbacks(
resolver, this)); | 110 client->startSession(m_url.getString(), new PresentationConnectionCallbacks(
resolver, this)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) | 155 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) |
| 156 : ActiveScriptWrappable(this) | 156 : ActiveScriptWrappable(this) |
| 157 , ActiveDOMObject(executionContext) | 157 , ActiveDOMObject(executionContext) |
| 158 , m_url(url) | 158 , m_url(url) |
| 159 { | 159 { |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace blink | 162 } // namespace blink |
| OLD | NEW |