diff options
Diffstat (limited to 'remoting/webapp/host_native_messaging.js')
-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]; } /** |