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

Delta Between Two Patch Sets: background.js

Issue 4731979438227456: Issue 1663 - Emulate background page and implement proper message responder (Closed)
Left Patch Set: Fixed sender API Created Dec. 17, 2014, 7:37 p.m.
Right Patch Set: Using Services.vc Created Dec. 19, 2014, 5:45 p.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 | « background.html ('k') | ext/background.js » ('j') | messageResponder.js » ('J')
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-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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(global) 18 (function(global)
19 { 19 {
20 function getURLParameters(data) 20 function updateFromURL(data)
21 { 21 {
22 if (window.location.search) 22 if (window.location.search)
23 { 23 {
24 var params = window.location.search.substr(1).split("&"); 24 var params = window.location.search.substr(1).split("&");
25 for (var i = 0; i < params.length; i++) 25 for (var i = 0; i < params.length; i++)
26 { 26 {
27 var parts = params[i].split("=", 2); 27 var parts = params[i].split("=", 2);
28 if (parts.length == 2 && parts[0] in data) 28 if (parts.length == 2 && parts[0] in data)
29 data[parts[0]] = decodeURIComponent(parts[1]); 29 data[parts[0]] = decodeURIComponent(parts[1]);
30 } 30 }
31 } 31 }
32 } 32 }
33 33
34 var subscriptions =[ 34 var subscriptions =[
35 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", 35 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
36 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", 36 "https://easylist-downloads.adblockplus.org/exceptionrules.txt",
37 "https://easylist-downloads.adblockplus.org/fanboy-social.txt" 37 "https://easylist-downloads.adblockplus.org/fanboy-social.txt"
38 ]; 38 ];
39 39
40 global.Utils = { 40 global.Utils = {
41 getDocLink: function(link) 41 getDocLink: function(link)
42 { 42 {
43 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(link) ; 43 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(link) ;
44 } 44 }
45 }; 45 };
46 46
47 global.Subscription = { 47 global.Subscription = function(url)
48 fromURL: function(url) 48 {
49 { 49 this.url = url;
50 return { 50 this.title = "Subscription " + url;
51 url: url, 51 this.disabled = false;
52 title: "Subscription " + url, 52 this.lastDownload = 1234;
53 disabled: false,
54 lastDownload: 1234
55 };
56 }
57 }; 53 };
54
55 global.Subscription.fromURL = function(url)
56 {
57 return new global.Subscription(url);
58 };
59
60 global.DownloadableSubscription = global.Subscription;
61 global.SpecialSubscription = function() {};
58 62
59 global.FilterStorage = { 63 global.FilterStorage = {
60 get subscriptions() 64 get subscriptions()
61 { 65 {
62 return subscriptions.map(global.Subscription.fromURL); 66 return subscriptions.map(global.Subscription.fromURL);
63 }, 67 },
64 68
65 get knownSubscriptions() 69 get knownSubscriptions()
66 { 70 {
67 var result = {}; 71 var result = {};
(...skipping 22 matching lines...) Expand all
90 } 94 }
91 } 95 }
92 }; 96 };
93 97
94 global.BlockingFilter = function() {}; 98 global.BlockingFilter = function() {};
95 99
96 global.defaultMatcher = { 100 global.defaultMatcher = {
97 matchesAny: function(url, requestType, docDomain, thirdParty) 101 matchesAny: function(url, requestType, docDomain, thirdParty)
98 { 102 {
99 var params = {blockedURLs: ""}; 103 var params = {blockedURLs: ""};
100 getURLParameters(params); 104 updateFromURL(params);
101 var blocked = params.blockedURLs.split(","); 105 var blocked = params.blockedURLs.split(",");
102 if (blocked.indexOf(url) >= 0) 106 if (blocked.indexOf(url) >= 0)
103 return new global.BlockingFilter(); 107 return new global.BlockingFilter();
104 else 108 else
105 return null; 109 return null;
106 } 110 }
107 }; 111 };
108 112
109 var notifierListeners = []; 113 var notifierListeners = [];
110 global.FilterNotifier = { 114 global.FilterNotifier = {
(...skipping 16 matching lines...) Expand all
127 var listeners = notifierListeners.slice(); 131 var listeners = notifierListeners.slice();
128 for (var i = 0; i < listeners.length; i++) 132 for (var i = 0; i < listeners.length; i++)
129 listeners[i].apply(null, args); 133 listeners[i].apply(null, args);
130 } 134 }
131 }; 135 };
132 136
133 global.require = function(module) 137 global.require = function(module)
134 { 138 {
135 if (module == "info") 139 if (module == "info")
136 { 140 {
137 var result = {platform: "gecko", platformVersion: "34.0", application: "fi refox", applicationVersion: "34.0"}; 141 var result = {
138 getURLParameters(result); 142 platform: "gecko",
143 platformVersion: "34.0",
144 application: "firefox",
145 applicationVersion: "34.0"
146 };
147 updateFromURL(result);
139 return result; 148 return result;
140 } 149 }
141 else 150 else
142 return undefined; 151 return undefined;
143 } 152 }
144 153
145 global.openOptions = function() 154 global.openOptions = function()
146 { 155 {
147 window.open("http://example.com/options.html", "_blank"); 156 window.open("http://example.com/options.html", "_blank");
148 }; 157 };
149 158
159 global.Services = {
160 vc: {
161 compare: function(v1, v2)
162 {
163 return parseFloat(v1) - parseFloat(v2);
164 }
165 }
166 };
167
150 var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; 168 var issues = {seenDataCorruption: false, filterlistsReinitialized: false};
151 getURLParameters(issues); 169 updateFromURL(issues);
152 global.seenDataCorruption = issues.seenDataCorruption; 170 global.seenDataCorruption = issues.seenDataCorruption;
153 global.filterlistsReinitialized = issues.filterlistsReinitialized; 171 global.filterlistsReinitialized = issues.filterlistsReinitialized;
154 })(this); 172 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld