OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @constructor */ | 10 /** @constructor */ |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 /** @param {XMLHttpRequest} xhr */ | 196 /** @param {XMLHttpRequest} xhr */ |
197 function (xhr) { onRegistered(privateKey, xhr); }, | 197 function (xhr) { onRegistered(privateKey, xhr); }, |
198 JSON.stringify(newHostDetails), | 198 JSON.stringify(newHostDetails), |
199 headers); | 199 headers); |
200 }; | 200 }; |
201 | 201 |
202 /** @param {string} privateKey | 202 /** @param {string} privateKey |
203 * @param {string} publicKey */ | 203 * @param {string} publicKey */ |
204 function onKeyGenerated(privateKey, publicKey) { | 204 function onKeyGenerated(privateKey, publicKey) { |
205 remoting.oauth2.callWithToken( | 205 remoting.oauth2.callWithToken( |
206 /** @param {string} oauthToken */ | 206 /** @param {string?} oauthToken */ |
207 function(oauthToken) { | 207 function(oauthToken) { |
208 doRegisterHost(privateKey, publicKey, oauthToken); | 208 if (oauthToken) { |
| 209 doRegisterHost(privateKey, publicKey, oauthToken); |
| 210 } else { |
| 211 // TODO(jamiewalch): Have a more specific error code here? |
| 212 callback(remoting.HostController.AsyncResult.FAILED); |
| 213 } |
209 }); | 214 }); |
210 }; | 215 }; |
211 | 216 |
212 this.plugin_.generateKeyPair(onKeyGenerated); | 217 this.plugin_.generateKeyPair(onKeyGenerated); |
213 }; | 218 }; |
214 | 219 |
215 /** | 220 /** |
216 * Stop the daemon process. | 221 * Stop the daemon process. |
217 * @param {function(remoting.HostController.AsyncResult):void} callback | 222 * @param {function(remoting.HostController.AsyncResult):void} callback |
218 * Callback to be called when finished. | 223 * Callback to be called when finished. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 try { | 330 try { |
326 this.plugin_.getDaemonConfig(onConfig); | 331 this.plugin_.getDaemonConfig(onConfig); |
327 } catch (err) { | 332 } catch (err) { |
328 this.setHost(null); | 333 this.setHost(null); |
329 onDone(); | 334 onDone(); |
330 } | 335 } |
331 }; | 336 }; |
332 | 337 |
333 /** @type {remoting.HostController} */ | 338 /** @type {remoting.HostController} */ |
334 remoting.hostController = null; | 339 remoting.hostController = null; |
OLD | NEW |