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

Side by Side Diff: chrome/content/ui/sendReport.js

Issue 29329823: Issue 3278 - Adjust Issue Reporter to e10s-related API changes (Closed)
Patch Set: Created Nov. 6, 2015, 1:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/content/ui/utils.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Cu.import("resource://gre/modules/Services.jsm"); 22 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
23 Cu.import("resource://gre/modules/FileUtils.jsm"); 23 let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {});
24 let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/PrivateBrowsingUt ils.jsm", {});
24 25
25 const MILLISECONDS_IN_SECOND = 1000; 26 const MILLISECONDS_IN_SECOND = 1000;
26 const SECONDS_IN_MINUTE = 60; 27 const SECONDS_IN_MINUTE = 60;
27 const SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE; 28 const SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE;
28 const SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR; 29 const SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR;
29 30
30 let contentWindow = window.arguments[0]; 31 let contentWindow = window.arguments[0];
31 let windowURI = (window.arguments[1] instanceof Ci.nsIURI ? window.arguments[1] : null); 32 let windowURI = (window.arguments[1] instanceof Ci.nsIURI ? window.arguments[1] : null);
32 33
33 let reportData = new DOMParser().parseFromString("<report></report>", "text/xml" ); 34 let reportData = new DOMParser().parseFromString("<report></report>", "text/xml" );
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 let element = reportElement("platform"); 88 let element = reportElement("platform");
88 element.setAttribute("name", "Gecko"); 89 element.setAttribute("name", "Gecko");
89 element.setAttribute("version", Services.appinfo.platformVersion); 90 element.setAttribute("version", Services.appinfo.platformVersion);
90 element.setAttribute("build", Services.appinfo.platformBuildID); 91 element.setAttribute("build", Services.appinfo.platformBuildID);
91 }; 92 };
92 { 93 {
93 let element = reportElement("options"); 94 let element = reportElement("options");
94 appendElement(element, "option", {id: "enabled"}, Prefs.enabled); 95 appendElement(element, "option", {id: "enabled"}, Prefs.enabled);
95 appendElement(element, "option", {id: "objecttabs"}, Prefs.frameobjects); 96 appendElement(element, "option", {id: "objecttabs"}, Prefs.frameobjects);
96 appendElement(element, "option", {id: "collapse"}, !Prefs.fastcollapse); 97 appendElement(element, "option", {id: "collapse"}, !Prefs.fastcollapse);
97 appendElement(element, "option", {id: "privateBrowsing"}, PrivateBrowsing.enab ledForWindow(contentWindow) || PrivateBrowsing.enabled); 98 appendElement(element, "option", {id: "privateBrowsing"}, PrivateBrowsingUtils .isContentWindowPrivate(contentWindow));
98 appendElement(element, "option", {id: "subscriptionsAutoUpdate"}, Prefs.subscr iptions_autoupdate); 99 appendElement(element, "option", {id: "subscriptionsAutoUpdate"}, Prefs.subscr iptions_autoupdate);
99 appendElement(element, "option", {id: "javascript"}, Services.prefs.getBoolPre f("javascript.enabled")); 100 appendElement(element, "option", {id: "javascript"}, Services.prefs.getBoolPre f("javascript.enabled"));
100 appendElement(element, "option", {id: "cookieBehavior"}, Services.prefs.getInt Pref("network.cookie.cookieBehavior")); 101 appendElement(element, "option", {id: "cookieBehavior"}, Services.prefs.getInt Pref("network.cookie.cookieBehavior"));
101 }; 102 };
102 103
103 // 104 //
104 // Data collectors 105 // Data collectors
105 // 106 //
106 107
107 let reportsListDataSource = 108 let reportsListDataSource =
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 let requestsDataSource = 187 let requestsDataSource =
187 { 188 {
188 requests: reportElement("requests"), 189 requests: reportElement("requests"),
189 origRequests: [], 190 origRequests: [],
190 requestNotifier: null, 191 requestNotifier: null,
191 callback: null, 192 callback: null,
192 nodeByKey: Object.create(null), 193 nodeByKey: Object.create(null),
193 194
194 collectData: function(wnd, windowURI, callback) 195 collectData: function(wnd, windowURI, callback)
195 { 196 {
197 let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor)
198 .getInterface(Ci.nsIDOMWindowUtils)
199 .outerWindowID;
196 this.callback = callback; 200 this.callback = callback;
197 this.requestNotifier = new RequestNotifier(wnd, this.onRequestFound, this); 201 this.requestNotifier = new RequestNotifier(outerWindowID, this.onRequestFoun d, this);
198 }, 202 },
199 203
200 onRequestFound: function(frame, node, entry, scanComplete) 204 onRequestFound: function(entry, scanComplete)
201 { 205 {
202 if (entry) 206 if (entry)
203 { 207 {
204 let key = entry.location + " " + entry.type + " " + entry.docDomain; 208 let key = entry.location + " " + entry.type + " " + entry.docDomain;
205 let requestXML; 209 let requestXML;
206 if (key in this.nodeByKey) 210 if (key in this.nodeByKey)
207 { 211 {
208 requestXML = this.nodeByKey[key]; 212 requestXML = this.nodeByKey[key];
209 requestXML.setAttribute("count", parseInt(requestXML.getAttribute("count "), 10) + 1); 213 requestXML.setAttribute("count", parseInt(requestXML.getAttribute("count "), 10) + 1);
210 } 214 }
211 else 215 else
212 { 216 {
213 requestXML = this.nodeByKey[key] = appendElement(this.requests, "request ", { 217 requestXML = this.nodeByKey[key] = appendElement(this.requests, "request ", {
214 location: censorURL(entry.location), 218 location: censorURL(entry.location),
215 type: entry.type, 219 type: entry.type,
216 docDomain: entry.docDomain, 220 docDomain: entry.docDomain,
217 thirdParty: entry.thirdParty, 221 thirdParty: entry.thirdParty,
218 count: 1 222 count: 1
219 }); 223 });
224
225 // Location is meaningless for element hiding hits
226 if (requestXML.getAttribute("location")[0] == "#")
227 requestXML.removeAttribute("location");
220 } 228 }
221 229
222 // Location is meaningless for element hiding hits 230 if (entry.filter)
223 if (entry.filter && entry.filter instanceof ElemHideBase) 231 requestXML.setAttribute("filter", entry.filter);
224 requestXML.removeAttribute("location");
225 232
226 if (entry.filter)
227 requestXML.setAttribute("filter", entry.filter.text);
228
229 if (node instanceof Element)
230 {
231 requestXML.setAttribute("node", (node.namespaceURI ? node.namespaceURI + "#" : "") + node.localName);
232
233 try
234 {
235 requestXML.setAttribute("size", node.offsetWidth + "x" + node.offsetHe ight);
236 } catch(e) {}
237 }
238 this.origRequests.push(entry); 233 this.origRequests.push(entry);
239 } 234 }
240 235
241 if (scanComplete) 236 if (scanComplete)
242 { 237 {
243 this.requestNotifier.shutdown(); 238 this.requestNotifier.shutdown();
244 this.requestNotifier = null; 239 this.requestNotifier = null;
245 this.callback(); 240 this.callback();
246 } 241 }
247 } 242 }
248 }; 243 };
249 244
250 let filtersDataSource = 245 let filtersDataSource =
251 { 246 {
252 origFilters: [], 247 origFilters: [],
253 248
254 collectData: function(wnd, windowURI, callback) 249 collectData: function(wnd, windowURI, callback)
255 { 250 {
256 let wndStats = RequestNotifier.getWindowStatistics(wnd); 251 let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor)
257 if (wndStats) 252 .getInterface(Ci.nsIDOMWindowUtils)
253 .outerWindowID;
254 RequestNotifier.getWindowStatistics(outerWindowID, (wndStats) =>
258 { 255 {
259 let filters = reportElement("filters"); 256 if (wndStats)
260 for (let f in wndStats.filters)
261 { 257 {
262 let filter = Filter.fromText(f) 258 let filters = reportElement("filters");
263 let hitCount = wndStats.filters[f]; 259 for (let f in wndStats.filters)
264 appendElement(filters, "filter", { 260 {
265 text: filter.text, 261 let filter = Filter.fromText(f)
266 subscriptions: filter.subscriptions.filter(subscriptionsDataSource.sub scriptionFilter).map(s => s.url).join(" "), 262 let hitCount = wndStats.filters[f];
267 hitCount: hitCount 263 appendElement(filters, "filter", {
268 }); 264 text: filter.text,
269 this.origFilters.push(filter); 265 subscriptions: filter.subscriptions.filter(subscriptionsDataSource.s ubscriptionFilter).map(s => s.url).join(" "),
266 hitCount: hitCount
267 });
268 this.origFilters.push(filter);
269 }
270 } 270 }
271 } 271 callback();
272 callback(); 272 });
273 } 273 }
274 }; 274 };
275 275
276 let subscriptionsDataSource = 276 let subscriptionsDataSource =
277 { 277 {
278 subscriptionFilter: function(s) 278 subscriptionFilter: function(s)
279 { 279 {
280 if (s.disabled || !(s instanceof RegularSubscription)) 280 if (s.disabled || !(s instanceof RegularSubscription))
281 return false; 281 return false;
282 if (s instanceof DownloadableSubscription && !/^(http|https|ftp):/i.test(s.u rl)) 282 if (s instanceof DownloadableSubscription && !/^(http|https|ftp):/i.test(s.u rl))
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 1537
1538 if (success) 1538 if (success)
1539 { 1539 {
1540 try 1540 try
1541 { 1541 {
1542 let link = request.responseXML.getElementById("link").getAttribute("href") ; 1542 let link = request.responseXML.getElementById("link").getAttribute("href") ;
1543 let button = E("copyLink"); 1543 let button = E("copyLink");
1544 button.setAttribute("url", link); 1544 button.setAttribute("url", link);
1545 button.removeAttribute("disabled"); 1545 button.removeAttribute("disabled");
1546 1546
1547 if (!PrivateBrowsing.enabledForWindow(contentWindow) && !PrivateBrowsing.e nabled) 1547 if (!PrivateBrowsingUtils.isContentWindowPrivate(contentWindow))
1548 reportsListDataSource.addReport(framesDataSource.site, link); 1548 reportsListDataSource.addReport(framesDataSource.site, link);
1549 } catch (e) {} 1549 } catch (e) {}
1550 E("copyLinkBox").hidden = false; 1550 E("copyLinkBox").hidden = false;
1551 1551
1552 document.documentElement.getButton("finish").disabled = false; 1552 document.documentElement.getButton("finish").disabled = false;
1553 document.documentElement.getButton("cancel").disabled = true; 1553 document.documentElement.getButton("cancel").disabled = true;
1554 E("progressBar").activeItemComplete = true; 1554 E("progressBar").activeItemComplete = true;
1555 } 1555 }
1556 } 1556 }
1557 1557
(...skipping 19 matching lines...) Expand all
1577 1577
1578 function censorURL(url) 1578 function censorURL(url)
1579 { 1579 {
1580 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); 1580 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*");
1581 } 1581 }
1582 1582
1583 function encodeHTML(str) 1583 function encodeHTML(str)
1584 { 1584 {
1585 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;"); 1585 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;");
1586 } 1586 }
OLDNEW
« no previous file with comments | « no previous file | chrome/content/ui/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld