Index: remoting/webapp/host_native_messaging.js |
diff --git a/remoting/webapp/host_native_messaging.js b/remoting/webapp/host_native_messaging.js |
index 8ed628c9120bc2309a0b779d0674673677b773b0..957e881a57ffb2dfc78b233b08c072f82185938d 100644 |
--- a/remoting/webapp/host_native_messaging.js |
+++ b/remoting/webapp/host_native_messaging.js |
@@ -109,13 +109,11 @@ 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 (result in remoting.HostController.AsyncResult) { |
+ return remoting.HostController.AsyncResult[result]; |
Sergey Ulanov
2013/05/31 23:01:43
nit: I would swap this block and the error case at
Lambros
2013/06/03 21:28:44
Done.
|
} |
console.error('NativeMessaging: unexpected result code: ', result); |
return null; |
@@ -129,13 +127,11 @@ 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 (result in remoting.HostController.State) { |
+ return remoting.HostController.State[result]; |
} |
console.error('NativeMessaging: unexpected result code: ', result); |
return null; |