| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/imagecapture/ImageCapture.h" | 5 #include "modules/imagecapture/ImageCapture.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (!m_service) { | 85 if (!m_service) { |
| 86 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); | 86 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); |
| 87 return promise; | 87 return promise; |
| 88 } | 88 } |
| 89 | 89 |
| 90 m_serviceRequests.add(resolver); | 90 m_serviceRequests.add(resolver); |
| 91 | 91 |
| 92 // m_streamTrack->component()->source()->id() is the renderer "name" of the
camera; | 92 // m_streamTrack->component()->source()->id() is the renderer "name" of the
camera; |
| 93 // TODO(mcasas) consider sending the security origin as well: | 93 // TODO(mcasas) consider sending the security origin as well: |
| 94 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() | 94 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() |
| 95 m_service->GetCapabilities(m_streamTrack->component()->source()->id(), creat
eBaseCallback(bind<media::mojom::blink::PhotoCapabilitiesPtr>(&ImageCapture::onC
apabilities, this, resolver))); | 95 m_service->GetCapabilities(m_streamTrack->component()->source()->id(), creat
eBaseCallback(bind<media::mojom::blink::PhotoCapabilitiesPtr>(&ImageCapture::onC
apabilities, wrapPersistent(this), wrapPersistent(resolver)))); |
| 96 return promise; | 96 return promise; |
| 97 } | 97 } |
| 98 | 98 |
| 99 ScriptPromise ImageCapture::setOptions(ScriptState* scriptState, const PhotoSett
ings& photoSettings, ExceptionState& exceptionState) | 99 ScriptPromise ImageCapture::setOptions(ScriptState* scriptState, const PhotoSett
ings& photoSettings, ExceptionState& exceptionState) |
| 100 { | 100 { |
| 101 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 101 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 102 ScriptPromise promise = resolver->promise(); | 102 ScriptPromise promise = resolver->promise(); |
| 103 | 103 |
| 104 if (trackIsInactive(*m_streamTrack)) { | 104 if (trackIsInactive(*m_streamTrack)) { |
| 105 resolver->reject(DOMException::create(InvalidStateError, "The associated
Track is in an invalid state.")); | 105 resolver->reject(DOMException::create(InvalidStateError, "The associated
Track is in an invalid state.")); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 if (!m_service) { | 137 if (!m_service) { |
| 138 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); | 138 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); |
| 139 return promise; | 139 return promise; |
| 140 } | 140 } |
| 141 | 141 |
| 142 m_serviceRequests.add(resolver); | 142 m_serviceRequests.add(resolver); |
| 143 | 143 |
| 144 // m_streamTrack->component()->source()->id() is the renderer "name" of the
camera; | 144 // m_streamTrack->component()->source()->id() is the renderer "name" of the
camera; |
| 145 // TODO(mcasas) consider sending the security origin as well: | 145 // TODO(mcasas) consider sending the security origin as well: |
| 146 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() | 146 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() |
| 147 m_service->TakePhoto(m_streamTrack->component()->source()->id(), createBaseC
allback(bind<const String&, mojo::WTFArray<uint8_t>>(&ImageCapture::onTakePhoto,
this, resolver))); | 147 m_service->TakePhoto(m_streamTrack->component()->source()->id(), createBaseC
allback(bind<const String&, mojo::WTFArray<uint8_t>>(&ImageCapture::onTakePhoto,
wrapPersistent(this), wrapPersistent(resolver)))); |
| 148 return promise; | 148 return promise; |
| 149 } | 149 } |
| 150 | 150 |
| 151 ScriptPromise ImageCapture::grabFrame(ScriptState* scriptState, ExceptionState&
exceptionState) | 151 ScriptPromise ImageCapture::grabFrame(ScriptState* scriptState, ExceptionState&
exceptionState) |
| 152 { | 152 { |
| 153 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 153 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 154 ScriptPromise promise = resolver->promise(); | 154 ScriptPromise promise = resolver->promise(); |
| 155 | 155 |
| 156 if (trackIsInactive(*m_streamTrack)) { | 156 if (trackIsInactive(*m_streamTrack)) { |
| 157 resolver->reject(DOMException::create(InvalidStateError, "The associated
Track is in an invalid state.")); | 157 resolver->reject(DOMException::create(InvalidStateError, "The associated
Track is in an invalid state.")); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 DEFINE_TRACE(ImageCapture) | 242 DEFINE_TRACE(ImageCapture) |
| 243 { | 243 { |
| 244 visitor->trace(m_streamTrack); | 244 visitor->trace(m_streamTrack); |
| 245 visitor->trace(m_serviceRequests); | 245 visitor->trace(m_serviceRequests); |
| 246 EventTargetWithInlineData::trace(visitor); | 246 EventTargetWithInlineData::trace(visitor); |
| 247 ContextLifecycleObserver::trace(visitor); | 247 ContextLifecycleObserver::trace(visitor); |
| 248 } | 248 } |
| 249 | 249 |
| 250 } // namespace blink | 250 } // namespace blink |
| OLD | NEW |