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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 /** @param {string} privateKey | 149 /** @param {string} privateKey |
150 * @param {XMLHttpRequest} xhr */ | 150 * @param {XMLHttpRequest} xhr */ |
151 function onRegistered(privateKey, xhr) { | 151 function onRegistered(privateKey, xhr) { |
152 var success = (xhr.status == 200); | 152 var success = (xhr.status == 200); |
153 | 153 |
154 if (success) { | 154 if (success) { |
155 var hostSecretHash = | 155 var hostSecretHash = |
156 'hmac:' + that.plugin_.getPinHash(newHostId, hostPin); | 156 'hmac:' + that.plugin_.getPinHash(newHostId, hostPin); |
157 var hostConfig = JSON.stringify({ | 157 var hostConfig = JSON.stringify({ |
158 xmpp_login: remoting.oauth2.getCachedEmail(), | 158 xmpp_login: remoting.oauth2.getCachedEmail(), |
159 oauth_refresh_token: remoting.oauth2.getRefreshToken(), | 159 oauth_refresh_token: remoting.oauth2.exportRefreshToken(), |
160 host_id: newHostId, | 160 host_id: newHostId, |
161 host_name: hostName, | 161 host_name: hostName, |
162 host_secret_hash: hostSecretHash, | 162 host_secret_hash: hostSecretHash, |
163 private_key: privateKey | 163 private_key: privateKey |
164 }); | 164 }); |
165 /** @param {remoting.HostController.AsyncResult} result */ | 165 /** @param {remoting.HostController.AsyncResult} result */ |
166 var onStartDaemon = function(result) { | 166 var onStartDaemon = function(result) { |
167 onStarted(callback, result, hostName); | 167 onStarted(callback, result, hostName); |
168 }; | 168 }; |
169 that.plugin_.startDaemon(hostConfig, onStartDaemon); | 169 that.plugin_.startDaemon(hostConfig, onStartDaemon); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 | 210 |
211 this.plugin_.generateKeyPair(onKeyGenerated); | 211 this.plugin_.generateKeyPair(onKeyGenerated); |
212 }; | 212 }; |
213 | 213 |
214 /** | 214 /** |
215 * Stop the daemon process. | 215 * Stop the daemon process. |
216 * @param {function(remoting.HostController.AsyncResult):void} callback | 216 * @param {function(remoting.HostController.AsyncResult):void} callback |
217 * Callback to be called when finished. | 217 * Callback to be called when finished. |
218 * @return {void} Nothing. | 218 * @return {void} Nothing. |
219 */ | 219 */ |
220 remoting.HostController.prototype.stop = function(callback) { | 220 remoting.HostController.prototype.stop = function(callback) { |
Jamie
2012/04/16 17:04:45
I think we can mark the token as revokable again h
simonmorris
2012/04/16 22:37:51
I see what you mean, but the claim that that's saf
| |
221 /** @type {remoting.HostController} */ | 221 /** @type {remoting.HostController} */ |
222 var that = this; | 222 var that = this; |
223 | 223 |
224 /** @param {remoting.HostController.AsyncResult} result */ | 224 /** @param {remoting.HostController.AsyncResult} result */ |
225 function onStopped(result) { | 225 function onStopped(result) { |
226 if (that.localHost && that.localHost.hostId) | 226 if (that.localHost && that.localHost.hostId) |
227 remoting.HostList.unregisterHostById(that.localHost.hostId); | 227 remoting.HostList.unregisterHostById(that.localHost.hostId); |
228 window.localStorage.removeItem('me2me-host-id'); | 228 window.localStorage.removeItem('me2me-host-id'); |
229 callback(result); | 229 callback(result); |
230 }; | 230 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 if (hostId && typeof(hostId) == 'string') { | 308 if (hostId && typeof(hostId) == 'string') { |
309 this.setHost(hostList.getHostForId(/** @type{string} */(hostId))); | 309 this.setHost(hostList.getHostForId(/** @type{string} */(hostId))); |
310 } else { | 310 } else { |
311 this.setHost(null); | 311 this.setHost(null); |
312 } | 312 } |
313 onDone(); | 313 onDone(); |
314 }; | 314 }; |
315 | 315 |
316 /** @type {remoting.HostController} */ | 316 /** @type {remoting.HostController} */ |
317 remoting.hostController = null; | 317 remoting.hostController = null; |
OLD | NEW |