diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-04 07:24:37 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-04 07:24:37 +0000 |
commit | 9286a19c5860cf874d139b15cc5922b909686db7 (patch) | |
tree | 0a5d6fad820fc6b26859e4589c7ff5a8222a62d0 /remoting/webapp | |
parent | 3899be4f08ba835bdf1c6af501a64eb438cc304c (diff) | |
download | chromium_src-9286a19c5860cf874d139b15cc5922b909686db7.zip chromium_src-9286a19c5860cf874d139b15cc5922b909686db7.tar.gz chromium_src-9286a19c5860cf874d139b15cc5922b909686db7.tar.bz2 |
Send enums as strings between Chromoting Native Messaging host and web-app.
This updates the JSON interface to transmit State and
AsyncResult values as strings instead of numbers.
BUG=232135
Review URL: https://chromiumcodereview.appspot.com/16236008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203894 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r-- | remoting/webapp/host_native_messaging.js | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/remoting/webapp/host_native_messaging.js b/remoting/webapp/host_native_messaging.js index 51180b1..5a35617 100644 --- a/remoting/webapp/host_native_messaging.js +++ b/remoting/webapp/host_native_messaging.js @@ -109,16 +109,14 @@ function checkType_(name, object, type) { * @return {remoting.HostController.AsyncResult?} Converted result. */ function asAsyncResult_(result) { - if (!checkType_('result', result, 'number')) { + if (!checkType_('result', result, 'string')) { return null; } - for (var i in remoting.HostController.AsyncResult) { - if (remoting.HostController.AsyncResult[i] == result) { - return remoting.HostController.AsyncResult[i]; - } + if (!remoting.HostController.AsyncResult.hasOwnProperty(result)) { + console.error('NativeMessaging: unexpected result code: ', result); + return null; } - console.error('NativeMessaging: unexpected result code: ', result); - return null; + return remoting.HostController.AsyncResult[result]; } /** @@ -129,16 +127,14 @@ function asAsyncResult_(result) { * @return {remoting.HostController.State?} Converted result. */ function asHostState_(result) { - if (!checkType_('result', result, 'number')) { + if (!checkType_('result', result, 'string')) { return null; } - for (var i in remoting.HostController.State) { - if (remoting.HostController.State[i] == result) { - return remoting.HostController.State[i]; - } + if (!remoting.HostController.State.hasOwnProperty(result)) { + console.error('NativeMessaging: unexpected result code: ', result); + return null; } - console.error('NativeMessaging: unexpected result code: ', result); - return null; + return remoting.HostController.State[result]; } /** |