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

Delta Between Two Patch Sets: adblockplus/Api.jsm

Issue 29626577: Issue 6108 - No filter list is selected after a migration failure (Closed)
Left Patch Set: Created Dec. 1, 2017, 8:24 p.m.
Right Patch Set: Small adjustments Created Dec. 5, 2017, 3:51 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 | « no previous file | adblockplus/build.py » ('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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 29 matching lines...) Expand all
40 let {FilterNotifier} = require("filterNotifier"); 40 let {FilterNotifier} = require("filterNotifier");
41 let {FilterStorage} = require("filterStorage"); 41 let {FilterStorage} = require("filterStorage");
42 let {defaultMatcher} = require("matcher"); 42 let {defaultMatcher} = require("matcher");
43 let {Prefs} = require("prefs"); 43 let {Prefs} = require("prefs");
44 let {Subscription, SpecialSubscription, RegularSubscription, DownloadableSubscri ption, ExternalSubscription} = require("subscriptionClasses"); 44 let {Subscription, SpecialSubscription, RegularSubscription, DownloadableSubscri ption, ExternalSubscription} = require("subscriptionClasses");
45 let {Synchronizer} = require("synchronizer"); 45 let {Synchronizer} = require("synchronizer");
46 let {UI} = require("ui"); 46 let {UI} = require("ui");
47 47
48 const SUBSCRIPTIONS_SAVED_PREF = "subscriptions_saved"; 48 const SUBSCRIPTIONS_SAVED_PREF = "subscriptions_saved";
49 const USER_REMOVED_BLOCK_SUBS_PREF = "user_removed_block_subscriptions"; 49 const USER_REMOVED_BLOCK_SUBS_PREF = "user_removed_block_subscriptions";
50 const USER_REMOVED_EXCEPTIONS_SUB_PREF = "user_removed_exception_subscription";
50 51
51 function initFilterListeners() 52 function initFilterListeners()
52 { 53 {
53 FilterNotifier.on("load", onFiltersLoad); 54 FilterNotifier.on("load", onFiltersLoad);
54 FilterNotifier.on("save", onFiltersSave); 55 FilterNotifier.on("save", onFiltersSave);
55 } 56 }
56 57
57 function onFiltersLoad() 58 function onFiltersLoad()
58 { 59 {
59 let {addonVersion} = require("info");
60 let detectedSubscriptionFailure = !hasBlockSubscription() && 60 let detectedSubscriptionFailure = !hasBlockSubscription() &&
61 (!getBoolPref(SUBSCRIPTIONS_SAVED_PREF) || !getBoolPref(USER_REMOVED_BLOCK_S UBS_PREF) || FilterStorage.loadFromDiskFailed); 61 (!getBoolPref(SUBSCRIPTIONS_SAVED_PREF) || !getBoolPref(USER_REMOVED_BLOCK_S UBS_PREF) || FilterStorage.loadFromDiskFailed);
62 62
63 // We will only try to recover the default subscription settings if the addonV ersion hasn't changed, 63 // We will only try to recover the default subscription settings if the addonV ersion hasn't changed,
64 // otherwise it will be handled in firstRunActions(), inside ui.js 64 // otherwise it will be handled in firstRunActions(), inside ui.js
65 if(Prefs.currentVersion == addonVersion && detectedSubscriptionFailure) 65 let {addonVersion} = require("info");
anton 2017/12/04 14:00:46 space is needed here
diegocarloslima 2017/12/05 09:44:10 Acknowledged.
66 { 66 if (Prefs.currentVersion == addonVersion && detectedSubscriptionFailure)
67 UI.addSubscription(UI.currentWindow, "0.0"); 67 {
68 if (getBoolPref(USER_REMOVED_EXCEPTIONS_SUB_PREF))
69 {
70 UI.addSubscription(UI.currentWindow, Prefs.currentVersion);
71 }
72 else
73 {
74 UI.addSubscription(UI.currentWindow, "0.0");
75 }
68 } 76 }
69 Messaging.sendRequest({ type: "Abb:OnFiltersLoad" }); 77 Messaging.sendRequest({ type: "Abb:OnFiltersLoad" });
70 } 78 }
79
71 function onFiltersSave() 80 function onFiltersSave()
72 { 81 {
73 if (hasBlockSubscription()) 82 if (hasBlockSubscription())
74 { 83 {
75 setBoolPref(SUBSCRIPTIONS_SAVED_PREF, true); 84 setBoolPref(SUBSCRIPTIONS_SAVED_PREF, true);
76 } 85 }
77 Messaging.sendRequest({ type: "Abb:OnFiltersSave" }); 86 Messaging.sendRequest({ type: "Abb:OnFiltersSave" });
78 } 87 }
79 88
80 function getBoolPref(name) 89 function getBoolPref(name)
(...skipping 19 matching lines...) Expand all
100 function getPrefsBranch() 109 function getPrefsBranch()
101 { 110 {
102 let {addonRoot, addonName} = require("info"); 111 let {addonRoot, addonName} = require("info");
103 let branchName = "extensions." + addonName + "."; 112 let branchName = "extensions." + addonName + ".";
104 return Services.prefs.getBranch(branchName); 113 return Services.prefs.getBranch(branchName);
105 } 114 }
106 115
107 function hasBlockSubscription() 116 function hasBlockSubscription()
108 { 117 {
109 return FilterStorage.subscriptions.some( 118 return FilterStorage.subscriptions.some(
110 (subscription) => subscription instanceof DownloadableSubscription && subscr iption.url != Prefs.subscriptions_exceptionsurl); 119 subscription => subscription instanceof DownloadableSubscription && subscrip tion.url != Prefs.subscriptions_exceptionsurl);
jens 2017/12/04 11:00:30 Do we need parentheses when there's only one param
diegocarloslima 2017/12/05 09:44:09 Acknowledged.
111 } 120 }
112 121
113 function getWhitelistingFilter(url) 122 function getWhitelistingFilter(url)
114 { 123 {
115 let uriObject = Services.io.newURI(url, null, null); 124 let uriObject = Services.io.newURI(url, null, null);
116 try 125 try
117 { 126 {
118 return defaultMatcher.whitelist.matchesAny( 127 return defaultMatcher.whitelist.matchesAny(
119 uriObject.spec, RegExpFilter.typeMap.DOCUMENT, uriObject.host, false, null , false); 128 uriObject.spec, RegExpFilter.typeMap.DOCUMENT, uriObject.host, false, null , false);
120 } 129 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 FilterStorage.addSubscription(subscriptionToAdd); 182 FilterStorage.addSubscription(subscriptionToAdd);
174 let subscription = FilterStorage.knownSubscriptions[url]; 183 let subscription = FilterStorage.knownSubscriptions[url];
175 if (subscription) 184 if (subscription)
176 { 185 {
177 subscription.disabled = false; 186 subscription.disabled = false;
178 if (!subscription.lastDownload) 187 if (!subscription.lastDownload)
179 { 188 {
180 Synchronizer.execute(subscription); 189 Synchronizer.execute(subscription);
181 } 190 }
182 } 191 }
183 if (hasBlockSubscription()) 192 if (url == Prefs.subscriptions_exceptionsurl)
193 {
194 setBoolPref(USER_REMOVED_EXCEPTIONS_SUB_PREF, false);
195 }
196 else if (hasBlockSubscription())
184 { 197 {
185 setBoolPref(USER_REMOVED_BLOCK_SUBS_PREF, false); 198 setBoolPref(USER_REMOVED_BLOCK_SUBS_PREF, false);
186 } 199 }
187 }, 200 },
188 removeSubscription: function(url) 201 removeSubscription: function(url)
189 { 202 {
190 FilterStorage.removeSubscription(FilterStorage.knownSubscriptions[url]); 203 FilterStorage.removeSubscription(FilterStorage.knownSubscriptions[url]);
191 if (!hasBlockSubscription()) 204 if (url == Prefs.subscriptions_exceptionsurl)
205 {
206 setBoolPref(USER_REMOVED_EXCEPTIONS_SUB_PREF, true);
207 }
208 else if (!hasBlockSubscription())
192 { 209 {
193 setBoolPref(USER_REMOVED_BLOCK_SUBS_PREF, true); 210 setBoolPref(USER_REMOVED_BLOCK_SUBS_PREF, true);
194 } 211 }
195 }, 212 },
196 getActiveSubscriptions: function() 213 getActiveSubscriptions: function()
197 { 214 {
198 let subscriptions = []; 215 let subscriptions = [];
199 for (let i = 0; i < FilterStorage.subscriptions.length; i++) 216 for (let i = 0; i < FilterStorage.subscriptions.length; i++)
200 { 217 {
201 let subscription = FilterStorage.subscriptions[i]; 218 let subscription = FilterStorage.subscriptions[i];
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 { 330 {
314 this.whitelistSite(data["url"], data["whitelisted"]); 331 this.whitelistSite(data["url"], data["whitelisted"]);
315 return {"success": true}; 332 return {"success": true};
316 } 333 }
317 break; 334 break;
318 } 335 }
319 return {"success": false, "error": "malformed request"}; 336 return {"success": false, "error": "malformed request"};
320 }).bind(this), "AdblockPlus:Api"); 337 }).bind(this), "AdblockPlus:Api");
321 } 338 }
322 }; 339 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld