Chromium Code Reviews| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 | 266 |
| 267 /** | 267 /** |
| 268 * @param {string} hostName | 268 * @param {string} hostName |
| 269 * @param {string} privateKey | 269 * @param {string} privateKey |
| 270 * @param {string} publicKey | 270 * @param {string} publicKey |
| 271 * @param {?string} hostClientId | 271 * @param {?string} hostClientId |
| 272 * @param {string} oauthToken | 272 * @param {string} oauthToken |
| 273 */ | 273 */ |
| 274 function doRegisterHost( | 274 function doRegisterHost( |
| 275 hostName, privateKey, publicKey, hostClientId, oauthToken) { | 275 hostName, privateKey, publicKey, hostClientId, oauthToken) { |
| 276 var headers = { | |
| 277 'Authorization': 'OAuth ' + oauthToken, | |
| 278 'Content-type' : 'application/json; charset=UTF-8' | |
| 279 }; | |
| 280 | |
| 281 var newHostDetails = { data: { | 276 var newHostDetails = { data: { |
| 282 hostId: newHostId, | 277 hostId: newHostId, |
| 283 hostName: hostName, | 278 hostName: hostName, |
| 284 publicKey: publicKey | 279 publicKey: publicKey |
| 285 } }; | 280 } }; |
| 286 | 281 |
| 287 var registerHostUrl = | 282 var registerHostUrl = |
| 288 remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts'; | 283 remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts'; |
| 289 | 284 |
| 290 if (hostClientId) { | 285 remoting.xhr.start({ |
|
Jamie
2015/02/21 01:35:48
You've deleted this conditional. Was that intentio
John Williams
2015/02/23 23:00:55
Yes. The new version automagically omits URL param
| |
| 291 registerHostUrl += '?' + remoting.xhr.urlencodeParamHash( | 286 method: 'POST', |
| 292 { hostClientId: hostClientId }); | 287 url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts', |
| 293 } | 288 urlParams: { |
| 294 | 289 hostClientId: hostClientId |
| 295 remoting.xhr.post( | 290 }, |
| 296 registerHostUrl, | 291 onDone: onRegistered.bind(null, hostName, publicKey, privateKey), |
| 297 onRegistered.bind(null, hostName, publicKey, privateKey), | 292 jsonContent: newHostDetails, |
| 298 JSON.stringify(newHostDetails), | 293 oauthToken: oauthToken |
| 299 headers); | 294 }); |
| 300 } | 295 } |
| 301 | 296 |
| 302 /** | 297 /** |
| 303 * @param {string} hostName | 298 * @param {string} hostName |
| 304 * @param {string} privateKey | 299 * @param {string} privateKey |
| 305 * @param {string} publicKey | 300 * @param {string} publicKey |
| 306 * @param {string} hostClientId | 301 * @param {string} hostClientId |
| 307 */ | 302 */ |
| 308 function onHostClientId( | 303 function onHostClientId( |
| 309 hostName, privateKey, publicKey, hostClientId) { | 304 hostName, privateKey, publicKey, hostClientId) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 function connectSignalingWithTokenAndEmail(token, email) { | 565 function connectSignalingWithTokenAndEmail(token, email) { |
| 571 signalStrategy.connect( | 566 signalStrategy.connect( |
| 572 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); | 567 remoting.settings.XMPP_SERVER_FOR_CLIENT, email, token); |
| 573 } | 568 } |
| 574 | 569 |
| 575 remoting.identity.callWithToken(connectSignalingWithToken, onError); | 570 remoting.identity.callWithToken(connectSignalingWithToken, onError); |
| 576 }; | 571 }; |
| 577 | 572 |
| 578 /** @type {remoting.HostController} */ | 573 /** @type {remoting.HostController} */ |
| 579 remoting.hostController = null; | 574 remoting.hostController = null; |
| OLD | NEW |