summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamiewalch <jamiewalch@chromium.org>2014-11-07 14:59:15 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-07 22:59:39 +0000
commitd2b979e70f16a7fbc398add5133c7cee90dd596d (patch)
tree44ec21af179b6ca0a457f85bd44a2bfb2207097a
parentc332de7c1838b85e27685bed6c376c36ccb17287 (diff)
downloadchromium_src-d2b979e70f16a7fbc398add5133c7cee90dd596d.zip
chromium_src-d2b979e70f16a7fbc398add5133c7cee90dd596d.tar.gz
chromium_src-d2b979e70f16a7fbc398add5133c7cee90dd596d.tar.bz2
Use a dedicated message to inform the web-app of the connection type.
I originally implemented this by parsing the log message because I thought we needed to support old plugins. However, since we only need this for the v2 app for now, which uses NaCl, there's no reason not to do it properly. Review URL: https://codereview.chromium.org/683713003 Cr-Commit-Position: refs/heads/master@{#303316}
-rw-r--r--remoting/client/plugin/chromoting_instance.cc8
-rw-r--r--remoting/webapp/browser_test/mock_client_plugin.js3
-rw-r--r--remoting/webapp/crd/js/client_plugin.js7
-rw-r--r--remoting/webapp/crd/js/client_plugin_impl.js22
-rw-r--r--remoting/webapp/crd/js/client_session.js21
5 files changed, 51 insertions, 10 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 379b879..36046c0 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -485,10 +485,10 @@ void ChromotingInstance::OnConnectionReady(bool ready) {
void ChromotingInstance::OnRouteChanged(const std::string& channel_name,
const protocol::TransportRoute& route) {
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
- std::string message = "Channel " + channel_name + " using " +
- protocol::TransportRoute::GetTypeString(route.type) + " connection.";
- data->SetString("message", message);
- PostLegacyJsonMessage("logDebugMessage", data.Pass());
+ data->SetString("channel", channel_name);
+ data->SetString("connectionType",
+ protocol::TransportRoute::GetTypeString(route.type));
+ PostLegacyJsonMessage("onRouteChanged", data.Pass());
}
void ChromotingInstance::SetCapabilities(const std::string& capabilities) {
diff --git a/remoting/webapp/browser_test/mock_client_plugin.js b/remoting/webapp/browser_test/mock_client_plugin.js
index dfe0ffe..6a7cba3 100644
--- a/remoting/webapp/browser_test/mock_client_plugin.js
+++ b/remoting/webapp/browser_test/mock_client_plugin.js
@@ -143,6 +143,9 @@ remoting.MockClientPlugin.prototype.setConnectionStatusUpdateHandler =
this.connectionStatusUpdateHandler_ = handler;
};
+remoting.MockClientPlugin.prototype.setRouteChangedHandler =
+ function(handler) {};
+
remoting.MockClientPlugin.prototype.setConnectionReadyHandler =
function(handler) {};
diff --git a/remoting/webapp/crd/js/client_plugin.js b/remoting/webapp/crd/js/client_plugin.js
index 106fc78..beeab42 100644
--- a/remoting/webapp/crd/js/client_plugin.js
+++ b/remoting/webapp/crd/js/client_plugin.js
@@ -205,6 +205,13 @@ remoting.ClientPlugin.prototype.setConnectionStatusUpdateHandler =
function(handler) {};
/**
+ * @param {function(string, string):void} handler Callback for route-change
+ * notifications. The first parameter is the channel name, and the second
+ * is the connection type.
+ */
+remoting.ClientPlugin.prototype.setRouteChangedHandler = function(handler) {};
+
+/**
* @param {function(boolean):void} handler Callback for connection readiness
* notifications.
*/
diff --git a/remoting/webapp/crd/js/client_plugin_impl.js b/remoting/webapp/crd/js/client_plugin_impl.js
index 867fc51..6490f7e 100644
--- a/remoting/webapp/crd/js/client_plugin_impl.js
+++ b/remoting/webapp/crd/js/client_plugin_impl.js
@@ -56,6 +56,14 @@ remoting.ClientPluginImpl = function(container, onExtensionMessage) {
* @private
*/
this.onConnectionStatusUpdateHandler_ = function(state, error) {};
+
+ /**
+ * @param {string} channel The channel name.
+ * @param {string} connectionType The connection type.
+ * @private
+ */
+ this.onRouteChangedHandler_ = function(channel, connectionType) {};
+
/**
* @param {boolean} ready Connection ready state.
* @private
@@ -225,6 +233,13 @@ remoting.ClientPluginImpl.prototype.setConnectionStatusUpdateHandler =
};
/**
+ * @param {function(string, string):void} handler
+ */
+remoting.ClientPluginImpl.prototype.setRouteChangedHandler = function(handler) {
+ this.onRouteChangedHandler_ = handler;
+};
+
+/**
* @param {function(boolean):void} handler
*/
remoting.ClientPluginImpl.prototype.setConnectionReadyHandler =
@@ -394,11 +409,16 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) {
} else if (message.method == 'onConnectionStatus') {
var state = remoting.ClientSession.State.fromString(
- getStringAttr(message.data, 'state'))
+ getStringAttr(message.data, 'state'));
var error = remoting.ClientSession.ConnectionError.fromString(
getStringAttr(message.data, 'error'));
this.onConnectionStatusUpdateHandler_(state, error);
+ } else if (message.method == 'onRouteChanged') {
+ var channel = getStringAttr(message.data, 'channel');
+ var connectionType = getStringAttr(message.data, 'connectionType');
+ this.onRouteChangedHandler_(channel, connectionType);
+
} else if (message.method == 'onDesktopSize') {
this.desktopWidth_ = getNumberAttr(message.data, 'width');
this.desktopHeight_ = getNumberAttr(message.data, 'height');
diff --git a/remoting/webapp/crd/js/client_session.js b/remoting/webapp/crd/js/client_session.js
index 6a15a5a..456f8ad 100644
--- a/remoting/webapp/crd/js/client_session.js
+++ b/remoting/webapp/crd/js/client_session.js
@@ -532,6 +532,7 @@ remoting.ClientSession.prototype.onPluginInitialized_ = function(initialized) {
this.plugin_.setConnectionStatusUpdateHandler(
this.onConnectionStatusUpdate_.bind(this));
+ this.plugin_.setRouteChangedHandler(this.onRouteChanged_.bind(this));
this.plugin_.setConnectionReadyHandler(this.onConnectionReady_.bind(this));
this.plugin_.setDesktopSizeUpdateHandler(
this.onDesktopSizeChanged_.bind(this));
@@ -837,11 +838,6 @@ remoting.ClientSession.prototype.sendIq_ = function(message) {
* @param {string} msg
*/
remoting.ClientSession.prototype.onDebugMessage_ = function(msg) {
- var isConnectionTypeMessage = msg.match(
- /^Channel (.*) using (.*) connection.$/);
- if (isConnectionTypeMessage) {
- this.logToServer.setConnectionType(isConnectionTypeMessage[2]);
- }
console.log('plugin: ' + msg.trimRight());
};
@@ -975,6 +971,21 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ =
};
/**
+ * Callback that the plugin invokes to indicate that the connection type for
+ * a channel has changed.
+ *
+ * @private
+ * @param {string} channel The channel name.
+ * @param {string} connectionType The new connection type.
+ */
+remoting.ClientSession.prototype.onRouteChanged_ =
+ function(channel, connectionType) {
+ console.log('plugin: Channel ' + channel + ' using ' +
+ connectionType + ' connection.');
+ this.logToServer.setConnectionType(connectionType);
+};
+
+/**
* Callback that the plugin invokes to indicate when the connection is
* ready.
*