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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 /** @param {string} publicKey | 137 /** @param {string} publicKey |
138 * @param {string} privateKey | 138 * @param {string} privateKey |
139 * @param {XMLHttpRequest} xhr */ | 139 * @param {XMLHttpRequest} xhr */ |
140 function onRegistered(publicKey, privateKey, xhr) { | 140 function onRegistered(publicKey, privateKey, xhr) { |
141 var success = (xhr.status == 200); | 141 var success = (xhr.status == 200); |
142 | 142 |
143 if (success) { | 143 if (success) { |
144 var hostSecretHash = | 144 var hostSecretHash = |
145 that.plugin_.getPinHash(newHostId, hostPin); | 145 that.plugin_.getPinHash(newHostId, hostPin); |
146 var hostConfig = JSON.stringify({ | 146 var hostConfig = JSON.stringify({ |
147 xmpp_login: remoting.oauth2.getCachedEmail(), | 147 xmpp_login: remoting.identity.getCachedEmail(), |
148 oauth_refresh_token: remoting.oauth2.exportRefreshToken(), | 148 oauth_refresh_token: remoting.oauth2.exportRefreshToken(), |
149 host_id: newHostId, | 149 host_id: newHostId, |
150 host_name: hostName, | 150 host_name: hostName, |
151 host_secret_hash: hostSecretHash, | 151 host_secret_hash: hostSecretHash, |
152 private_key: privateKey | 152 private_key: privateKey |
153 }); | 153 }); |
154 /** @param {remoting.HostController.AsyncResult} result */ | 154 /** @param {remoting.HostController.AsyncResult} result */ |
155 var onStartDaemon = function(result) { | 155 var onStartDaemon = function(result) { |
156 onStarted(callback, result, hostName, publicKey); | 156 onStarted(callback, result, hostName, publicKey); |
157 }; | 157 }; |
(...skipping 25 matching lines...) Expand all Loading... |
183 'https://www.googleapis.com/chromoting/v1/@me/hosts/', | 183 'https://www.googleapis.com/chromoting/v1/@me/hosts/', |
184 /** @param {XMLHttpRequest} xhr */ | 184 /** @param {XMLHttpRequest} xhr */ |
185 function (xhr) { onRegistered(publicKey, privateKey, xhr); }, | 185 function (xhr) { onRegistered(publicKey, privateKey, xhr); }, |
186 JSON.stringify(newHostDetails), | 186 JSON.stringify(newHostDetails), |
187 headers); | 187 headers); |
188 }; | 188 }; |
189 | 189 |
190 /** @param {string} privateKey | 190 /** @param {string} privateKey |
191 * @param {string} publicKey */ | 191 * @param {string} publicKey */ |
192 function onKeyGenerated(privateKey, publicKey) { | 192 function onKeyGenerated(privateKey, publicKey) { |
193 remoting.oauth2.callWithToken( | 193 remoting.identity.callWithToken( |
194 /** @param {string} oauthToken */ | 194 /** @param {string} oauthToken */ |
195 function(oauthToken) { | 195 function(oauthToken) { |
196 doRegisterHost(privateKey, publicKey, oauthToken); | 196 doRegisterHost(privateKey, publicKey, oauthToken); |
197 }, | 197 }, |
198 /** @param {remoting.Error} error */ | 198 /** @param {remoting.Error} error */ |
199 function(error) { | 199 function(error) { |
200 // TODO(jamiewalch): Have a more specific error code here? | 200 // TODO(jamiewalch): Have a more specific error code here? |
201 callback(remoting.HostController.AsyncResult.FAILED); | 201 callback(remoting.HostController.AsyncResult.FAILED); |
202 }); | 202 }); |
203 }; | 203 }; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 }; | 311 }; |
312 try { | 312 try { |
313 this.plugin_.getDaemonConfig(onConfig); | 313 this.plugin_.getDaemonConfig(onConfig); |
314 } catch (err) { | 314 } catch (err) { |
315 onDone(remoting.HostController.State.NOT_IMPLEMENTED, null); | 315 onDone(remoting.HostController.State.NOT_IMPLEMENTED, null); |
316 } | 316 } |
317 }; | 317 }; |
318 | 318 |
319 /** @type {remoting.HostController} */ | 319 /** @type {remoting.HostController} */ |
320 remoting.hostController = null; | 320 remoting.hostController = null; |
OLD | NEW |