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} hostName The user-visible name of the new host.
26 * @param {string} publicKey The public half of the host's key pair.
27 * @param {string} hostClientId The OAuth2 client ID of the host.
28 * @return {!Promise<remoting.HostListApi.RegisterResult>}
30 remoting.HostListApi.prototype.register = function(
31 hostName, publicKey, hostClientId) {
35 * Fetch the list of hosts for a user.
37 * @return {!Promise<!Array<!remoting.Host>>}
39 remoting.HostListApi.prototype.get = function() {
43 * Update the information for a host.
45 * @param {string} hostId
46 * @param {string} hostName
47 * @param {string} hostPublicKey
48 * @return {!Promise<void>}
50 remoting.HostListApi.prototype.put =
51 function(hostId, hostName, hostPublicKey) {
57 * @param {string} hostId
58 * @return {!Promise<void>}
60 remoting.HostListApi.prototype.remove = function(hostId) {
64 * Attempts to look up a host using an ID derived from its publicly
65 * visible access code.
67 * @param {string} supportId The support ID of the host to connect to.
68 * @return {!Promise<!remoting.Host>}
70 remoting.HostListApi.prototype.getSupportHost = function(supportId) {
74 * @private {remoting.HostListApi}
79 * @return {!remoting.HostListApi}
81 remoting.HostListApi.getInstance = function() {
82 if (instance == null) {
83 if (remoting.settings.USE_GCD) {
84 var gcdInstance = new remoting.GcdHostListApi();
85 var legacyInstance = new remoting.LegacyHostListApi();
86 instance = new remoting.CombinedHostListApi(legacyInstance, gcdInstance);
88 instance = new remoting.LegacyHostListApi();
96 * @param {remoting.HostListApi} newInstance
98 remoting.HostListApi.setInstance = function(newInstance) {
99 instance = newInstance;
105 * Information returned from the registry/GCD server when registering
110 * authCode: An OAuth2 authorization code that can be exchanged for a
113 * email: The email/XMPP address of the robot account associated with
114 * this device. The Chromoting directory sets this field to the
115 * empty string; GCD returns a real email address.
117 * hostId: The ID of the newly registered host.
125 remoting.HostListApi.RegisterResult;