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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 /**
6 * @fileoverview
7 * REST API for host-list management.
8 */
9
10 /** @suppress {duplicate} */
11 var remoting = remoting || {};
12
13 (function() {
14
15 'use strict';
16
17 /**
18 * @constructor
19 * @implements {remoting.HostListApi}
20 */
21 remoting.HostListApiGcdImpl = function() {
22 this.gcd_ = new remoting.gcd.Client({
23 apiKey: remoting.settings.GOOGLE_API_KEY
24 });
25 };
26
27 /** @override */
28 remoting.HostListApiGcdImpl.prototype.register = function(
29 newHostId, hostName, publicKey, hostClientId) {
30 var self = this;
31 var deviceDraft = {
32 channel: {
33 supportedType: 'xmpp'
34 },
35 deviceKind: 'vendor',
36 name: newHostId,
37 displayName: hostName,
38 state: {
39 'publicKey': publicKey
40 }
41 };
42
43 return /** @type {!Promise<string>} */ (
44 this.gcd_.insertRegistrationTicket().
45 then(function(ticket) {
46 return self.gcd_.patchRegistrationTicket(
47 ticket.id, deviceDraft, hostClientId);
48 }).
49 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) {
50 return self.gcd_.finalizeRegistrationTicket(ticket.id);
51 }).
52 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) {
53 return ticket.robotAccountAuthorizationCode;
54 }).
55 catch(function(error) {
56 console.error('Error registering device with GCD: ' + error);
57 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED);
58 }));
59 };
60
61 /** @override */
62 remoting.HostListApiGcdImpl.prototype.get = function() {
63 // TODO(jrw)
64 this.gcd_.listDevices();
65 return Promise.resolve([]);
66 };
67
68 /** @override */
69 remoting.HostListApiGcdImpl.prototype.put =
70 function(hostId, hostName, hostPublicKey) {
71 // TODO(jrw)
72 throw new Error('Not implemented');
73 };
74
75 /** @override */
76 remoting.HostListApiGcdImpl.prototype.remove = function(hostId) {
77 // TODO(jrw)
78 throw new Error('Not implemented');
79 };
80
81 })();
OLDNEW
« 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