Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/webmidi/MIDIAccessInitializer.h" | 6 #include "modules/webmidi/MIDIAccessInitializer.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMError.h" | 10 #include "core/dom/DOMError.h" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/frame/Navigator.h" | 12 #include "core/frame/Navigator.h" |
| 13 #include "modules/webmidi/MIDIAccess.h" | 13 #include "modules/webmidi/MIDIAccess.h" |
| 14 #include "modules/webmidi/MIDIController.h" | 14 #include "modules/webmidi/MIDIController.h" |
| 15 #include "modules/webmidi/MIDIOptions.h" | 15 #include "modules/webmidi/MIDIOptions.h" |
| 16 #include "modules/webmidi/MIDIPort.h" | 16 #include "modules/webmidi/MIDIPort.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 MIDIAccessInitializer::MIDIAccessInitializer(ScriptState* scriptState, const MID IOptions& options) | 20 MIDIAccessInitializer::MIDIAccessInitializer(ScriptState* scriptState, const MID IOptions* options) |
| 21 : ScriptPromiseResolver(scriptState) | 21 : ScriptPromiseResolver(scriptState) |
| 22 , m_options(options) | |
| 23 , m_sysexEnabled(false) | 22 , m_sysexEnabled(false) |
| 24 { | 23 { |
| 24 if (options->hasSysex()) | |
|
Takashi Toyoshima
2014/09/10 04:07:51
hum... this change works, but now the variable nam
bashi
2014/09/10 08:04:38
Renamed m_requestSysex and resolveSysexPermission(
| |
| 25 m_sysexEnabled = options->sysex(); | |
| 25 } | 26 } |
| 26 | 27 |
| 27 MIDIAccessInitializer::~MIDIAccessInitializer() | 28 MIDIAccessInitializer::~MIDIAccessInitializer() |
| 28 { | 29 { |
| 29 // It is safe to cancel a request which is already finished or canceld. | 30 // It is safe to cancel a request which is already finished or canceld. |
| 30 Document* document = toDocument(executionContext()); | 31 Document* document = toDocument(executionContext()); |
| 31 ASSERT(document); | 32 ASSERT(document); |
| 32 MIDIController* controller = MIDIController::from(document->frame()); | 33 MIDIController* controller = MIDIController::from(document->frame()); |
| 33 if (controller) | 34 if (controller) |
| 34 controller->cancelSysexPermissionRequest(this); | 35 controller->cancelSysexPermissionRequest(this); |
| 35 } | 36 } |
| 36 | 37 |
| 37 ScriptPromise MIDIAccessInitializer::start() | 38 ScriptPromise MIDIAccessInitializer::start() |
| 38 { | 39 { |
| 39 ScriptPromise promise = this->promise(); | 40 ScriptPromise promise = this->promise(); |
| 40 m_accessor = MIDIAccessor::create(this); | 41 m_accessor = MIDIAccessor::create(this); |
| 41 | 42 |
| 42 if (!m_options.sysex) { | 43 if (!m_sysexEnabled) { |
| 43 m_accessor->startSession(); | 44 m_accessor->startSession(); |
| 44 return promise; | 45 return promise; |
| 45 } | 46 } |
| 46 Document* document = toDocument(executionContext()); | 47 Document* document = toDocument(executionContext()); |
| 47 ASSERT(document); | 48 ASSERT(document); |
| 48 MIDIController* controller = MIDIController::from(document->frame()); | 49 MIDIController* controller = MIDIController::from(document->frame()); |
| 49 if (controller) { | 50 if (controller) { |
| 50 controller->requestSysexPermission(this); | 51 controller->requestSysexPermission(this); |
| 51 } else { | 52 } else { |
| 52 reject(DOMError::create("SecurityError")); | 53 reject(DOMError::create("SecurityError")); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 { | 90 { |
| 90 return executionContext()->securityOrigin(); | 91 return executionContext()->securityOrigin(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 ExecutionContext* MIDIAccessInitializer::executionContext() const | 94 ExecutionContext* MIDIAccessInitializer::executionContext() const |
| 94 { | 95 { |
| 95 return scriptState()->executionContext(); | 96 return scriptState()->executionContext(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |