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

Side by Side Diff: remoting/webapp/crd/js/host_list_api_gcd_impl.js

Issue 1111603002: Added ability to register new hosts using GCD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-list-delete
Patch Set: unit test fix Created 5 years, 7 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * REST API for host-list management. 7 * REST API for host-list management.
8 */ 8 */
9 9
10 /** @suppress {duplicate} */ 10 /** @suppress {duplicate} */
(...skipping 22 matching lines...) Expand all
33 supportedType: 'xmpp' 33 supportedType: 'xmpp'
34 }, 34 },
35 deviceKind: 'vendor', 35 deviceKind: 'vendor',
36 name: newHostId, 36 name: newHostId,
37 displayName: hostName, 37 displayName: hostName,
38 state: { 38 state: {
39 'publicKey': publicKey 39 'publicKey': publicKey
40 } 40 }
41 }; 41 };
42 42
43 return /** @type {!Promise<string>} */ ( 43 return /** @type {!Promise<remoting.HostListApi.RegisterResult>} */ (
44 this.gcd_.insertRegistrationTicket(). 44 this.gcd_.insertRegistrationTicket().
45 then(function(ticket) { 45 then(function(ticket) {
46 return self.gcd_.patchRegistrationTicket( 46 return self.gcd_.patchRegistrationTicket(
47 ticket.id, deviceDraft, hostClientId); 47 ticket.id, deviceDraft, hostClientId);
48 }). 48 }).
49 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) { 49 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) {
50 return self.gcd_.finalizeRegistrationTicket(ticket.id); 50 return self.gcd_.finalizeRegistrationTicket(ticket.id);
51 }). 51 }).
52 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) { 52 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) {
53 return ticket.robotAccountAuthorizationCode; 53 return {
54 authCode: ticket.robotAccountAuthorizationCode,
55 email: ticket.robotAccountEmail
56 };
54 }). 57 }).
55 catch(function(error) { 58 catch(function(error) {
56 console.error('Error registering device with GCD: ' + error); 59 console.error('Error registering device with GCD: ' + error);
57 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); 60 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED);
58 })); 61 }));
59 }; 62 };
60 63
61 /** @override */ 64 /** @override */
62 remoting.HostListApiGcdImpl.prototype.get = function() { 65 remoting.HostListApiGcdImpl.prototype.get = function() {
63 return this.gcd_.listDevices(). 66 return this.gcd_.listDevices().
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 host.createdTime = new Date(creationTimeMs).toISOString(); 128 host.createdTime = new Date(creationTimeMs).toISOString();
126 } 129 }
127 var lastUpdateTimeMs = base.getNumberAttr(device, 'lastUpdateTimeMs', 0); 130 var lastUpdateTimeMs = base.getNumberAttr(device, 'lastUpdateTimeMs', 0);
128 if (lastUpdateTimeMs) { 131 if (lastUpdateTimeMs) {
129 host.updatedTime = new Date(lastUpdateTimeMs).toISOString(); 132 host.updatedTime = new Date(lastUpdateTimeMs).toISOString();
130 } 133 }
131 return host; 134 return host;
132 }; 135 };
133 136
134 })(); 137 })();
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