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

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: for submit 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
« no previous file with comments | « remoting/webapp/crd/js/host_list_api.js ('k') | remoting/webapp/crd/js/host_list_api_impl.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..02db52e6d41920cbceec8a68834aad2f6517afb2
--- /dev/null
+++ b/remoting/webapp/crd/js/host_list_api_gcd_impl.js
@@ -0,0 +1,81 @@
+// 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({
+ apiKey: remoting.settings.GOOGLE_API_KEY
+ });
+};
+
+/** @override */
+remoting.HostListApiGcdImpl.prototype.register = function(
+ newHostId, hostName, publicKey, hostClientId) {
+ 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');
+};
+
+})();
« no previous file with comments | « remoting/webapp/crd/js/host_list_api.js ('k') | remoting/webapp/crd/js/host_list_api_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698