Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // Chromoting V1 app API key. | |
| 24 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.
| |
| 25 }); | |
| 26 }; | |
| 27 | |
| 28 /** @override */ | |
| 29 remoting.HostListApiGcdImpl.prototype.register = function( | |
| 30 newHostId, hostName, publicKey, hostClientId) { | |
| 31 // 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.
| |
| 32 var self = this; | |
| 33 var deviceDraft = { | |
| 34 channel: { | |
| 35 supportedType: 'xmpp' | |
| 36 }, | |
| 37 deviceKind: 'vendor', | |
| 38 name: newHostId, | |
| 39 displayName: hostName, | |
| 40 state: { | |
| 41 'publicKey': publicKey | |
| 42 } | |
| 43 }; | |
| 44 | |
| 45 return /** @type {!Promise<string>} */ ( | |
| 46 this.gcd_.insertRegistrationTicket(). | |
| 47 then(function(ticket) { | |
| 48 return self.gcd_.patchRegistrationTicket( | |
| 49 ticket.id, deviceDraft, hostClientId); | |
| 50 }). | |
| 51 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) { | |
| 52 return self.gcd_.finalizeRegistrationTicket(ticket.id); | |
| 53 }). | |
| 54 then(function(/**remoting.gcd.RegistrationTicket*/ ticket) { | |
| 55 return ticket.robotAccountAuthorizationCode; | |
| 56 }). | |
| 57 catch(function(error) { | |
| 58 console.error('Error registering device with GCD: ' + error); | |
| 59 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); | |
| 60 })); | |
| 61 }; | |
| 62 | |
| 63 /** @override */ | |
| 64 remoting.HostListApiGcdImpl.prototype.get = function() { | |
| 65 // TODO(jrw) | |
| 66 this.gcd_.listDevices(); | |
| 67 return Promise.resolve([]); | |
| 68 }; | |
| 69 | |
| 70 /** @override */ | |
| 71 remoting.HostListApiGcdImpl.prototype.put = | |
| 72 function(hostId, hostName, hostPublicKey) { | |
| 73 // TODO(jrw) | |
| 74 throw new Error('Not implemented'); | |
| 75 }; | |
| 76 | |
| 77 /** @override */ | |
| 78 remoting.HostListApiGcdImpl.prototype.remove = function(hostId) { | |
| 79 // TODO(jrw) | |
| 80 throw new Error('Not implemented'); | |
| 81 }; | |
| 82 | |
| 83 })(); | |
| OLD | NEW |