OLD | NEW |
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 Loading... |
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 Loading... |
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 })(); |
OLD | NEW |