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

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

Issue 9965005: Deprecate chrome.extension.sendRequest in favor of sendMessage, with a safer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: return.val Created 8 years, 8 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 Print = eventBindingsNatives.Print; 8 var Print = eventBindingsNatives.Print;
9 9
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Dispatches this event object to all listeners, passing all supplied 188 // Dispatches this event object to all listeners, passing all supplied
189 // arguments to this function each listener. 189 // arguments to this function each listener.
190 chrome.Event.prototype.dispatch = function(varargs) { 190 chrome.Event.prototype.dispatch = function(varargs) {
191 if (!this.eventOptions_.supportsListeners) 191 if (!this.eventOptions_.supportsListeners)
192 throw new Error("This event does not support listeners."); 192 throw new Error("This event does not support listeners.");
193 var args = Array.prototype.slice.call(arguments); 193 var args = Array.prototype.slice.call(arguments);
194 var validationErrors = this.validate_(args); 194 var validationErrors = this.validate_(args);
195 if (validationErrors) { 195 if (validationErrors) {
196 return validationErrors; 196 return validationErrors;
197 } 197 }
198 var retvals = [];
198 for (var i = 0; i < this.listeners_.length; i++) { 199 for (var i = 0; i < this.listeners_.length; i++) {
199 try { 200 try {
200 this.listeners_[i].apply(null, args); 201 var retval = this.listeners_[i].apply(null, args);
202 if (retval !== undefined)
203 retvals.push(retval);
201 } catch (e) { 204 } catch (e) {
202 console.error("Error in event handler for '" + this.eventName_ + 205 console.error("Error in event handler for '" + this.eventName_ +
203 "': " + e.stack); 206 "': " + e.stack);
204 } 207 }
205 } 208 }
209 if (retvals.length)
210 return retvals;
Matt Perry 2012/03/30 05:41:39 This conflicts with 'return validationErrors' abov
206 }; 211 };
207 212
208 // Attaches this event object to its name. Only one object can have a given 213 // Attaches this event object to its name. Only one object can have a given
209 // name. 214 // name.
210 chrome.Event.prototype.attach_ = function() { 215 chrome.Event.prototype.attach_ = function() {
211 AttachEvent(this.eventName_); 216 AttachEvent(this.eventName_);
212 allAttachedEvents[allAttachedEvents.length] = this; 217 allAttachedEvents[allAttachedEvents.length] = this;
213 if (!this.eventName_) 218 if (!this.eventName_)
214 return; 219 return;
215 220
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 for (var i = 0; i < allAttachedEvents.length; ++i) { 307 for (var i = 0; i < allAttachedEvents.length; ++i) {
303 var event = allAttachedEvents[i]; 308 var event = allAttachedEvents[i];
304 if (event) 309 if (event)
305 event.detach_(false); 310 event.detach_(false);
306 } 311 }
307 }; 312 };
308 313
309 chromeHidden.dispatchError = function(msg) { 314 chromeHidden.dispatchError = function(msg) {
310 console.error(msg); 315 console.error(msg);
311 }; 316 };
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/tabs.html ('k') | chrome/renderer/resources/extensions/extension_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698