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

Delta Between Two Patch Sets: messageResponder.js

Issue 29337729: Issue 2374 - Implemented Tweaks section in options page (Closed)
Left Patch Set: Addressed Manvel's comments Created March 15, 2016, 2:40 p.m.
Right Patch Set: Created March 16, 2016, 11:13 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 | « locale/en-US/options.json ('k') | options.html » ('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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
(...skipping 16 matching lines...) Expand all
27 var defaultMatcher = require("matcher").defaultMatcher; 27 var defaultMatcher = require("matcher").defaultMatcher;
28 var CSSRules = require("cssRules").CSSRules; 28 var CSSRules = require("cssRules").CSSRules;
29 var NotificationStorage = require("notification").Notification; 29 var NotificationStorage = require("notification").Notification;
30 30
31 var filterClasses = require("filterClasses"); 31 var filterClasses = require("filterClasses");
32 var Filter = filterClasses.Filter; 32 var Filter = filterClasses.Filter;
33 var BlockingFilter = filterClasses.BlockingFilter; 33 var BlockingFilter = filterClasses.BlockingFilter;
34 var RegExpFilter = filterClasses.RegExpFilter; 34 var RegExpFilter = filterClasses.RegExpFilter;
35 var Synchronizer = require("synchronizer").Synchronizer; 35 var Synchronizer = require("synchronizer").Synchronizer;
36 36
37 var info = require("info");
37 var subscriptionClasses = require("subscriptionClasses"); 38 var subscriptionClasses = require("subscriptionClasses");
38 var Subscription = subscriptionClasses.Subscription; 39 var Subscription = subscriptionClasses.Subscription;
39 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; 40 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription;
40 var SpecialSubscription = subscriptionClasses.SpecialSubscription; 41 var SpecialSubscription = subscriptionClasses.SpecialSubscription;
41 42
42 function convertObject(keys, obj) 43 function convertObject(keys, obj)
43 { 44 {
44 var result = {}; 45 var result = {};
45 for (var i = 0; i < keys.length; i++) 46 for (var i = 0; i < keys.length; i++)
46 result[keys[i]] = obj[keys[i]]; 47 result[keys[i]] = obj[keys[i]];
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ext.showOptions(function() 141 ext.showOptions(function()
141 { 142 {
142 var subscription = Subscription.fromURL(message.url); 143 var subscription = Subscription.fromURL(message.url);
143 subscription.title = message.title; 144 subscription.title = message.title;
144 onFilterChange("addSubscription", subscription); 145 onFilterChange("addSubscription", subscription);
145 }); 146 });
146 break; 147 break;
147 case "app.get": 148 case "app.get":
148 if (message.what == "issues") 149 if (message.what == "issues")
149 { 150 {
150 var info = require("info"); 151 var subscriptionInit = require("subscriptionInit");
151 callback({ 152 callback({
152 seenDataCorruption: "seenDataCorruption" in global ? global.seenData Corruption : false, 153 filterlistsReinitialized: subscriptionInit ? subscriptionInit.reinit ialized : false,
153 filterlistsReinitialized: "filterlistsReinitialized" in global ? glo bal.filterlistsReinitialized : false,
154 legacySafariVersion: (info.platform == "safari" && ( 154 legacySafariVersion: (info.platform == "safari" && (
155 Services.vc.compare(info.platformVersion, "6.0") < 0 || // bef oreload breaks websites in Safari 5 155 Services.vc.compare(info.platformVersion, "6.0") < 0 || // bef oreload breaks websites in Safari 5
156 Services.vc.compare(info.platformVersion, "6.1") == 0 || // ext ensions are broken in 6.1 and 7.0 156 Services.vc.compare(info.platformVersion, "6.1") == 0 || // ext ensions are broken in 6.1 and 7.0
157 Services.vc.compare(info.platformVersion, "7.0") == 0)) 157 Services.vc.compare(info.platformVersion, "7.0") == 0))
158 }); 158 });
159 } 159 }
160 else if (message.what == "doclink") 160 else if (message.what == "doclink")
161 callback(Utils.getDocLink(message.link)); 161 callback(Utils.getDocLink(message.link));
162 else if (message.what == "localeInfo") 162 else if (message.what == "localeInfo")
163 { 163 {
164 var bidiDir; 164 var bidiDir;
165 if ("chromeRegistry" in Utils) 165 if ("chromeRegistry" in Utils)
166 bidiDir = Utils.chromeRegistry.isLocaleRTL("adblockplus") ? "rtl" : "ltr"; 166 bidiDir = Utils.chromeRegistry.isLocaleRTL("adblockplus") ? "rtl" : "ltr";
167 else 167 else
168 bidiDir = ext.i18n.getMessage("@@bidi_dir"); 168 bidiDir = ext.i18n.getMessage("@@bidi_dir");
169 169
170 callback({locale: Utils.appLocale, bidiDir: bidiDir}); 170 callback({locale: Utils.appLocale, bidiDir: bidiDir});
171 } 171 }
172 else if (message.what == "addonVersion") 172 else if (message.what == "addonVersion")
173 { 173 {
174 callback(require("info").addonVersion); 174 callback(info.addonVersion);
175 } 175 }
176 else if (message.what == "features") 176 else if (message.what == "features")
177 { 177 {
178 callback({ 178 callback({
179 devToolsPanel: info.platform == "chromium",
179 safariContentBlocker: "safari" in global 180 safariContentBlocker: "safari" in global
180 && "extension" in global.safari 181 && "extension" in global.safari
181 && "setContentBlocker" in global.safari.extension 182 && "setContentBlocker" in global.safari.extension
182 }); 183 });
183 } 184 }
184 else 185 else
185 callback(null); 186 callback(null);
186 break; 187 break;
187 case "app.listen": 188 case "app.listen":
188 if (message.filter) 189 if (message.filter)
189 listenerFilters.app = message.filter; 190 listenerFilters.app = message.filter;
190 else 191 else
191 delete listenerFilters.app; 192 delete listenerFilters.app;
192 break; 193 break;
193 case "app.open": 194 case "app.open":
194 if (message.what == "options") 195 if (message.what == "options")
195 ext.showOptions(); 196 ext.showOptions();
196 break; 197 break;
197 case "filters.add": 198 case "filters.add":
198 var filter = Filter.fromText(message.text);
199 var result = require("filterValidation").parseFilter(message.text); 199 var result = require("filterValidation").parseFilter(message.text);
200 var errors = [];
200 if (result.error) 201 if (result.error)
201 sendMessage("app", "error", [result.error.toString()], sender.page); 202 errors.push(result.error.toString());
202 else if (result.filter) 203 else if (result.filter)
203 FilterStorage.addFilter(result.filter); 204 FilterStorage.addFilter(result.filter);
205 callback(errors);
204 break; 206 break;
205 case "filters.blocked": 207 case "filters.blocked":
206 var filter = defaultMatcher.matchesAny(message.url, message.requestType, 208 var filter = defaultMatcher.matchesAny(message.url,
207 message.docDomain, message.thirdParty); 209 RegExpFilter.typeMap[message.requestType], message.docDomain,
210 message.thirdParty);
208 callback(filter instanceof BlockingFilter); 211 callback(filter instanceof BlockingFilter);
209 break; 212 break;
210 case "filters.get": 213 case "filters.get":
211 if (message.what == "cssproperties") 214 if (message.what == "cssproperties")
212 { 215 {
213 var filters = []; 216 var filters = [];
214 var checkWhitelisted = require("whitelisting").checkWhitelisted; 217 var checkWhitelisted = require("whitelisting").checkWhitelisted;
215 218
216 if (!checkWhitelisted(sender.page, sender.frame, 219 if (!checkWhitelisted(sender.page, sender.frame,
217 RegExpFilter.typeMap.DOCUMENT | 220 RegExpFilter.typeMap.DOCUMENT |
(...skipping 25 matching lines...) Expand all
243 case "filters.importRaw": 246 case "filters.importRaw":
244 var result = require("filterValidation").parseFilters(message.text); 247 var result = require("filterValidation").parseFilters(message.text);
245 var errors = []; 248 var errors = [];
246 for (var i = 0; i < result.errors.length; i++) 249 for (var i = 0; i < result.errors.length; i++)
247 { 250 {
248 var error = result.errors[i]; 251 var error = result.errors[i];
249 if (error.type != "unexpected-filter-list-header") 252 if (error.type != "unexpected-filter-list-header")
250 errors.push(error.toString()); 253 errors.push(error.toString());
251 } 254 }
252 255
256 callback(errors);
253 if (errors.length > 0) 257 if (errors.length > 0)
254 {
255 sendMessage("app", "error", errors, sender.page);
256 return; 258 return;
257 }
258 259
259 var seenFilter = Object.create(null); 260 var seenFilter = Object.create(null);
260 for (var i = 0; i < result.filters.length; i++) 261 for (var i = 0; i < result.filters.length; i++)
261 { 262 {
262 var filter = result.filters[i]; 263 var filter = result.filters[i];
263 FilterStorage.addFilter(filter); 264 FilterStorage.addFilter(filter);
264 seenFilter[filter.text] = null; 265 seenFilter[filter.text] = null;
265 } 266 }
266 267
267 for (var i = 0; i < FilterStorage.subscriptions.length; i++) 268 for (var i = 0; i < FilterStorage.subscriptions.length; i++)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (subscription instanceof DownloadableSubscription) 388 if (subscription instanceof DownloadableSubscription)
388 Synchronizer.execute(subscription, true); 389 Synchronizer.execute(subscription, true);
389 } 390 }
390 break; 391 break;
391 case "subscriptions.isDownloading": 392 case "subscriptions.isDownloading":
392 callback(Synchronizer.isExecuting(message.url)); 393 callback(Synchronizer.isExecuting(message.url));
393 break; 394 break;
394 } 395 }
395 }); 396 });
396 })(this); 397 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld