| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 ASSERT(document); | 48 ASSERT(document); |
| 49 MIDIController* controller = MIDIController::from(document->frame()); | 49 MIDIController* controller = MIDIController::from(document->frame()); |
| 50 if (controller) { | 50 if (controller) { |
| 51 controller->requestSysexPermission(this); | 51 controller->requestSysexPermission(this); |
| 52 } else { | 52 } else { |
| 53 reject(DOMError::create("SecurityError")); | 53 reject(DOMError::create("SecurityError")); |
| 54 } | 54 } |
| 55 return promise; | 55 return promise; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void MIDIAccessInitializer::didAddInputPort(const String& id, const String& manu
facturer, const String& name, const String& version) | 58 void MIDIAccessInitializer::didAddInputPort(const String& id, const String& manu
facturer, const String& name, const String& version, bool isActive) |
| 59 { | 59 { |
| 60 ASSERT(m_accessor); | 60 ASSERT(m_accessor); |
| 61 m_portDescriptors.append(PortDescriptor(id, manufacturer, name, MIDIPort::MI
DIPortTypeInput, version)); | 61 m_portDescriptors.append(PortDescriptor(id, manufacturer, name, MIDIPort::MI
DIPortTypeInput, version, isActive)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void MIDIAccessInitializer::didAddOutputPort(const String& id, const String& man
ufacturer, const String& name, const String& version) | 64 void MIDIAccessInitializer::didAddOutputPort(const String& id, const String& man
ufacturer, const String& name, const String& version, bool isActive) |
| 65 { | 65 { |
| 66 ASSERT(m_accessor); | 66 ASSERT(m_accessor); |
| 67 m_portDescriptors.append(PortDescriptor(id, manufacturer, name, MIDIPort::MI
DIPortTypeOutput, version)); | 67 m_portDescriptors.append(PortDescriptor(id, manufacturer, name, MIDIPort::MI
DIPortTypeOutput, version, isActive)); |
| 68 } |
| 69 |
| 70 void MIDIAccessInitializer::didSetInputPortState(unsigned portIndex, bool isActi
ve) |
| 71 { |
| 72 // didSetInputPortState() is not allowed to call before didStartSession() |
| 73 // is called. Once didStartSession() is called, MIDIAccessorClient methods |
| 74 // are delegated to MIDIAccess. See constructor of MIDIAccess. |
| 75 ASSERT_NOT_REACHED(); |
| 76 } |
| 77 |
| 78 void MIDIAccessInitializer::didSetOutputPortState(unsigned portIndex, bool isAct
ive) |
| 79 { |
| 80 // See comments on didSetInputPortState(). |
| 81 ASSERT_NOT_REACHED(); |
| 68 } | 82 } |
| 69 | 83 |
| 70 void MIDIAccessInitializer::didStartSession(bool success, const String& error, c
onst String& message) | 84 void MIDIAccessInitializer::didStartSession(bool success, const String& error, c
onst String& message) |
| 71 { | 85 { |
| 72 ASSERT(m_accessor); | 86 ASSERT(m_accessor); |
| 73 if (success) { | 87 if (success) { |
| 74 resolve(MIDIAccess::create(m_accessor.release(), m_requestSysex, m_portD
escriptors, executionContext())); | 88 resolve(MIDIAccess::create(m_accessor.release(), m_requestSysex, m_portD
escriptors, executionContext())); |
| 75 } else { | 89 } else { |
| 76 reject(DOMError::create(error, message)); | 90 reject(DOMError::create(error, message)); |
| 77 } | 91 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 89 { | 103 { |
| 90 return executionContext()->securityOrigin(); | 104 return executionContext()->securityOrigin(); |
| 91 } | 105 } |
| 92 | 106 |
| 93 ExecutionContext* MIDIAccessInitializer::executionContext() const | 107 ExecutionContext* MIDIAccessInitializer::executionContext() const |
| 94 { | 108 { |
| 95 return scriptState()->executionContext(); | 109 return scriptState()->executionContext(); |
| 96 } | 110 } |
| 97 | 111 |
| 98 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |