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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Class that wraps low-level details of interacting with the client plugin. | 7 * Class that wraps low-level details of interacting with the client plugin. |
8 * | 8 * |
9 * This abstracts a <embed> element and controls the plugin which does | 9 * This abstracts a <embed> element and controls the plugin which does |
10 * the actual remoting work. It also handles differences between | 10 * the actual remoting work. It also handles differences between |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 }; | 285 }; |
286 | 286 |
287 /** | 287 /** |
288 * @param {string|{method:string, data:Object.<string,*>}} | 288 * @param {string|{method:string, data:Object.<string,*>}} |
289 * rawMessage Message from the plugin. | 289 * rawMessage Message from the plugin. |
290 * @private | 290 * @private |
291 */ | 291 */ |
292 remoting.ClientPluginImpl.prototype.handleMessage_ = function(rawMessage) { | 292 remoting.ClientPluginImpl.prototype.handleMessage_ = function(rawMessage) { |
293 var message = | 293 var message = |
294 /** @type {{method:string, data:Object.<string,*>}} */ | 294 /** @type {{method:string, data:Object.<string,*>}} */ |
295 ((typeof(rawMessage) == 'string') ? jsonParseSafe(rawMessage) | 295 ((typeof(rawMessage) == 'string') ? base.jsonParseSafe(rawMessage) |
296 : rawMessage); | 296 : rawMessage); |
297 if (!message || !('method' in message) || !('data' in message)) { | 297 if (!message || !('method' in message) || !('data' in message)) { |
298 console.error('Received invalid message from the plugin:', rawMessage); | 298 console.error('Received invalid message from the plugin:', rawMessage); |
299 return; | 299 return; |
300 } | 300 } |
301 | 301 |
302 try { | 302 try { |
303 this.handleMessageMethod_(message); | 303 this.handleMessageMethod_(message); |
304 } catch(e) { | 304 } catch(e) { |
305 console.error(/** @type {*} */ (e)); | 305 console.error(/** @type {*} */ (e)); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 remoting.DefaultClientPluginFactory.prototype.preloadPlugin = function() { | 961 remoting.DefaultClientPluginFactory.prototype.preloadPlugin = function() { |
962 if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') { | 962 if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') { |
963 return; | 963 return; |
964 } | 964 } |
965 | 965 |
966 var plugin = remoting.ClientPluginImpl.createPluginElement_(); | 966 var plugin = remoting.ClientPluginImpl.createPluginElement_(); |
967 plugin.addEventListener( | 967 plugin.addEventListener( |
968 'loadend', function() { document.body.removeChild(plugin); }, false); | 968 'loadend', function() { document.body.removeChild(plugin); }, false); |
969 document.body.appendChild(plugin); | 969 document.body.appendChild(plugin); |
970 }; | 970 }; |
OLD | NEW |