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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 var error; | 215 var error; |
216 if (remoting.ClientSession.ConnectionError.hasOwnProperty( | 216 if (remoting.ClientSession.ConnectionError.hasOwnProperty( |
217 message.data['error'])) { | 217 message.data['error'])) { |
218 error = /** @type {remoting.ClientSession.ConnectionError} */ | 218 error = /** @type {remoting.ClientSession.ConnectionError} */ |
219 remoting.ClientSession.ConnectionError[message.data['error']]; | 219 remoting.ClientSession.ConnectionError[message.data['error']]; |
220 } else { | 220 } else { |
221 error = remoting.ClientSession.ConnectionError.UNKNOWN; | 221 error = remoting.ClientSession.ConnectionError.UNKNOWN; |
222 } | 222 } |
223 | 223 |
224 this.onConnectionStatusUpdateHandler(state, error); | 224 this.onConnectionStatusUpdateHandler(state, error); |
225 } else if (message.method == 'onRouteChanged') { | |
Sergey Ulanov
2014/01/07 22:58:43
Instead of adding another message type can we send
Jamie
2014/01/08 11:39:34
I've changed it to use logDebugMessage.
| |
226 var channel = /** @type {string} */ (message.data['channel']); | |
227 var type = /** @type {string} */ (message.data['type']); | |
228 if (typeof channel != 'string' || typeof type != 'string') { | |
229 console.error('Received invalid onRouteChanged message: ' + messageStr); | |
230 return; | |
231 } | |
232 this.perfStats_.channelTypes[channel] = type; | |
225 } else if (message.method == 'onDesktopSize') { | 233 } else if (message.method == 'onDesktopSize') { |
226 if (typeof message.data['width'] != 'number' || | 234 if (typeof message.data['width'] != 'number' || |
227 typeof message.data['height'] != 'number') { | 235 typeof message.data['height'] != 'number') { |
228 console.error('Received invalid onDesktopSize message: ' + messageStr); | 236 console.error('Received invalid onDesktopSize message: ' + messageStr); |
229 return; | 237 return; |
230 } | 238 } |
231 this.desktopWidth = /** @type {number} */ message.data['width']; | 239 this.desktopWidth = /** @type {number} */ message.data['width']; |
232 this.desktopHeight = /** @type {number} */ message.data['height']; | 240 this.desktopHeight = /** @type {number} */ message.data['height']; |
233 this.desktopXDpi = (typeof message.data['x_dpi'] == 'number') ? | 241 this.desktopXDpi = (typeof message.data['x_dpi'] == 'number') ? |
234 /** @type {number} */ (message.data['x_dpi']) : 96; | 242 /** @type {number} */ (message.data['x_dpi']) : 96; |
235 this.desktopYDpi = (typeof message.data['y_dpi'] == 'number') ? | 243 this.desktopYDpi = (typeof message.data['y_dpi'] == 'number') ? |
236 /** @type {number} */ (message.data['y_dpi']) : 96; | 244 /** @type {number} */ (message.data['y_dpi']) : 96; |
237 this.onDesktopSizeUpdateHandler(); | 245 this.onDesktopSizeUpdateHandler(); |
238 } else if (message.method == 'onPerfStats') { | 246 } else if (message.method == 'onPerfStats') { |
239 if (typeof message.data['videoBandwidth'] != 'number' || | 247 var properties = [ |
240 typeof message.data['videoFrameRate'] != 'number' || | 248 'videoBandwidth', |
241 typeof message.data['captureLatency'] != 'number' || | 249 'videoFrameRate', |
242 typeof message.data['encodeLatency'] != 'number' || | 250 'captureLatency', |
243 typeof message.data['decodeLatency'] != 'number' || | 251 'encodeLatency', |
244 typeof message.data['renderLatency'] != 'number' || | 252 'decodeLatency', |
245 typeof message.data['roundtripLatency'] != 'number') { | 253 'renderLatency', |
246 console.error('Received incorrect onPerfStats message: ' + messageStr); | 254 'roundtripLatency' |
247 return; | 255 ]; |
256 for (var i = 0; i < properties.length; ++i) { | |
257 if (typeof message.data[properties[i]] != 'number') { | |
258 console.error('Received incorrect onPerfStats message: ' + messageStr); | |
259 return; | |
260 } | |
248 } | 261 } |
249 this.perfStats_ = | 262 for (var i = 0; i < properties.length; ++i) { |
250 /** @type {remoting.ClientSession.PerfStats} */ message.data; | 263 this.perfStats_[properties[i]] = message.data[properties[i]]; |
264 } | |
251 } else if (message.method == 'injectClipboardItem') { | 265 } else if (message.method == 'injectClipboardItem') { |
252 if (typeof message.data['mimeType'] != 'string' || | 266 if (typeof message.data['mimeType'] != 'string' || |
253 typeof message.data['item'] != 'string') { | 267 typeof message.data['item'] != 'string') { |
254 console.error('Received incorrect injectClipboardItem message.'); | 268 console.error('Received incorrect injectClipboardItem message.'); |
255 return; | 269 return; |
256 } | 270 } |
257 if (remoting.clipboard) { | 271 if (remoting.clipboard) { |
258 remoting.clipboard.fromHost(message.data['mimeType'], | 272 remoting.clipboard.fromHost(message.data['mimeType'], |
259 message.data['item']); | 273 message.data['item']); |
260 } | 274 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 this.plugin.width = width; | 659 this.plugin.width = width; |
646 this.plugin.height = height; | 660 this.plugin.height = height; |
647 // Center the plugin just underneath the "Connnecting..." dialog. | 661 // Center the plugin just underneath the "Connnecting..." dialog. |
648 var parentNode = this.plugin.parentNode; | 662 var parentNode = this.plugin.parentNode; |
649 var dialog = document.getElementById('client-dialog'); | 663 var dialog = document.getElementById('client-dialog'); |
650 var dialogRect = dialog.getBoundingClientRect(); | 664 var dialogRect = dialog.getBoundingClientRect(); |
651 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; | 665 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; |
652 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; | 666 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; |
653 } | 667 } |
654 }; | 668 }; |
OLD | NEW |