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

Side by Side Diff: chrome/renderer/resources/extensions/event.js

Issue 10566018: Initial work to remove the notion of all extension message payloads as strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review changes. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var eventBindingsNatives = requireNative('event_bindings'); 5 var eventBindingsNatives = requireNative('event_bindings');
6 var AttachEvent = eventBindingsNatives.AttachEvent; 6 var AttachEvent = eventBindingsNatives.AttachEvent;
7 var DetachEvent = eventBindingsNatives.DetachEvent; 7 var DetachEvent = eventBindingsNatives.DetachEvent;
8 var sendRequest = require('sendRequest').sendRequest; 8 var sendRequest = require('sendRequest').sendRequest;
9 var utils = require('utils'); 9 var utils = require('utils');
10 var validate = require('schemaUtils').validate; 10 var validate = require('schemaUtils').validate;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 throw new Error("Massager already registered for event: " + name); 132 throw new Error("Massager already registered for event: " + name);
133 eventArgumentMassagers[name] = fn; 133 eventArgumentMassagers[name] = fn;
134 }; 134 };
135 135
136 // Dispatches a named event with the given JSON array, which is deserialized 136 // Dispatches a named event with the given JSON array, which is deserialized
137 // before dispatch. The JSON array is the list of arguments that will be 137 // before dispatch. The JSON array is the list of arguments that will be
138 // sent with the event callback. 138 // sent with the event callback.
139 chromeHidden.Event.dispatchJSON = function(name, args) { 139 chromeHidden.Event.dispatchJSON = function(name, args) {
140 if (attachedNamedEvents[name]) { 140 if (attachedNamedEvents[name]) {
141 if (args) { 141 if (args) {
142 args = chromeHidden.JSON.parse(args); 142 // TODO(asargent): This is an antiquity. Until all callers of
143 // dispatchJSON use actual values, this must remain here to catch the
144 // cases where a caller has hard-coded a JSON string to pass in.
145 if (typeof(args) == "string") {
146 args = chromeHidden.JSON.parse(args);
147 }
143 if (eventArgumentMassagers[name]) 148 if (eventArgumentMassagers[name])
144 eventArgumentMassagers[name](args); 149 eventArgumentMassagers[name](args);
145 } 150 }
146 var result = attachedNamedEvents[name].dispatch.apply( 151 var result = attachedNamedEvents[name].dispatch.apply(
147 attachedNamedEvents[name], args); 152 attachedNamedEvents[name], args);
148 if (result && result.validationErrors) 153 if (result && result.validationErrors)
149 return result.validationErrors; 154 return result.validationErrors;
150 } 155 }
151 }; 156 };
152 157
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 if (event) 365 if (event)
361 event.detach_(false); 366 event.detach_(false);
362 } 367 }
363 }; 368 };
364 369
365 chromeHidden.dispatchError = function(msg) { 370 chromeHidden.dispatchError = function(msg) {
366 console.error(msg); 371 console.error(msg);
367 }; 372 };
368 373
369 exports.Event = chrome.Event; 374 exports.Event = chrome.Event;
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_event_router.cc ('k') | chrome/renderer/resources/extensions/schema_utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698