Index: remoting/webapp/crd/js/host_list_api_gcd_impl.js |
diff --git a/remoting/webapp/crd/js/host_list_api_gcd_impl.js b/remoting/webapp/crd/js/host_list_api_gcd_impl.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e1a400dfecc5cdc09e27636617c124c11cb16fa7 |
--- /dev/null |
+++ b/remoting/webapp/crd/js/host_list_api_gcd_impl.js |
@@ -0,0 +1,83 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * @fileoverview |
+ * REST API for host-list management. |
+ */ |
+ |
+/** @suppress {duplicate} */ |
+var remoting = remoting || {}; |
+ |
+(function() { |
+ |
+'use strict'; |
+ |
+/** |
+ * @constructor |
+ * @implements {remoting.HostListApi} |
+ */ |
+remoting.HostListApiGcdImpl = function() { |
+ this.gcd_ = new remoting.gcd.Client({ |
+ // Chromoting V1 app API key. |
+ apiKey: 'AIzaSyBs-PPti9HWLCqGtU_QyIRD4kSfb-0wnbU' |
Jamie
2015/04/22 23:46:01
API keys should be checked in to google_apis/inter
John Williams
2015/04/23 23:55:42
Done.
|
+ }); |
+}; |
+ |
+/** @override */ |
+remoting.HostListApiGcdImpl.prototype.register = function( |
+ newHostId, hostName, publicKey, hostClientId) { |
+ // TODO(jrw) |
Jamie
2015/04/22 23:46:01
Please be more specific about what remains to be d
John Williams
2015/04/23 23:55:42
That TODO is obsolete. Removed.
|
+ var self = this; |
+ var deviceDraft = { |
+ channel: { |
+ supportedType: 'xmpp' |
+ }, |
+ deviceKind: 'vendor', |
+ name: newHostId, |
+ displayName: hostName, |
+ state: { |
+ 'publicKey': publicKey |
+ } |
+ }; |
+ |
+ return /** @type {!Promise<string>} */ ( |
+ this.gcd_.insertRegistrationTicket(). |
+ then(function(ticket) { |
+ return self.gcd_.patchRegistrationTicket( |
+ ticket.id, deviceDraft, hostClientId); |
+ }). |
+ then(function(/**remoting.gcd.RegistrationTicket*/ ticket) { |
+ return self.gcd_.finalizeRegistrationTicket(ticket.id); |
+ }). |
+ then(function(/**remoting.gcd.RegistrationTicket*/ ticket) { |
+ return ticket.robotAccountAuthorizationCode; |
+ }). |
+ catch(function(error) { |
+ console.error('Error registering device with GCD: ' + error); |
+ throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); |
+ })); |
+}; |
+ |
+/** @override */ |
+remoting.HostListApiGcdImpl.prototype.get = function() { |
+ // TODO(jrw) |
+ this.gcd_.listDevices(); |
+ return Promise.resolve([]); |
+}; |
+ |
+/** @override */ |
+remoting.HostListApiGcdImpl.prototype.put = |
+ function(hostId, hostName, hostPublicKey) { |
+ // TODO(jrw) |
+ throw new Error('Not implemented'); |
+}; |
+ |
+/** @override */ |
+remoting.HostListApiGcdImpl.prototype.remove = function(hostId) { |
+ // TODO(jrw) |
+ throw new Error('Not implemented'); |
+}; |
+ |
+})(); |