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

Unified Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 2754014: Merge 48667 - Prevent extensions from clobbering JSON implementation that ext... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/375/src/
Patch Set: Created 10 years, 6 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: chrome/renderer/resources/extension_process_bindings.js
===================================================================
--- chrome/renderer/resources/extension_process_bindings.js (revision 49570)
+++ chrome/renderer/resources/extension_process_bindings.js (working copy)
@@ -81,7 +81,7 @@
if (request.callback) {
// Callbacks currently only support one callback argument.
- var callbackArgs = response ? [JSON.parse(response)] : [];
+ var callbackArgs = response ? [chromeHidden.JSON.parse(response)] : [];
// Validate callback in debug only -- and only when the
// caller has provided a callback. Implementations of api
@@ -173,20 +173,8 @@
if (request.args === undefined)
request.args = null;
- // Some javascript libraries (e.g. prototype.js version <= 1.6) add a toJSON
- // serializer function on Array.prototype that is incompatible with our
- // native JSON library, causing incorrect deserialization in the C++ side of
- // StartRequest. We work around that here by temporarily removing the toJSON
- // function.
- var arrayToJsonTmp;
- if (Array.prototype.toJSON) {
- arrayToJsonTmp = Array.prototype.toJSON;
- Array.prototype.toJSON = null;
- }
- var sargs = JSON.stringify(request.args);
- if (arrayToJsonTmp) {
- Array.prototype.toJSON = arrayToJsonTmp;
- }
+ var sargs = chromeHidden.JSON.stringify(request.args);
+
var requestId = GetNextRequestId();
requests[requestId] = request;
var hasCallback = (request.callback || customCallback) ? true : false;
@@ -324,7 +312,7 @@
// TODO(rafaelw): Handle synchronous functions.
// TOOD(rafaelw): Consider providing some convenient override points
// for api functions that wish to insert themselves into the call.
- var apiDefinitions = JSON.parse(GetExtensionAPIDefinition());
+ var apiDefinitions = chromeHidden.JSON.parse(GetExtensionAPIDefinition());
apiDefinitions.forEach(function(apiDef) {
var module = chrome;
@@ -599,7 +587,7 @@
// Set up the onclick handler if we were passed one in the request.
if (request.args.onclick) {
- var menuItemId = JSON.parse(response);
+ var menuItemId = chromeHidden.JSON.parse(response);
chromeHidden.contextMenuHandlers[menuItemId] = request.args.onclick;
}
};
« no previous file with comments | « chrome/renderer/resources/event_bindings.js ('k') | chrome/renderer/resources/renderer_extension_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698