OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 /** | 7 /** |
8 * @type {string} The host id corresponding to the user's VM. The @pending | 8 * @type {string} The host id corresponding to the user's VM. The @pending |
9 * place-holder instructs the Orchestrator to abandon any pending host, | 9 * place-holder instructs the Orchestrator to abandon any pending host, |
10 * and is used if no host id is provided by the main window. | 10 * and is used if no host id is provided by the main window. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 var idArray = new Uint8Array(20); | 104 var idArray = new Uint8Array(20); |
105 crypto.getRandomValues(idArray); | 105 crypto.getRandomValues(idArray); |
106 return btoa(String.fromCharCode.apply(null, idArray)); | 106 return btoa(String.fromCharCode.apply(null, idArray)); |
107 } | 107 } |
108 | 108 |
109 /** | 109 /** |
110 * @param {string} token | 110 * @param {string} token |
111 */ | 111 */ |
112 function onToken(token) { | 112 function onToken(token) { |
113 var getUserInfo = function() { | 113 var getUserInfo = function() { |
114 remoting.OAuth2Api.getUserInfo( | 114 var oauth2Api = new remoting.OAuth2ApiImpl(); |
| 115 oauth2Api.getUserInfo( |
115 onUserInfo, onUserInfo.bind(null, 'unknown', 'unknown'), token); | 116 onUserInfo, onUserInfo.bind(null, 'unknown', 'unknown'), token); |
116 }; | 117 }; |
117 if (!token) { | 118 if (!token) { |
118 onUserInfo('unknown', 'unknown'); | 119 onUserInfo('unknown', 'unknown'); |
119 } else { | 120 } else { |
120 if (abandonHost == 'yes') { | 121 if (abandonHost == 'yes') { |
121 var body = { | 122 var body = { |
122 'abandonHost': 'true', | 123 'abandonHost': 'true', |
123 'crashServiceReportId': crashServiceReportId | 124 'crashServiceReportId': crashServiceReportId |
124 }; | 125 }; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 var method = /** @type {string} */ (event.data['method']); | 221 var method = /** @type {string} */ (event.data['method']); |
221 if (method == 'init') { | 222 if (method == 'init') { |
222 if (event.data['hostId']) { | 223 if (event.data['hostId']) { |
223 hostId = /** @type {string} */ (event.data['hostId']); | 224 hostId = /** @type {string} */ (event.data['hostId']); |
224 } | 225 } |
225 connectionStats = /** @type {string} */ (event.data['connectionStats']); | 226 connectionStats = /** @type {string} */ (event.data['connectionStats']); |
226 } | 227 } |
227 }; | 228 }; |
228 | 229 |
229 window.addEventListener('load', onLoad, false); | 230 window.addEventListener('load', onLoad, false); |
OLD | NEW |