This source file includes following definitions.
- supplementName
- from
- requestMIDIAccess
- requestMIDIAccess
#include "config.h"
#include "modules/webmidi/NavigatorWebMIDI.h"
#include "bindings/v8/ScriptPromise.h"
#include "bindings/v8/ScriptPromiseResolver.h"
#include "core/dom/DOMError.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Navigator.h"
#include "modules/webmidi/MIDIAccess.h"
#include "modules/webmidi/MIDIOptions.h"
namespace WebCore {
NavigatorWebMIDI::NavigatorWebMIDI(LocalFrame* frame)
: DOMWindowProperty(frame)
{
}
NavigatorWebMIDI::~NavigatorWebMIDI()
{
}
const char* NavigatorWebMIDI::supplementName()
{
return "NavigatorWebMIDI";
}
NavigatorWebMIDI& NavigatorWebMIDI::from(Navigator& navigator)
{
NavigatorWebMIDI* supplement = static_cast<NavigatorWebMIDI*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName()));
if (!supplement) {
supplement = new NavigatorWebMIDI(navigator.frame());
provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
}
return *supplement;
}
ScriptPromise NavigatorWebMIDI::requestMIDIAccess(Navigator& navigator, const Dictionary& options)
{
return NavigatorWebMIDI::from(navigator).requestMIDIAccess(options);
}
ScriptPromise NavigatorWebMIDI::requestMIDIAccess(const Dictionary& options)
{
if (!frame()) {
RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(v8::Isolate::GetCurrent());
ScriptPromise promise = resolver->promise();
resolver->reject(DOMError::create("AbortError"));
return promise;
}
return MIDIAccess::request(MIDIOptions(options), frame()->document());
}
}