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 29 matching lines...) Expand all Loading... |
40 #include "modules/webmidi/MIDIAccessInitializer.h" | 40 #include "modules/webmidi/MIDIAccessInitializer.h" |
41 #include "modules/webmidi/MIDIOptions.h" | 41 #include "modules/webmidi/MIDIOptions.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 NavigatorWebMIDI::NavigatorWebMIDI(LocalFrame* frame) | 45 NavigatorWebMIDI::NavigatorWebMIDI(LocalFrame* frame) |
46 : DOMWindowProperty(frame) | 46 : DOMWindowProperty(frame) |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NavigatorWebMIDI); | 50 NavigatorWebMIDI::~NavigatorWebMIDI() |
| 51 { |
| 52 } |
51 | 53 |
52 DEFINE_TRACE(NavigatorWebMIDI) | 54 DEFINE_TRACE(NavigatorWebMIDI) |
53 { | 55 { |
54 WillBeHeapSupplement<Navigator>::trace(visitor); | 56 HeapSupplement<Navigator>::trace(visitor); |
55 DOMWindowProperty::trace(visitor); | 57 DOMWindowProperty::trace(visitor); |
56 } | 58 } |
57 | 59 |
58 const char* NavigatorWebMIDI::supplementName() | 60 const char* NavigatorWebMIDI::supplementName() |
59 { | 61 { |
60 return "NavigatorWebMIDI"; | 62 return "NavigatorWebMIDI"; |
61 } | 63 } |
62 | 64 |
63 NavigatorWebMIDI& NavigatorWebMIDI::from(Navigator& navigator) | 65 NavigatorWebMIDI& NavigatorWebMIDI::from(Navigator& navigator) |
64 { | 66 { |
65 NavigatorWebMIDI* supplement = static_cast<NavigatorWebMIDI*>(WillBeHeapSupp
lement<Navigator>::from(navigator, supplementName())); | 67 NavigatorWebMIDI* supplement = static_cast<NavigatorWebMIDI*>(HeapSupplement
<Navigator>::from(navigator, supplementName())); |
66 if (!supplement) { | 68 if (!supplement) { |
67 supplement = new NavigatorWebMIDI(navigator.frame()); | 69 supplement = new NavigatorWebMIDI(navigator.frame()); |
68 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); | 70 provideTo(navigator, supplementName(), supplement); |
69 } | 71 } |
70 return *supplement; | 72 return *supplement; |
71 } | 73 } |
72 | 74 |
73 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, Navi
gator& navigator, const MIDIOptions& options) | 75 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, Navi
gator& navigator, const MIDIOptions& options) |
74 { | 76 { |
75 return NavigatorWebMIDI::from(navigator).requestMIDIAccess(scriptState, opti
ons); | 77 return NavigatorWebMIDI::from(navigator).requestMIDIAccess(scriptState, opti
ons); |
76 } | 78 } |
77 | 79 |
78 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, cons
t MIDIOptions& options) | 80 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, cons
t MIDIOptions& options) |
79 { | 81 { |
80 if (!frame() || frame()->document()->activeDOMObjectsAreStopped()) { | 82 if (!frame() || frame()->document()->activeDOMObjectsAreStopped()) { |
81 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "The frame is not working.")); | 83 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "The frame is not working.")); |
82 } | 84 } |
83 | 85 |
84 return MIDIAccessInitializer::start(scriptState, options); | 86 return MIDIAccessInitializer::start(scriptState, options); |
85 } | 87 } |
86 | 88 |
87 } // namespace blink | 89 } // namespace blink |
OLD | NEW |