Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1274)

Unified Diff: remoting/webapp/crd/js/host_list_api_gcd_impl.js

Issue 1094133003: Added (incomplete) implementation of HostListApi using GCD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcd-client-fix
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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');
+};
+
+})();

Powered by Google App Engine
This is Rietveld 408576698