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

Unified Diff: remoting/webapp/host_native_messaging.js

Issue 16236008: Send enums as strings between Chromoting Native Messaging host and web-app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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
« no previous file with comments | « remoting/host/setup/native_messaging_host_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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];
}
/**
« no previous file with comments | « remoting/host/setup/native_messaging_host_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698