OLD | NEW |
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 // | 18 // |
19 // Report data template, more data will be added during data collection | 19 // Report data template, more data will be added during data collection |
20 // | 20 // |
21 | 21 |
22 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 22 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
23 let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {}); | 23 let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {}); |
24 | 24 |
25 const MILLISECONDS_IN_SECOND = 1000; | 25 const MILLISECONDS_IN_SECOND = 1000; |
26 const SECONDS_IN_MINUTE = 60; | 26 const SECONDS_IN_MINUTE = 60; |
27 const SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE; | 27 const SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE; |
28 const SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR; | 28 const SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR; |
29 | 29 |
30 let contentWindow = window.arguments[0]; | 30 let outerWindowID = window.arguments[0]; |
31 let windowURI = window.arguments[1]; | 31 let windowURI = window.arguments[1]; |
32 if (typeof windowURI == "string") | 32 if (typeof windowURI == "string") |
33 windowURI = Services.newURI(windowURI, null, null); | 33 windowURI = Services.newURI(windowURI, null, null); |
34 let browser = window.arguments[2]; | 34 let browser = window.arguments[2]; |
35 let isPrivate = false; | 35 let isPrivate = false; |
36 | 36 |
37 let reportData = new DOMParser().parseFromString("<report></report>", "text/xml"
); | 37 let reportData = new DOMParser().parseFromString("<report></report>", "text/xml"
); |
38 | 38 |
39 // Some helper functions to work with the report data | 39 // Some helper functions to work with the report data |
40 function reportElement(tag) | 40 function reportElement(tag) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 }; | 104 }; |
105 | 105 |
106 // | 106 // |
107 // Data collectors | 107 // Data collectors |
108 // | 108 // |
109 | 109 |
110 var reportsListDataSource = | 110 var reportsListDataSource = |
111 { | 111 { |
112 list: [], | 112 list: [], |
113 | 113 |
114 collectData: function(wnd, windowURI, browser, callback) | 114 collectData: function(outerWindowID, windowURI, browser, callback) |
115 { | 115 { |
116 let data = Prefs.recentReports; | 116 let data = Prefs.recentReports; |
117 if (data && "length" in data) | 117 if (data && "length" in data) |
118 { | 118 { |
119 for (let i = 0; i < data.length; i++) | 119 for (let i = 0; i < data.length; i++) |
120 { | 120 { |
121 let entry = data[i]; | 121 let entry = data[i]; |
122 if (typeof entry.reportURL == "string" && entry.reportURL && | 122 if (typeof entry.reportURL == "string" && entry.reportURL && |
123 typeof entry.time == "number" && Date.now() - entry.time < 30*24*60*
60*1000) | 123 typeof entry.time == "number" && Date.now() - entry.time < 30*24*60*
60*1000) |
124 { | 124 { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 }; | 187 }; |
188 | 188 |
189 var requestsDataSource = | 189 var requestsDataSource = |
190 { | 190 { |
191 requests: reportElement("requests"), | 191 requests: reportElement("requests"), |
192 origRequests: [], | 192 origRequests: [], |
193 requestNotifier: null, | 193 requestNotifier: null, |
194 callback: null, | 194 callback: null, |
195 nodeByKey: Object.create(null), | 195 nodeByKey: Object.create(null), |
196 | 196 |
197 collectData: function(wnd, windowURI, browser, callback) | 197 collectData: function(outerWindowID, windowURI, browser, callback) |
198 { | 198 { |
199 let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) | |
200 .getInterface(Ci.nsIDOMWindowUtils) | |
201 .outerWindowID; | |
202 this.callback = callback; | 199 this.callback = callback; |
203 this.requestNotifier = new RequestNotifier(outerWindowID, this.onRequestFoun
d, this); | 200 this.requestNotifier = new RequestNotifier(outerWindowID, this.onRequestFoun
d, this); |
204 }, | 201 }, |
205 | 202 |
206 onRequestFound: function(entry, scanComplete) | 203 onRequestFound: function(entry, scanComplete) |
207 { | 204 { |
208 if (entry) | 205 if (entry) |
209 { | 206 { |
210 let key = entry.location + " " + entry.type + " " + entry.docDomain; | 207 let key = entry.location + " " + entry.type + " " + entry.docDomain; |
211 let requestXML; | 208 let requestXML; |
(...skipping 29 matching lines...) Expand all Loading... |
241 this.requestNotifier = null; | 238 this.requestNotifier = null; |
242 this.callback(); | 239 this.callback(); |
243 } | 240 } |
244 } | 241 } |
245 }; | 242 }; |
246 | 243 |
247 var filtersDataSource = | 244 var filtersDataSource = |
248 { | 245 { |
249 origFilters: [], | 246 origFilters: [], |
250 | 247 |
251 collectData: function(wnd, windowURI, browser, callback) | 248 collectData: function(outerWindowID, windowURI, browser, callback) |
252 { | 249 { |
253 let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) | |
254 .getInterface(Ci.nsIDOMWindowUtils) | |
255 .outerWindowID; | |
256 RequestNotifier.getWindowStatistics(outerWindowID, (wndStats) => | 250 RequestNotifier.getWindowStatistics(outerWindowID, (wndStats) => |
257 { | 251 { |
258 if (wndStats) | 252 if (wndStats) |
259 { | 253 { |
260 let filters = reportElement("filters"); | 254 let filters = reportElement("filters"); |
261 for (let f in wndStats.filters) | 255 for (let f in wndStats.filters) |
262 { | 256 { |
263 let filter = Filter.fromText(f) | 257 let filter = Filter.fromText(f) |
264 let hitCount = wndStats.filters[f]; | 258 let hitCount = wndStats.filters[f]; |
265 appendElement(filters, "filter", { | 259 appendElement(filters, "filter", { |
(...skipping 13 matching lines...) Expand all Loading... |
279 { | 273 { |
280 subscriptionFilter: function(s) | 274 subscriptionFilter: function(s) |
281 { | 275 { |
282 if (s.disabled || !(s instanceof RegularSubscription)) | 276 if (s.disabled || !(s instanceof RegularSubscription)) |
283 return false; | 277 return false; |
284 if (s instanceof DownloadableSubscription && !/^(http|https|ftp):/i.test(s.u
rl)) | 278 if (s instanceof DownloadableSubscription && !/^(http|https|ftp):/i.test(s.u
rl)) |
285 return false; | 279 return false; |
286 return true; | 280 return true; |
287 }, | 281 }, |
288 | 282 |
289 collectData: function(wnd, windowURI, browser, callback) | 283 collectData: function(outerWindowID, windowURI, browser, callback) |
290 { | 284 { |
291 let subscriptions = reportElement("subscriptions"); | 285 let subscriptions = reportElement("subscriptions"); |
292 let now = Math.round(Date.now() / 1000); | 286 let now = Math.round(Date.now() / 1000); |
293 for (let i = 0; i < FilterStorage.subscriptions.length; i++) | 287 for (let i = 0; i < FilterStorage.subscriptions.length; i++) |
294 { | 288 { |
295 let subscription = FilterStorage.subscriptions[i]; | 289 let subscription = FilterStorage.subscriptions[i]; |
296 if (!this.subscriptionFilter(subscription)) | 290 if (!this.subscriptionFilter(subscription)) |
297 continue; | 291 continue; |
298 | 292 |
299 let subscriptionXML = appendElement(subscriptions, "subscription", { | 293 let subscriptionXML = appendElement(subscriptions, "subscription", { |
(...skipping 14 matching lines...) Expand all Loading... |
314 subscriptionXML.setAttribute("hardExpiration", subscription.expires -
now); | 308 subscriptionXML.setAttribute("hardExpiration", subscription.expires -
now); |
315 subscriptionXML.setAttribute("downloadStatus", subscription.downloadStat
us); | 309 subscriptionXML.setAttribute("downloadStatus", subscription.downloadStat
us); |
316 } | 310 } |
317 } | 311 } |
318 callback(); | 312 callback(); |
319 } | 313 } |
320 }; | 314 }; |
321 | 315 |
322 var remoteDataSource = | 316 var remoteDataSource = |
323 { | 317 { |
324 collectData: function(wnd, windowURI, browser, callback) | 318 collectData: function(outerWindowID, windowURI, browser, callback) |
325 { | 319 { |
326 let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) | |
327 .getInterface(Ci.nsIDOMWindowUtils) | |
328 .outerWindowID; | |
329 let dataCollector = require("dataCollector"); | 320 let dataCollector = require("dataCollector"); |
330 let screenshotWidth = screenshotDataSource.getWidth(); | 321 let screenshotWidth = screenshotDataSource.getWidth(); |
331 dataCollector.collectData(outerWindowID, screenshotWidth, data => { | 322 dataCollector.collectData(outerWindowID, screenshotWidth, data => { |
332 screenshotDataSource.setData(data && data.screenshot); | 323 screenshotDataSource.setData(data && data.screenshot); |
333 framesDataSource.setData(windowURI, data && data.opener, data && data.refe
rrer, data && data.frames); | 324 framesDataSource.setData(windowURI, data && data.opener, data && data.refe
rrer, data && data.frames); |
334 | 325 |
335 if (data && data.isPrivate) | 326 if (data && data.isPrivate) |
336 isPrivate = true; | 327 isPrivate = true; |
337 let element = reportElement("options"); | 328 let element = reportElement("options"); |
338 appendElement(element, "option", {id: "privateBrowsing"}, isPrivate); | 329 appendElement(element, "option", {id: "privateBrowsing"}, isPrivate); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 let frameXML = appendElement(xmlList, "frame", { | 572 let frameXML = appendElement(xmlList, "frame", { |
582 url: censorURL(frame.url) | 573 url: censorURL(frame.url) |
583 }); | 574 }); |
584 this.addFrames(frame.frames, frameXML); | 575 this.addFrames(frame.frames, frameXML); |
585 } | 576 } |
586 } | 577 } |
587 }; | 578 }; |
588 | 579 |
589 var errorsDataSource = | 580 var errorsDataSource = |
590 { | 581 { |
591 collectData: function(wnd, windowURI, browser, callback) | 582 collectData: function(outerWindowID, windowURI, browser, callback) |
592 { | 583 { |
593 let {addonID} = require("info"); | 584 let {addonID} = require("info"); |
594 addonID = addonID.replace(/[\{\}]/g, ""); | 585 addonID = addonID.replace(/[\{\}]/g, ""); |
595 | 586 |
596 // See https://bugzilla.mozilla.org/show_bug.cgi?id=664695 - starting with | 587 // See https://bugzilla.mozilla.org/show_bug.cgi?id=664695 - starting with |
597 // Gecko 19 this function returns the result, before that it wrote to a | 588 // Gecko 19 this function returns the result, before that it wrote to a |
598 // parameter. | 589 // parameter. |
599 let outparam = {}; | 590 let outparam = {}; |
600 let messages = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleS
ervice).getMessageArray(outparam, {}); | 591 let messages = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleS
ervice).getMessageArray(outparam, {}); |
601 messages = messages || outparam.value || []; | 592 messages = messages || outparam.value || []; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 } | 647 } |
657 | 648 |
658 callback(); | 649 callback(); |
659 } | 650 } |
660 }; | 651 }; |
661 | 652 |
662 var extensionsDataSource = | 653 var extensionsDataSource = |
663 { | 654 { |
664 data: reportData.createElement("extensions"), | 655 data: reportData.createElement("extensions"), |
665 | 656 |
666 collectData: function(wnd, windowURI, browser, callback) | 657 collectData: function(outerWindowID, windowURI, browser, callback) |
667 { | 658 { |
668 try | 659 try |
669 { | 660 { |
670 let AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm", nu
ll).AddonManager; | 661 let AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm", nu
ll).AddonManager; |
671 AddonManager.getAddonsByTypes(["extension", "plugin"], function(items) | 662 AddonManager.getAddonsByTypes(["extension", "plugin"], function(items) |
672 { | 663 { |
673 for (let i = 0; i < items.length; i++) | 664 for (let i = 0; i < items.length; i++) |
674 { | 665 { |
675 let item = items[i]; | 666 let item = items[i]; |
676 if (!item.isActive) | 667 if (!item.isActive) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 needUpdate: null, | 700 needUpdate: null, |
710 | 701 |
711 subscriptionFilter: function(s) | 702 subscriptionFilter: function(s) |
712 { | 703 { |
713 if (s instanceof DownloadableSubscription) | 704 if (s instanceof DownloadableSubscription) |
714 return subscriptionsDataSource.subscriptionFilter(s); | 705 return subscriptionsDataSource.subscriptionFilter(s); |
715 else | 706 else |
716 return false; | 707 return false; |
717 }, | 708 }, |
718 | 709 |
719 collectData: function(wnd, windowURI, browser, callback) | 710 collectData: function(outerWindowID, windowURI, browser, callback) |
720 { | 711 { |
721 this.browser = browser; | 712 this.browser = browser; |
722 let now = Date.now() / MILLISECONDS_IN_SECOND; | 713 let now = Date.now() / MILLISECONDS_IN_SECOND; |
723 let outdatedThreshold = now - 14 * SECONDS_IN_DAY; | 714 let outdatedThreshold = now - 14 * SECONDS_IN_DAY; |
724 let needUpdateThreshold = now - 1 * SECONDS_IN_HOUR; | 715 let needUpdateThreshold = now - 1 * SECONDS_IN_HOUR; |
725 | 716 |
726 this.outdated = []; | 717 this.outdated = []; |
727 this.needUpdate = []; | 718 this.needUpdate = []; |
728 | 719 |
729 let subscriptions = FilterStorage.subscriptions.filter(this.subscriptionFilt
er); | 720 let subscriptions = FilterStorage.subscriptions.filter(this.subscriptionFilt
er); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 if (s instanceof DownloadableSubscription && | 866 if (s instanceof DownloadableSubscription && |
876 s.url != Prefs.subscriptions_exceptionsurl && | 867 s.url != Prefs.subscriptions_exceptionsurl && |
877 s.url != Prefs.subscriptions_antiadblockurl) | 868 s.url != Prefs.subscriptions_antiadblockurl) |
878 { | 869 { |
879 return subscriptionsDataSource.subscriptionFilter(s); | 870 return subscriptionsDataSource.subscriptionFilter(s); |
880 } | 871 } |
881 else | 872 else |
882 return false; | 873 return false; |
883 }, | 874 }, |
884 | 875 |
885 collectData: function(wnd, windowURI, browser, callback) | 876 collectData: function(outerWindowID, windowURI, browser, callback) |
886 { | 877 { |
887 this.browser = browser; | 878 this.browser = browser; |
888 this.whitelistFilter = Policy.isWhitelisted(windowURI.spec); | 879 this.whitelistFilter = Policy.isWhitelisted(windowURI.spec); |
889 | 880 |
890 if (!this.whitelistFilter && this.isEnabled) | 881 if (!this.whitelistFilter && this.isEnabled) |
891 { | 882 { |
892 // Find disabled filters in active subscriptions matching any of the reque
sts | 883 // Find disabled filters in active subscriptions matching any of the reque
sts |
893 let disabledMatcher = new CombinedMatcher(); | 884 let disabledMatcher = new CombinedMatcher(); |
894 for (let subscription of FilterStorage.subscriptions) | 885 for (let subscription of FilterStorage.subscriptions) |
895 { | 886 { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 { | 1224 { |
1234 let progressMeter = E("dataCollectorProgress"); | 1225 let progressMeter = E("dataCollectorProgress"); |
1235 progressMeter.mode = "determined"; | 1226 progressMeter.mode = "determined"; |
1236 progressMeter.value = progress; | 1227 progressMeter.value = progress; |
1237 } | 1228 } |
1238 | 1229 |
1239 // Continue with the next data source, asynchronously to allow progress mete
r to update | 1230 // Continue with the next data source, asynchronously to allow progress mete
r to update |
1240 let dataSource = dataCollectors.shift(); | 1231 let dataSource = dataCollectors.shift(); |
1241 Utils.runAsync(function() | 1232 Utils.runAsync(function() |
1242 { | 1233 { |
1243 dataSource.collectData(contentWindow, windowURI, browser, initNextDataSour
ce); | 1234 dataSource.collectData(outerWindowID, windowURI, browser, initNextDataSour
ce); |
1244 }); | 1235 }); |
1245 }; | 1236 }; |
1246 | 1237 |
1247 initNextDataSource(); | 1238 initNextDataSource(); |
1248 } | 1239 } |
1249 | 1240 |
1250 function initTypeSelectorPage() | 1241 function initTypeSelectorPage() |
1251 { | 1242 { |
1252 E("progressBar").activeItem = E("typeSelectorHeader"); | 1243 E("progressBar").activeItem = E("typeSelectorHeader"); |
1253 let header = document.getAnonymousElementByAttribute(document.documentElement,
"class", "wizard-header"); | 1244 let header = document.getAnonymousElementByAttribute(document.documentElement,
"class", "wizard-header"); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 | 1547 |
1557 function censorURL(url) | 1548 function censorURL(url) |
1558 { | 1549 { |
1559 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); | 1550 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); |
1560 } | 1551 } |
1561 | 1552 |
1562 function encodeHTML(str) | 1553 function encodeHTML(str) |
1563 { | 1554 { |
1564 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); | 1555 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); |
1565 } | 1556 } |
OLD | NEW |