| 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 /** | 5 /** |
| 6 * @fileoverview Implements a low-level gnubby driver based on chrome.usb. | 6 * @fileoverview Implements a low-level gnubby driver based on chrome.usb. |
| 7 */ | 7 */ |
| 8 'use strict'; | 8 'use strict'; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (!self.readyToUse_()) return; // No point in continuing. | 267 if (!self.readyToUse_()) return; // No point in continuing. |
| 268 | 268 |
| 269 if (chrome.runtime.lastError) { | 269 if (chrome.runtime.lastError) { |
| 270 console.warn(UTIL_fmt('out bulkTransfer lastError: ')); | 270 console.warn(UTIL_fmt('out bulkTransfer lastError: ')); |
| 271 console.warn(UTIL_fmt(chrome.runtime.lastError.message)); | 271 console.warn(UTIL_fmt(chrome.runtime.lastError.message)); |
| 272 window.setTimeout(function() { self.destroy(); }, 0); | 272 window.setTimeout(function() { self.destroy(); }, 0); |
| 273 return; | 273 return; |
| 274 } | 274 } |
| 275 | 275 |
| 276 window.setTimeout(function() { self.readOneReply_(); }, 0); | 276 window.setTimeout(function() { self.readOneReply_(); }, 0); |
| 277 }; | 277 } |
| 278 | 278 |
| 279 var u8 = new Uint8Array(frame); | 279 var u8 = new Uint8Array(frame); |
| 280 | 280 |
| 281 // See whether this requires scrubbing before logging. | 281 // See whether this requires scrubbing before logging. |
| 282 var alternateLog = Gnubby.hasOwnProperty('redactRequestLog') && | 282 var alternateLog = Gnubby.hasOwnProperty('redactRequestLog') && |
| 283 Gnubby['redactRequestLog'](u8); | 283 Gnubby['redactRequestLog'](u8); |
| 284 if (alternateLog) { | 284 if (alternateLog) { |
| 285 console.log(UTIL_fmt('>' + alternateLog)); | 285 console.log(UTIL_fmt('>' + alternateLog)); |
| 286 } else { | 286 } else { |
| 287 console.log(UTIL_fmt('>' + UTIL_BytesToHex(u8))); | 287 console.log(UTIL_fmt('>' + UTIL_BytesToHex(u8))); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 */ | 589 */ |
| 590 UsbGnubbyDevice.register = function(gnubbies) { | 590 UsbGnubbyDevice.register = function(gnubbies) { |
| 591 var USB_GNUBBY_IMPL = { | 591 var USB_GNUBBY_IMPL = { |
| 592 isSharedAccess: false, | 592 isSharedAccess: false, |
| 593 enumerate: UsbGnubbyDevice.enumerate, | 593 enumerate: UsbGnubbyDevice.enumerate, |
| 594 deviceToDeviceId: UsbGnubbyDevice.deviceToDeviceId, | 594 deviceToDeviceId: UsbGnubbyDevice.deviceToDeviceId, |
| 595 open: UsbGnubbyDevice.open | 595 open: UsbGnubbyDevice.open |
| 596 }; | 596 }; |
| 597 gnubbies.registerNamespace(UsbGnubbyDevice.NAMESPACE, USB_GNUBBY_IMPL); | 597 gnubbies.registerNamespace(UsbGnubbyDevice.NAMESPACE, USB_GNUBBY_IMPL); |
| 598 }; | 598 }; |
| OLD | NEW |