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

Unified Diff: trunk/src/chrome/renderer/resources/extensions/miscellaneous_bindings.js

Issue 16336011: Revert 203489 "Replace JSON (de)serialization of extension messa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
Index: trunk/src/chrome/renderer/resources/extensions/miscellaneous_bindings.js
===================================================================
--- trunk/src/chrome/renderer/resources/extensions/miscellaneous_bindings.js (revision 203729)
+++ trunk/src/chrome/renderer/resources/extensions/miscellaneous_bindings.js (working copy)
@@ -8,6 +8,7 @@
// content scripts only.
require('json_schema');
+ var json = require('json');
var lastError = require('lastError');
var miscNatives = requireNative('miscellaneous_bindings');
var chrome = requireNative('chrome').GetChrome();
@@ -54,7 +55,10 @@
// Sends a message asynchronously to the context on the other end of this
// port.
PortImpl.prototype.postMessage = function(msg) {
- PostMessage(this.portId_, msg);
+ // json.stringify doesn't support a root object which is undefined.
+ if (msg === undefined)
+ msg = null;
+ PostMessage(this.portId_, json.stringify(msg));
};
// Disconnects the port from the other end.
@@ -262,8 +266,12 @@
// Called by native code when a message has been sent to the given port.
chromeHidden.Port.dispatchOnMessage = function(msg, portId) {
var port = ports[portId];
- if (port)
+ if (port) {
+ if (msg) {
+ msg = json.parse(msg);
+ }
port.onMessage.dispatch(msg, port);
+ }
};
// Shared implementation used by tabs.sendMessage and runtime.sendMessage.

Powered by Google App Engine
This is Rietveld 408576698