Index: remoting/webapp/host_native_messaging.js |
diff --git a/remoting/webapp/host_native_messaging.js b/remoting/webapp/host_native_messaging.js |
index 51180b116f18344a0859004a8139c09d20b363b7..5a35617f21ef64e61a2609baab414b84ac9bb853 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]; |
} |
/** |