| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/webusb/USB.h" | 5 #include "modules/webusb/USB.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 m_deviceManagerRequests.remove(resolver); | 155 m_deviceManagerRequests.remove(resolver); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de
viceInfo) | 158 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de
viceInfo) |
| 159 { | 159 { |
| 160 auto requestEntry = m_chooserServiceRequests.find(resolver); | 160 auto requestEntry = m_chooserServiceRequests.find(resolver); |
| 161 if (requestEntry == m_chooserServiceRequests.end()) | 161 if (requestEntry == m_chooserServiceRequests.end()) |
| 162 return; | 162 return; |
| 163 m_chooserServiceRequests.remove(requestEntry); | 163 m_chooserServiceRequests.remove(requestEntry); |
| 164 | 164 |
| 165 if (!m_deviceManager) { |
| 166 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); |
| 167 return; |
| 168 } |
| 169 |
| 165 if (deviceInfo) { | 170 if (deviceInfo) { |
| 166 usb::DevicePtr device; | 171 usb::DevicePtr device; |
| 167 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device)); | 172 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device)); |
| 168 resolver->resolve(USBDevice::create(std::move(deviceInfo), std::move(dev
ice), resolver->getExecutionContext())); | 173 resolver->resolve(USBDevice::create(std::move(deviceInfo), std::move(dev
ice), resolver->getExecutionContext())); |
| 169 } else { | 174 } else { |
| 170 resolver->reject(DOMException::create(NotFoundError, "No device selected
.")); | 175 resolver->reject(DOMException::create(NotFoundError, "No device selected
.")); |
| 171 } | 176 } |
| 172 } | 177 } |
| 173 | 178 |
| 174 void USB::onDeviceChanges(usb::DeviceChangeNotificationPtr notification) | 179 void USB::onDeviceChanges(usb::DeviceChangeNotificationPtr notification) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 201 | 206 |
| 202 DEFINE_TRACE(USB) | 207 DEFINE_TRACE(USB) |
| 203 { | 208 { |
| 204 EventTargetWithInlineData::trace(visitor); | 209 EventTargetWithInlineData::trace(visitor); |
| 205 ContextLifecycleObserver::trace(visitor); | 210 ContextLifecycleObserver::trace(visitor); |
| 206 visitor->trace(m_deviceManagerRequests); | 211 visitor->trace(m_deviceManagerRequests); |
| 207 visitor->trace(m_chooserServiceRequests); | 212 visitor->trace(m_chooserServiceRequests); |
| 208 } | 213 } |
| 209 | 214 |
| 210 } // namespace blink | 215 } // namespace blink |
| OLD | NEW |