Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/common.js

Issue 16067002: Added Safari Support (Closed)
Left Patch Set: Added missing copyright disclaimers and websql implementation Created Oct. 23, 2013, 2:46 p.m.
Right Patch Set: Bugfixes Created Nov. 15, 2013, 8:58 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/background.js ('k') | chrome/content.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function() { 18 (function()
19 {
19 /* Events */ 20 /* Events */
Felix Dahlke 2013/10/24 16:30:34 As in other places, opening braces should go on th
20 21
21 WrappedEventTarget = function(target) { 22 WrappedEventTarget = function(target)
23 {
22 this._listeners = []; 24 this._listeners = [];
23 this._wrappedListeners = []; 25 this._wrappedListeners = [];
24 this._target = target; 26 this._target = target;
25 }; 27 };
26 WrappedEventTarget.prototype = { 28 WrappedEventTarget.prototype = {
27 _prepareExtraArguments: function() { 29 _prepareExtraArguments: function()
30 {
28 return []; 31 return [];
29 }, 32 },
30 addListener: function(listener) { 33 addListener: function(listener)
31 var extaArgs = Array.prototype.slice.call(arguments, 1); 34 {
Felix Dahlke 2013/10/24 16:30:34 s/extaArgs/extraArgs/?
32 extaArgs = this._prepareExtraArguments.apply(this, extaArgs); 35 var extraArgs = Array.prototype.slice.call(arguments, 1);
36 extraArgs = this._prepareExtraArguments.apply(this, extraArgs);
33 37
34 var wrappedListener = this._wrapListener(listener); 38 var wrappedListener = this._wrapListener(listener);
35 this._listeners.push(listener); 39 this._listeners.push(listener);
36 this._wrappedListeners.push(wrappedListener); 40 this._wrappedListeners.push(wrappedListener);
37 41
38 this._target.addListener.apply(this._target, [wrappedListener].concat(exta Args)); 42 this._target.addListener.apply(this._target, [wrappedListener].concat(extr aArgs));
39 }, 43 },
40 removeListener: function(listener) { 44 removeListener: function(listener)
45 {
41 var idx = this._listeners.indexOf(listener); 46 var idx = this._listeners.indexOf(listener);
42 47
43 if (idx != -1) { 48 if (idx != -1) {
44 this._target.removeListener(this._wrappedListeners[idx]); 49 this._target.removeListener(this._wrappedListeners[idx]);
45 50
46 this._listeners.splice(idx, 1); 51 this._listeners.splice(idx, 1);
47 this._wrappedListeners.splice(idx, 1); 52 this._wrappedListeners.splice(idx, 1);
48 } 53 }
49 } 54 }
50 }; 55 };
51 56
52 var MessageEventTarget = function() { 57 var MessageEventTarget = function()
58 {
53 WrappedEventTarget.call(this, chrome.runtime.onMessage); 59 WrappedEventTarget.call(this, chrome.runtime.onMessage);
54 }; 60 };
55 MessageEventTarget.prototype = { 61 MessageEventTarget.prototype = {
56 __proto__: WrappedEventTarget.prototype, 62 __proto__: WrappedEventTarget.prototype,
57 _wrapListener: function(listener) { 63 _wrapListener: function(listener) {
58 return function(message, sender, sendResponse) { 64 return function(message, sender, sendResponse)
65 {
59 listener(message, {tab: sender.tab && new Tab(sender.tab)}, sendResponse ); 66 listener(message, {tab: sender.tab && new Tab(sender.tab)}, sendResponse );
60 }; 67 };
61 } 68 }
62 }; 69 };
63 70
64 /* API */ 71 /* API */
65 72
66 ext = { 73 ext = {
67 backgroundPage: { 74 backgroundPage: {
68 sendMessage: function(message, responseCallback) { 75 sendMessage: function(message, responseCallback)
76 {
69 chrome.runtime.sendMessage(message, responseCallback); 77 chrome.runtime.sendMessage(message, responseCallback);
70 }, 78 },
71 getDOMWindow: function() { 79 getWindow: function()
80 {
72 return chrome.extension.getBackgroundPage(); 81 return chrome.extension.getBackgroundPage();
73 } 82 }
74 }, 83 },
75 getURL: chrome.extension.getURL, 84 getURL: chrome.extension.getURL,
76 onMessage: new MessageEventTarget(), 85 onMessage: new MessageEventTarget(),
77 i18n: chrome.i18n 86 i18n: chrome.i18n
78 }; 87 };
79 })(); 88 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld