Index: Source/modules/webmidi/NavigatorWebMIDI.cpp |
diff --git a/Source/modules/webmidi/NavigatorWebMIDI.cpp b/Source/modules/webmidi/NavigatorWebMIDI.cpp |
index ae9f39eefef3c5f9a2c1f7eed7d6f3ae3be34064..eba92d1c4a43d72eef15d0e8d9f3d5d1268ecdd3 100644 |
--- a/Source/modules/webmidi/NavigatorWebMIDI.cpp |
+++ b/Source/modules/webmidi/NavigatorWebMIDI.cpp |
@@ -31,11 +31,16 @@ |
#include "config.h" |
#include "modules/webmidi/NavigatorWebMIDI.h" |
+#include "bindings/v8/DOMRequestState.h" |
+#include "bindings/v8/ScriptPromise.h" |
+#include "bindings/v8/ScriptPromiseResolver.h" |
+#include "core/dom/DOMError.h" |
#include "core/dom/Document.h" |
#include "core/dom/ExecutionContext.h" |
#include "core/frame/Frame.h" |
#include "core/frame/Navigator.h" |
-#include "modules/webmidi/MIDIAccessPromise.h" |
+#include "modules/webmidi/MIDIAccess.h" |
+#include "modules/webmidi/MIDIOptions.h" |
namespace WebCore { |
@@ -63,20 +68,22 @@ NavigatorWebMIDI* NavigatorWebMIDI::from(Navigator* navigator) |
return supplement; |
} |
-PassRefPtrWillBeRawPtr<MIDIAccessPromise> NavigatorWebMIDI::requestMIDIAccess(Navigator* navigator, const Dictionary& options) |
+ScriptPromise NavigatorWebMIDI::requestMIDIAccess(Navigator* navigator, const Dictionary& options) |
{ |
return NavigatorWebMIDI::from(navigator)->requestMIDIAccess(options); |
} |
-PassRefPtrWillBeRawPtr<MIDIAccessPromise> NavigatorWebMIDI::requestMIDIAccess(const Dictionary& options) |
+ScriptPromise NavigatorWebMIDI::requestMIDIAccess(const Dictionary& options) |
{ |
- if (!frame()) |
- return 0; |
- |
- ExecutionContext* context = frame()->document(); |
- ASSERT(context); |
+ if (!frame()) { |
+ ScriptPromise promise = ScriptPromise::createPending(); |
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promise); |
+ // FIXME: Currently this rejection does not work because the context is stopped. |
+ resolver->reject(DOMError::create("AbortError")); |
+ return promise; |
+ } |
- return MIDIAccessPromise::create(context, options); |
+ return MIDIAccess::create(MIDIOptions(options), frame()->document())->startRequest(); |
} |
} // namespace WebCore |