OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "modules/webmidi/NavigatorWebMIDI.h" | 32 #include "modules/webmidi/NavigatorWebMIDI.h" |
33 | 33 |
34 #include "bindings/core/v8/ScriptPromise.h" | 34 #include "bindings/core/v8/ScriptPromise.h" |
35 #include "bindings/core/v8/ScriptPromiseResolver.h" | 35 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 36 #include "bindings/core/v8/V8DOMError.h" |
36 #include "core/dom/DOMError.h" | 37 #include "core/dom/DOMError.h" |
37 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
39 #include "core/frame/Navigator.h" | 40 #include "core/frame/Navigator.h" |
40 #include "modules/webmidi/MIDIAccessInitializer.h" | 41 #include "modules/webmidi/MIDIAccessInitializer.h" |
41 #include "modules/webmidi/MIDIOptions.h" | 42 #include "modules/webmidi/MIDIOptions.h" |
42 | 43 |
43 namespace blink { | 44 namespace blink { |
44 | 45 |
45 NavigatorWebMIDI::NavigatorWebMIDI(LocalFrame* frame) | 46 NavigatorWebMIDI::NavigatorWebMIDI(LocalFrame* frame) |
(...skipping 25 matching lines...) Expand all Loading... |
71 } | 72 } |
72 | 73 |
73 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, Navi
gator& navigator, const MIDIOptions& options) | 74 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, Navi
gator& navigator, const MIDIOptions& options) |
74 { | 75 { |
75 return NavigatorWebMIDI::from(navigator).requestMIDIAccess(scriptState, opti
ons); | 76 return NavigatorWebMIDI::from(navigator).requestMIDIAccess(scriptState, opti
ons); |
76 } | 77 } |
77 | 78 |
78 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, cons
t MIDIOptions& options) | 79 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, cons
t MIDIOptions& options) |
79 { | 80 { |
80 if (!frame() || frame()->document()->activeDOMObjectsAreStopped()) { | 81 if (!frame() || frame()->document()->activeDOMObjectsAreStopped()) { |
81 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(s
criptState); | 82 return ScriptPromise::reject(scriptState, toV8(DOMError::create("AbortEr
ror"), scriptState->context()->Global(), scriptState->isolate())); |
82 ScriptPromise promise = resolver->promise(); | |
83 // FIXME: Currently this rejection does not work because the context is
stopped. | |
84 resolver->reject(DOMError::create("AbortError")); | |
85 return promise; | |
86 } | 83 } |
87 | 84 |
88 return MIDIAccessInitializer::start(scriptState, options); | 85 return MIDIAccessInitializer::start(scriptState, options); |
89 } | 86 } |
90 | 87 |
91 } // namespace blink | 88 } // namespace blink |
OLD | NEW |