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

Unified Diff: remoting/webapp/crd/js/native_message_host_log_message_handler.js

Issue 1272833002: Pass error messages from native messaging to web-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer feedback. Created 5 years, 4 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/webapp/crd/js/it2me_host_facade.js ('k') | remoting/webapp/files.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/native_message_host_log_message_handler.js
diff --git a/remoting/webapp/crd/js/native_message_host_log_message_handler.js b/remoting/webapp/crd/js/native_message_host_log_message_handler.js
new file mode 100644
index 0000000000000000000000000000000000000000..ab5ff9fda42a42ccbb0713a1d9aa4817d5ab18eb
--- /dev/null
+++ b/remoting/webapp/crd/js/native_message_host_log_message_handler.js
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Class to handle debug log messages sent by either the It2Me or Me2Me native
+ * messaging hosts.
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+(function() {
+
+/**
+ * @constructor
+ */
+remoting.NativeMessageHostDebugMessageHandler = function() {
+};
+
+/**
+ * Handle debug messages..
+ *
+ * @param {Object} message
+ * @return {boolean} True if the message was handled.
+ */
+remoting.NativeMessageHostDebugMessageHandler.prototype.handleMessage =
+ function(message)
+{
+ /** @type {string} */
+ var type = base.getStringAttr(message, 'type', '');
+ switch (type) {
+ case '_debug_log':
+ var timestamp = base.timestamp();
+ var msg = base.getStringAttr(message, 'message', '<no message>');
+ var severity = base.getStringAttr(message, 'severity', 'log');
+ var file = base.getStringAttr(message, 'file', '<no file>');
+ var line = base.getNumberAttr(message, 'line', -1);
+ var location = file + ':' + line;
+ var css = 'color: gray; font-style: italic'
+ switch (severity) {
+ case 'error':
+ console.error('%s %s %c%s', timestamp, msg, css, location);
+ break;
+ case 'warn':
+ console.warn('%s %s %c%s', timestamp, msg, css, location);
+ break;
+ default:
+ console.log('%s %s %c%s', timestamp, msg, css, location);
+ };
+ return true;
+ }
+ return false;
+};
+
+})();
« no previous file with comments | « remoting/webapp/crd/js/it2me_host_facade.js ('k') | remoting/webapp/files.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698