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 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 * @param {Element} container The element to add the plugin to. | 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 | 184 * @return {remoting.HostPlugin} The new plugin instance or null if it failed to |
| 185 * load. | 185 * load. |
| 186 */ | 186 */ |
| 187 remoting.createNpapiPlugin = function(container) { | 187 remoting.createNpapiPlugin = function(container) { |
| 188 var plugin = document.createElement('embed'); | 188 var plugin = document.createElement('embed'); |
| 189 plugin.type = remoting.settings.PLUGIN_MIMETYPE; | 189 plugin.type = remoting.settings.PLUGIN_MIMETYPE; |
| 190 // Hiding the plugin means it doesn't load, so make it size zero instead. | 190 // Hiding the plugin means it doesn't load, so make it size zero instead. |
| 191 plugin.width = 0; | 191 plugin.width = 0; |
| 192 plugin.height = 0; | 192 plugin.height = 0; |
| 193 container.appendChild(plugin); | |
| 194 | 193 |
| 195 // Verify if the plugin was loaded successfully. | 194 // Verify if the plugin was loaded successfully. |
| 196 if (!plugin.hasOwnProperty('REQUESTED_ACCESS_CODE')) { | 195 if (plugin.hasOwnProperty('REQUESTED_ACCESS_CODE')) { |
|
Sergey Ulanov
2014/05/24 01:50:34
Plugins are not loaded until they are added to DOM
| |
| 197 container.removeChild(plugin); | 196 container.appendChild(plugin); |
| 198 return null; | 197 return /** @type {remoting.HostPlugin} */ (plugin); |
| 199 } | 198 } |
| 200 | 199 |
| 201 return /** @type {remoting.HostPlugin} */ (plugin); | 200 return null; |
| 202 }; | 201 }; |
| 203 | 202 |
| 204 /** | 203 /** |
| 205 * 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 |
| 206 * 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 |
| 207 * 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 |
| 208 * controls that allow to install and enable Me2Me host. | 207 * controls that allow to install and enable Me2Me host. |
| 209 * | 208 * |
| 210 * @return {boolean} | 209 * @return {boolean} |
| 211 */ | 210 */ |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 529 /** | 528 /** |
| 530 * Generate a nonce, to be used as an xsrf protection token. | 529 * Generate a nonce, to be used as an xsrf protection token. |
| 531 * | 530 * |
| 532 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ | 531 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ |
| 533 remoting.generateXsrfToken = function() { | 532 remoting.generateXsrfToken = function() { |
| 534 var random = new Uint8Array(16); | 533 var random = new Uint8Array(16); |
| 535 window.crypto.getRandomValues(random); | 534 window.crypto.getRandomValues(random); |
| 536 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); | 535 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
| 537 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | 536 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
| 538 }; | 537 }; |
| OLD | NEW |