| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const AtomicString& eventType, | 94 const AtomicString& eventType, |
| 95 RegisteredEventListener& registeredListener) { | 95 RegisteredEventListener& registeredListener) { |
| 96 EventTargetWithInlineData::addedEventListener(eventType, registeredListener); | 96 EventTargetWithInlineData::addedEventListener(eventType, registeredListener); |
| 97 if (eventType == EventTypeNames::connectionavailable) | 97 if (eventType == EventTypeNames::connectionavailable) |
| 98 UseCounter::count( | 98 UseCounter::count( |
| 99 getExecutionContext(), | 99 getExecutionContext(), |
| 100 UseCounter::PresentationRequestConnectionAvailableEventListener); | 100 UseCounter::PresentationRequestConnectionAvailableEventListener); |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool PresentationRequest::hasPendingActivity() const { | 103 bool PresentationRequest::hasPendingActivity() const { |
| 104 if (!getExecutionContext() || getExecutionContext()->isContextDestroyed()) | |
| 105 return false; | |
| 106 | |
| 107 // Prevents garbage collecting of this object when not hold by another | 104 // Prevents garbage collecting of this object when not hold by another |
| 108 // object but still has listeners registered. | 105 // object but still has listeners registered. |
| 109 return hasEventListeners(); | 106 return getExecutionContext() && hasEventListeners(); |
| 110 } | 107 } |
| 111 | 108 |
| 112 ScriptPromise PresentationRequest::start(ScriptState* scriptState) { | 109 ScriptPromise PresentationRequest::start(ScriptState* scriptState) { |
| 113 Settings* contextSettings = settings(getExecutionContext()); | 110 Settings* contextSettings = settings(getExecutionContext()); |
| 114 bool isUserGestureRequired = | 111 bool isUserGestureRequired = |
| 115 !contextSettings || contextSettings->presentationRequiresUserGesture(); | 112 !contextSettings || contextSettings->presentationRequiresUserGesture(); |
| 116 | 113 |
| 117 if (isUserGestureRequired && !UserGestureIndicator::utilizeUserGesture()) | 114 if (isUserGestureRequired && !UserGestureIndicator::utilizeUserGesture()) |
| 118 return ScriptPromise::rejectWithDOMException( | 115 return ScriptPromise::rejectWithDOMException( |
| 119 scriptState, | 116 scriptState, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 SuspendableObject::trace(visitor); | 205 SuspendableObject::trace(visitor); |
| 209 } | 206 } |
| 210 | 207 |
| 211 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, | 208 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, |
| 212 const KURL& url) | 209 const KURL& url) |
| 213 : ActiveScriptWrappable(this), | 210 : ActiveScriptWrappable(this), |
| 214 SuspendableObject(executionContext), | 211 SuspendableObject(executionContext), |
| 215 m_url(url) {} | 212 m_url(url) {} |
| 216 | 213 |
| 217 } // namespace blink | 214 } // namespace blink |
| OLD | NEW |