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
3 // found in the LICENSE file.
6 * @fileoverview Contains a simple factory for creating and opening Gnubby
12 * @param {Gnubbies} gnubbies Gnubbies singleton instance
14 * @implements {GnubbyFactory}
16 function UsbGnubbyFactory(gnubbies) {
17 /** @private {Gnubbies} */
18 this.gnubbies_ = gnubbies;
19 Gnubby.setGnubbies(gnubbies);
23 * Creates a new gnubby object, and opens the gnubby with the given index.
24 * @param {GnubbyDeviceId} which The device to open.
25 * @param {boolean} forEnroll Whether this gnubby is being opened for enrolling.
26 * @param {FactoryOpenCallback} cb Called with result of opening the gnubby.
27 * @param {string=} logMsgUrl the url to post log messages to
30 UsbGnubbyFactory.prototype.openGnubby =
31 function(which, forEnroll, cb, logMsgUrl) {
32 var gnubby = new Gnubby();
33 gnubby.open(which, function(rc) {
38 gnubby.sync(function(rc) {
45 * Enumerates gnubbies.
46 * @param {function(number, Array.<GnubbyDeviceId>)} cb Enumerate callback
48 UsbGnubbyFactory.prototype.enumerate = function(cb) {
49 this.gnubbies_.enumerate(cb);
53 * No-op prerequisite check.
54 * @param {Gnubby} gnubby The not-enrolled gnubby.
55 * @param {string} appIdHash The base64-encoded hash of the app id for which
56 * the gnubby being enrolled.
57 * @param {FactoryOpenCallback} cb Called with the result of the prerequisite
58 * check. (A non-zero status indicates failure.)
60 UsbGnubbyFactory.prototype.notEnrolledPrerequisiteCheck =
61 function(gnubby, appIdHash, cb) {
62 cb(DeviceStatusCodes.OK_STATUS, gnubby);