Chromium Code Reviews| Index: third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp |
| diff --git a/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp b/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp |
| index b900c515a35b7254993b5b328094b64835464a21..a819ee0b95e3fbcf59542f8f6ffc8e72487bd578 100644 |
| --- a/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp |
| +++ b/third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp |
| @@ -4,12 +4,17 @@ |
| #include "modules/imagecapture/ImageCapture.h" |
| +#include "bindings/core/v8/CallbackPromiseAdapter.h" |
| #include "bindings/core/v8/ScriptPromiseResolver.h" |
| #include "core/dom/DOMException.h" |
| #include "core/dom/ExceptionCode.h" |
| +#include "core/frame/ImageBitmap.h" |
| #include "modules/EventTargetModules.h" |
| #include "modules/mediastream/MediaStreamTrack.h" |
| +#include "platform/graphics/StaticBitmapImage.h" |
|
emircan
2016/04/26 19:19:31
Extra?
mcasas
2016/04/27 00:51:29
Done.
|
| #include "public/platform/Platform.h" |
| +#include "public/platform/WebImageCaptureFrameGrabber.h" |
| +#include "public/platform/WebMediaStreamTrack.h" |
| namespace blink { |
| @@ -60,7 +65,19 @@ ScriptPromise ImageCapture::grabFrame(ScriptState* scriptState, ExceptionState& |
| return promise; |
| } |
| - resolver->reject(DOMException::create(NotSupportedError, "Not implemented yet")); |
| + // Create |m_frameGrabber| the first time. |
| + if (!m_frameGrabber) |
| + m_frameGrabber = adoptPtr(Platform::current()->createImageCaptureFrameGrabber()); |
| + |
| + if (!m_frameGrabber) { |
|
emircan
2016/04/26 19:19:31
Can you move this inside the if on l.69? I dont th
mcasas
2016/04/27 00:51:29
This a get-or-create snippet, right? The first
ti
|
| + resolver->reject(DOMException::create(UnknownError, "Couldn't create platform resources")); |
| + return promise; |
| + } |
| + |
| + // The platform does not know about MediaStreamTrack, so we wrap it up. |
| + WebMediaStreamTrack track(m_streamTrack->component()); |
| + m_frameGrabber->grabFrame(&track, new CallbackPromiseAdapter<ImageBitmap, void>(resolver)); |
| + |
| return promise; |
| } |