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

Unified Diff: remoting/webapp/host_dispatcher.js

Issue 15623002: Don't serialize config dictionary in Native Messaging interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang-format fixes Created 7 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/host_dispatcher.js
diff --git a/remoting/webapp/host_dispatcher.js b/remoting/webapp/host_dispatcher.js
index fe0ba384c28407b606d7d477105ce805869cdb3a..d67884027ffccc4e3aba541818391877d7f6fba7 100644
--- a/remoting/webapp/host_dispatcher.js
+++ b/remoting/webapp/host_dispatcher.js
@@ -128,7 +128,7 @@ remoting.HostDispatcher.prototype.generateKeyPair = function(callback) {
};
/**
- * @param {string} config
+ * @param {Object} config
* @param {function(remoting.HostController.AsyncResult):void} callback
* @return {void}
*/
@@ -142,17 +142,35 @@ remoting.HostDispatcher.prototype.updateDaemonConfig = function(config,
this.nativeMessagingHost_.updateDaemonConfig(config, callback);
break;
case remoting.HostDispatcher.State.NPAPI:
- this.npapiHost_.updateDaemonConfig(config, callback);
+ this.npapiHost_.updateDaemonConfig(JSON.stringify(config), callback);
break;
}
-
};
/**
- * @param {function(string):void} callback
+ * @param {function(Object):void} callback
* @return {void}
*/
remoting.HostDispatcher.prototype.getDaemonConfig = function(callback) {
+ /**
+ * Converts the config string from the NPAPI plugin to an Object, to pass to
+ * |callback|.
+ * @param {string} configStr
+ * @return {void}
+ */
+ function callbackForNpapi(configStr) {
+ var config = null;
+ try {
+ config = JSON.parse(configStr);
+ } catch (err) {
+ // TODO(lambroslambrou): Call error handler here when that's implemented.
+ }
+ if (typeof(config) != 'object') {
+ config = null;
Jamie 2013/05/22 00:54:21 Would this also be an error? If so, please move th
Lambros 2013/05/23 00:22:48 Done.
+ }
+ callback(/** @type {Object} */ (config));
+ }
+
switch (this.state_) {
case remoting.HostDispatcher.State.UNKNOWN:
this.pendingRequests_.push(this.getDaemonConfig.bind(this, callback));
@@ -161,7 +179,7 @@ remoting.HostDispatcher.prototype.getDaemonConfig = function(callback) {
this.nativeMessagingHost_.getDaemonConfig(callback);
break;
case remoting.HostDispatcher.State.NPAPI:
- this.npapiHost_.getDaemonConfig(callback);
+ this.npapiHost_.getDaemonConfig(callbackForNpapi);
break;
}
};
@@ -204,7 +222,7 @@ remoting.HostDispatcher.prototype.getUsageStatsConsent = function(callback) {
};
/**
- * @param {string} config
+ * @param {Object} config
* @param {boolean} consent
* @param {function(remoting.HostController.AsyncResult):void} callback
* @return {void}
@@ -220,7 +238,7 @@ remoting.HostDispatcher.prototype.startDaemon = function(config, consent,
this.nativeMessagingHost_.startDaemon(config, consent, callback);
break;
case remoting.HostDispatcher.State.NPAPI:
- this.npapiHost_.startDaemon(config, consent, callback);
+ this.npapiHost_.startDaemon(JSON.stringify(config), consent, callback);
break;
}
};

Powered by Google App Engine
This is Rietveld 408576698