| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 Description of this file. | 6 * @fileoverview Description of this file. |
| 7 * Class handling interaction with the cast extension session of the Chromoting | 7 * Class handling interaction with the cast extension session of the Chromoting |
| 8 * host. It receives and sends extension messages from/to the host through | 8 * host. It receives and sends extension messages from/to the host through |
| 9 * the client session. It uses the Google Cast Chrome Sender API library to | 9 * the client session. It uses the Google Cast Chrome Sender API library to |
| 10 * interact with nearby Cast receivers. | 10 * interact with nearby Cast receivers. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 node.addEventListener('load', onLoad, false); | 87 node.addEventListener('load', onLoad, false); |
| 88 node.addEventListener('error', onLoadError, false); | 88 node.addEventListener('error', onLoadError, false); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Process Cast Extension Messages from the Chromoting host. | 92 * Process Cast Extension Messages from the Chromoting host. |
| 93 * @param {string} msgString The extension message's data. | 93 * @param {string} msgString The extension message's data. |
| 94 */ | 94 */ |
| 95 remoting.CastExtensionHandler.prototype.onMessage = function(msgString) { | 95 remoting.CastExtensionHandler.prototype.onMessage = function(msgString) { |
| 96 var message = getJsonObjectFromString(msgString); | 96 var message = base.getJsonObjectFromString(msgString); |
| 97 | 97 |
| 98 // Save messages to send after a session is established. | 98 // Save messages to send after a session is established. |
| 99 this.messageQueue_.push(message); | 99 this.messageQueue_.push(message); |
| 100 // Trigger the sending of pending messages, followed by the one just | 100 // Trigger the sending of pending messages, followed by the one just |
| 101 // received. | 101 // received. |
| 102 if (this.session_) { | 102 if (this.session_) { |
| 103 this.sendPendingMessages_(); | 103 this.sendPendingMessages_(); |
| 104 } | 104 } |
| 105 }; | 105 }; |
| 106 | 106 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 /** | 236 /** |
| 237 * Listener invoked when a cast extension message is received from the Cast | 237 * Listener invoked when a cast extension message is received from the Cast |
| 238 * device. | 238 * device. |
| 239 * @param {string} ns The namespace of the message received. | 239 * @param {string} ns The namespace of the message received. |
| 240 * @param {string} message The stringified JSON message received. | 240 * @param {string} message The stringified JSON message received. |
| 241 */ | 241 */ |
| 242 remoting.CastExtensionHandler.prototype.chromotingMessageListener = | 242 remoting.CastExtensionHandler.prototype.chromotingMessageListener = |
| 243 function(ns, message) { | 243 function(ns, message) { |
| 244 if (ns === this.kCastNamespace_) { | 244 if (ns === this.kCastNamespace_) { |
| 245 try { | 245 try { |
| 246 var messageObj = getJsonObjectFromString(message); | 246 var messageObj = base.getJsonObjectFromString(message); |
| 247 this.sendMessageToHost_(messageObj); | 247 this.sendMessageToHost_(messageObj); |
| 248 } catch (err) { | 248 } catch (err) { |
| 249 console.error('Failed to process message from Cast device.'); | 249 console.error('Failed to process message from Cast device.'); |
| 250 } | 250 } |
| 251 } else { | 251 } else { |
| 252 console.error("Unexpected message from Cast device."); | 252 console.error("Unexpected message from Cast device."); |
| 253 } | 253 } |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 /** | 256 /** |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 }; | 338 }; |
| 339 | 339 |
| 340 /** | 340 /** |
| 341 * Listener invoked when we fail to stop the receiver application. | 341 * Listener invoked when we fail to stop the receiver application. |
| 342 * | 342 * |
| 343 * @param {chrome.cast.Error} error The error code. | 343 * @param {chrome.cast.Error} error The error code. |
| 344 */ | 344 */ |
| 345 remoting.CastExtensionHandler.prototype.onStopAppError = function(error) { | 345 remoting.CastExtensionHandler.prototype.onStopAppError = function(error) { |
| 346 console.error('Error Stopping App: ', error); | 346 console.error('Error Stopping App: ', error); |
| 347 }; | 347 }; |
| OLD | NEW |