| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (enable) | 73 if (enable) |
| 74 m_accessor->startSession(); | 74 m_accessor->startSession(); |
| 75 else | 75 else |
| 76 permissionDenied(); | 76 permissionDenied(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) | 79 void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) |
| 80 { | 80 { |
| 81 ASSERT(isMainThread()); | 81 ASSERT(isMainThread()); |
| 82 | 82 |
| 83 m_inputs.append(MIDIInput::create(this, executionContext(), id, manufacturer
, name, version)); | 83 m_inputs.append(MIDIInput::create(this, id, manufacturer, name, version)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void MIDIAccess::didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) | 86 void MIDIAccess::didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) |
| 87 { | 87 { |
| 88 ASSERT(isMainThread()); | 88 ASSERT(isMainThread()); |
| 89 | 89 |
| 90 unsigned portIndex = m_outputs.size(); | 90 unsigned portIndex = m_outputs.size(); |
| 91 m_outputs.append(MIDIOutput::create(this, portIndex, executionContext(), id,
manufacturer, name, version)); | 91 m_outputs.append(MIDIOutput::create(this, portIndex, id, manufacturer, name,
version)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void MIDIAccess::didStartSession(bool success) | 94 void MIDIAccess::didStartSession(bool success) |
| 95 { | 95 { |
| 96 ASSERT(isMainThread()); | 96 ASSERT(isMainThread()); |
| 97 | 97 |
| 98 m_hasAccess = success; | 98 m_hasAccess = success; |
| 99 if (success) | 99 if (success) |
| 100 m_promise->fulfill(); | 100 m_promise->fulfill(); |
| 101 else | 101 else |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 { | 145 { |
| 146 m_hasAccess = false; | 146 m_hasAccess = false; |
| 147 if (!m_requesting) | 147 if (!m_requesting) |
| 148 return; | 148 return; |
| 149 m_requesting = false; | 149 m_requesting = false; |
| 150 Document* document = toDocument(executionContext()); | 150 Document* document = toDocument(executionContext()); |
| 151 ASSERT(document); | 151 ASSERT(document); |
| 152 MIDIController* controller = MIDIController::from(document->page()); | 152 MIDIController* controller = MIDIController::from(document->page()); |
| 153 ASSERT(controller); | 153 ASSERT(controller); |
| 154 controller->cancelSysExPermissionRequest(this); | 154 controller->cancelSysExPermissionRequest(this); |
| 155 | |
| 156 m_accessor.clear(); | |
| 157 } | 155 } |
| 158 | 156 |
| 159 void MIDIAccess::startRequest() | 157 void MIDIAccess::startRequest() |
| 160 { | 158 { |
| 161 if (!m_promise->options()->sysex) { | 159 if (!m_promise->options()->sysex) { |
| 162 m_accessor->startSession(); | 160 m_accessor->startSession(); |
| 163 return; | 161 return; |
| 164 } | 162 } |
| 165 Document* document = toDocument(executionContext()); | 163 Document* document = toDocument(executionContext()); |
| 166 ASSERT(document); | 164 ASSERT(document); |
| 167 MIDIController* controller = MIDIController::from(document->page()); | 165 MIDIController* controller = MIDIController::from(document->page()); |
| 168 if (controller) { | 166 if (controller) { |
| 169 m_requesting = true; | 167 m_requesting = true; |
| 170 controller->requestSysExPermission(this); | 168 controller->requestSysExPermission(this); |
| 171 } else { | 169 } else { |
| 172 permissionDenied(); | 170 permissionDenied(); |
| 173 } | 171 } |
| 174 } | 172 } |
| 175 | 173 |
| 176 void MIDIAccess::permissionDenied() | 174 void MIDIAccess::permissionDenied() |
| 177 { | 175 { |
| 178 ASSERT(isMainThread()); | 176 ASSERT(isMainThread()); |
| 179 | 177 |
| 180 m_hasAccess = false; | 178 m_hasAccess = false; |
| 181 m_promise->reject(DOMError::create("SecurityError")); | 179 m_promise->reject(DOMError::create("SecurityError")); |
| 182 } | 180 } |
| 183 | 181 |
| 184 } // namespace WebCore | 182 } // namespace WebCore |
| OLD | NEW |