Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: remoting/webapp/client_plugin_async.js

Issue 10221021: Protect all uses of JSON.parse against exceptions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Log errors if JSON parsing fails. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/webapp/client_screen.js » ('j') | remoting/webapp/host_list.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(message_str) {
Wez 2012/04/28 00:00:42 cleanup: message_str -> messageStr
Jamie 2012/04/28 00:15:41 Done.
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(message_str);
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
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 };
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/client_screen.js » ('j') | remoting/webapp/host_list.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698