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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 * compatibility with older API versions. | 80 * compatibility with older API versions. |
81 * | 81 * |
82 * @const | 82 * @const |
83 * @private | 83 * @private |
84 */ | 84 */ |
85 remoting.ClientPluginAsync.prototype.API_MIN_VERSION_ = 5; | 85 remoting.ClientPluginAsync.prototype.API_MIN_VERSION_ = 5; |
86 | 86 |
87 /** | 87 /** |
88 * @param {string} message_str Message from the plugin. | 88 * @param {string} message_str Message from the plugin. |
89 */ | 89 */ |
90 remoting.ClientPluginAsync.prototype.handleMessage_ = function(message_str) { | 90 remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) { |
91 var message = /** @type {{method:string, data:Object.<string,string>}} */ | 91 var message = /** @type {{method:string, data:Object.<string,string>}} */ |
92 JSON.parse(message_str); | 92 jsonParseSafe(messageStr); |
93 | 93 |
94 if (!('method' in message) || !('data' in message)) { | 94 if (!message || !('method' in message) || !('data' in message)) { |
95 console.error('Received invalid message from the plugin: ' + message_str); | 95 console.error('Received invalid message from the plugin: ' + message_str); |
96 return; | 96 return; |
97 } | 97 } |
98 | 98 |
99 if (message.method == 'hello') { | 99 if (message.method == 'hello') { |
100 // Reset the size in case we had to enlarge it to support click-to-play. | 100 // Reset the size in case we had to enlarge it to support click-to-play. |
101 this.plugin.width = 0; | 101 this.plugin.width = 0; |
102 this.plugin.height = 0; | 102 this.plugin.height = 0; |
103 if (typeof message.data['apiVersion'] != 'number' || | 103 if (typeof message.data['apiVersion'] != 'number' || |
104 typeof message.data['apiMinVersion'] != 'number') { | 104 typeof message.data['apiMinVersion'] != 'number') { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 this.plugin.width = width; | 377 this.plugin.width = width; |
378 this.plugin.height = height; | 378 this.plugin.height = height; |
379 // Center the plugin just underneath the "Connnecting..." dialog. | 379 // Center the plugin just underneath the "Connnecting..." dialog. |
380 var parentNode = this.plugin.parentNode; | 380 var parentNode = this.plugin.parentNode; |
381 var dialog = document.getElementById('client-dialog'); | 381 var dialog = document.getElementById('client-dialog'); |
382 var dialogRect = dialog.getBoundingClientRect(); | 382 var dialogRect = dialog.getBoundingClientRect(); |
383 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; | 383 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; |
384 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; | 384 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; |
385 } | 385 } |
386 }; | 386 }; |
OLD | NEW |