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.
7 * API for host-list management.
10 /** @suppress {duplicate} */
11 var remoting = remoting || {};
18 remoting.HostListApi = function() {
22 * Registers a new host with the host registry service (either the
23 * Chromoting registry or GCD).
25 * @param {string} newHostId The ID of the new host to register.
26 * @param {string} hostName The user-visible name of the new host.
27 * @param {string} publicKey The public half of the host's key pair.
28 * @param {string} hostClientId The OAuth2 client ID of the host.
29 * @return {!Promise<remoting.HostListApi.RegisterResult>}
31 remoting.HostListApi.prototype.register = function(
32 newHostId, hostName, publicKey, hostClientId) {
36 * Fetch the list of hosts for a user.
38 * @return {!Promise<!Array<!remoting.Host>>}
40 remoting.HostListApi.prototype.get = function() {
44 * Update the information for a host.
46 * @param {string} hostId
47 * @param {string} hostName
48 * @param {string} hostPublicKey
49 * @return {!Promise<void>}
51 remoting.HostListApi.prototype.put =
52 function(hostId, hostName, hostPublicKey) {
58 * @param {string} hostId
59 * @return {!Promise<void>}
61 remoting.HostListApi.prototype.remove = function(hostId) {
65 * Attempts to look up a host using an ID derived from its publicly
66 * visible access code.
68 * @param {string} supportId The support ID of the host to connect to.
69 * @return {!Promise<!remoting.Host>}
71 remoting.HostListApi.prototype.getSupportHost = function(supportId) {
75 * @private {remoting.HostListApi}
80 * @return {!remoting.HostListApi}
82 remoting.HostListApi.getInstance = function() {
83 if (instance == null) {
84 instance = remoting.settings.USE_GCD ?
85 new remoting.HostListApiGcdImpl() :
86 new remoting.HostListApiImpl();
93 * @param {remoting.HostListApi} newInstance
95 remoting.HostListApi.setInstance = function(newInstance) {
96 instance = newInstance;
102 * Information returned from the registry/GCD server when registering
103 * a device. GCD will fill in all three fields; the Chromoting
104 * registry will only return an auth code; other fields will be empty.
108 * authCode: An OAuth2 authorization code that can be exchanged for a
111 * email: The email/XMPP address of the robot account associated
114 * gcmId: The ID string assigned to this device by GCD.
122 remoting.HostListApi.RegisterResult;