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 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 * Returns whether or not IT2Me is supported via the host NPAPI plugin. | 172 * Returns whether or not IT2Me is supported via the host NPAPI plugin. |
173 * | 173 * |
174 * @return {boolean} | 174 * @return {boolean} |
175 */ | 175 */ |
176 function isIT2MeSupported_() { | 176 function isIT2MeSupported_() { |
177 // Currently, IT2Me on Chromebooks is not supported. | 177 // Currently, IT2Me on Chromebooks is not supported. |
178 return !remoting.runningOnChromeOS(); | 178 return !remoting.runningOnChromeOS(); |
179 } | 179 } |
180 | 180 |
181 /** | 181 /** |
| 182 * Create an instance of the NPAPI plugin. |
| 183 * @param {Element} container The element to add the plugin to. |
| 184 * @return {remoting.HostPlugin} The new plugin instance or null if it failed to |
| 185 * load. |
| 186 */ |
| 187 remoting.createNpapiPlugin = function(container) { |
| 188 var plugin = document.createElement('embed'); |
| 189 plugin.type = remoting.settings.PLUGIN_MIMETYPE; |
| 190 // Hiding the plugin means it doesn't load, so make it size zero instead. |
| 191 plugin.width = 0; |
| 192 plugin.height = 0; |
| 193 |
| 194 // Verify if the plugin was loaded successfully. |
| 195 if (plugin.hasOwnProperty('REQUESTED_ACCESS_CODE')) { |
| 196 container.appendChild(plugin); |
| 197 return /** @type {remoting.HostPlugin} */ (plugin); |
| 198 } |
| 199 |
| 200 return null; |
| 201 }; |
| 202 |
| 203 /** |
182 * Returns true if the current platform is fully supported. It's only used when | 204 * Returns true if the current platform is fully supported. It's only used when |
183 * we detect that host native messaging components are not installed. In that | 205 * we detect that host native messaging components are not installed. In that |
184 * case the result of this function determines if the webapp should show the | 206 * case the result of this function determines if the webapp should show the |
185 * controls that allow to install and enable Me2Me host. | 207 * controls that allow to install and enable Me2Me host. |
186 * | 208 * |
187 * @return {boolean} | 209 * @return {boolean} |
188 */ | 210 */ |
189 remoting.isMe2MeInstallable = function() { | 211 remoting.isMe2MeInstallable = function() { |
190 /** @type {string} */ | 212 /** @type {string} */ |
191 var platform = navigator.platform; | 213 var platform = navigator.platform; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 /** | 528 /** |
507 * Generate a nonce, to be used as an xsrf protection token. | 529 * Generate a nonce, to be used as an xsrf protection token. |
508 * | 530 * |
509 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ | 531 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ |
510 remoting.generateXsrfToken = function() { | 532 remoting.generateXsrfToken = function() { |
511 var random = new Uint8Array(16); | 533 var random = new Uint8Array(16); |
512 window.crypto.getRandomValues(random); | 534 window.crypto.getRandomValues(random); |
513 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); | 535 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
514 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | 536 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
515 }; | 537 }; |
OLD | NEW |