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

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

Issue 9043026: Adapted private browsing handling to per-window private browsing in Firefox 20 (Closed)
Patch Set: Created Dec. 19, 2012, 2:35 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 | lib/contentPolicy.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 the Adblock Plus, 2 * This file is part of the Adblock Plus,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 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 Cu.import("resource://gre/modules/Services.jsm");
23 Cu.import("resource://gre/modules/FileUtils.jsm"); 23 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];
31 let windowURI = (window.arguments[1] instanceof Ci.nsIURI ? window.arguments[1] : null);
32
30 let reportData = new DOMParser().parseFromString("<report></report>", "text/xml" ); 33 let reportData = new DOMParser().parseFromString("<report></report>", "text/xml" );
31 34
32 // Some helper functions to work with the report data 35 // Some helper functions to work with the report data
33 function reportElement(tag) 36 function reportElement(tag)
34 { 37 {
35 for (let child = reportData.documentElement.firstChild; child; child = child.n extSibling) 38 for (let child = reportData.documentElement.firstChild; child; child = child.n extSibling)
36 if (child.nodeType == Node.ELEMENT_NODE && child.tagName == tag) 39 if (child.nodeType == Node.ELEMENT_NODE && child.tagName == tag)
37 return child; 40 return child;
38 let element = reportData.createElement(tag); 41 let element = reportData.createElement(tag);
39 reportData.documentElement.appendChild(element); 42 reportData.documentElement.appendChild(element);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 { 87 {
85 element.setAttribute("name", "Gecko"); 88 element.setAttribute("name", "Gecko");
86 element.setAttribute("version", Services.appinfo.platformVersion); 89 element.setAttribute("version", Services.appinfo.platformVersion);
87 element.setAttribute("build", Services.appinfo.platformBuildID); 90 element.setAttribute("build", Services.appinfo.platformBuildID);
88 }; 91 };
89 let (element = reportElement("options")) 92 let (element = reportElement("options"))
90 { 93 {
91 appendElement(element, "option", {id: "enabled"}, Prefs.enabled); 94 appendElement(element, "option", {id: "enabled"}, Prefs.enabled);
92 appendElement(element, "option", {id: "objecttabs"}, Prefs.frameobjects); 95 appendElement(element, "option", {id: "objecttabs"}, Prefs.frameobjects);
93 appendElement(element, "option", {id: "collapse"}, !Prefs.fastcollapse); 96 appendElement(element, "option", {id: "collapse"}, !Prefs.fastcollapse);
94 appendElement(element, "option", {id: "privateBrowsing"}, PrivateBrowsing.enab led); 97 appendElement(element, "option", {id: "privateBrowsing"}, PrivateBrowsing.enab ledForWindow(contentWindow) || PrivateBrowsing.enabled);
95 appendElement(element, "option", {id: "subscriptionsAutoUpdate"}, Prefs.subscr iptions_autoupdate); 98 appendElement(element, "option", {id: "subscriptionsAutoUpdate"}, Prefs.subscr iptions_autoupdate);
96 appendElement(element, "option", {id: "javascript"}, Services.prefs.getBoolPre f("javascript.enabled")); 99 appendElement(element, "option", {id: "javascript"}, Services.prefs.getBoolPre f("javascript.enabled"));
97 appendElement(element, "option", {id: "cookieBehavior"}, Services.prefs.getInt Pref("network.cookie.cookieBehavior")); 100 appendElement(element, "option", {id: "cookieBehavior"}, Services.prefs.getInt Pref("network.cookie.cookieBehavior"));
98 }; 101 };
99 102
100 // 103 //
101 // Data collectors 104 // Data collectors
102 // 105 //
103 106
104 let reportsListDataSource = 107 let reportsListDataSource =
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 nextButton.setAttribute("accesskey", nextButton.getAttribute("_origAccessK ey")); 1217 nextButton.setAttribute("accesskey", nextButton.getAttribute("_origAccessK ey"));
1215 nextButton.removeAttribute("_origAccessKey"); 1218 nextButton.removeAttribute("_origAccessKey");
1216 } 1219 }
1217 } 1220 }
1218 } 1221 }
1219 1222
1220 function initDataCollectorPage() 1223 function initDataCollectorPage()
1221 { 1224 {
1222 document.documentElement.canAdvance = false; 1225 document.documentElement.canAdvance = false;
1223 1226
1224 let contentWindow = window.arguments[0];
1225 let windowURI = (window.arguments[1] instanceof Ci.nsIURI ? window.arguments[1 ] : null);
1226 let totalSteps = dataCollectors.length; 1227 let totalSteps = dataCollectors.length;
1227 let initNextDataSource = function() 1228 let initNextDataSource = function()
1228 { 1229 {
1229 if (!dataCollectors.length) 1230 if (!dataCollectors.length)
1230 { 1231 {
1231 // We are done, continue to next page 1232 // We are done, continue to next page
1232 document.documentElement.canAdvance = true; 1233 document.documentElement.canAdvance = true;
1233 document.documentElement.advance(); 1234 document.documentElement.advance();
1234 return; 1235 return;
1235 } 1236 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 document.documentElement.canAdvance = true; 1327 document.documentElement.canAdvance = true;
1327 1328
1328 E("progressBar").activeItem = E("screenshotHeader"); 1329 E("progressBar").activeItem = E("screenshotHeader");
1329 } 1330 }
1330 1331
1331 function initCommentPage() 1332 function initCommentPage()
1332 { 1333 {
1333 E("progressBar").activeItem = E("commentPageHeader"); 1334 E("progressBar").activeItem = E("commentPageHeader");
1334 1335
1335 updateEmail(); 1336 updateEmail();
1336 1337
1337 screenshotDataSource.exportData(); 1338 screenshotDataSource.exportData();
1338 updateDataField(); 1339 updateDataField();
1339 } 1340 }
1340 1341
1341 function showDataField() 1342 function showDataField()
1342 { 1343 {
1343 E('dataDeck').selectedIndex = 1; 1344 E('dataDeck').selectedIndex = 1;
1344 updateDataField(); 1345 updateDataField();
1345 E('data').focus(); 1346 E('data').focus();
1346 } 1347 }
(...skipping 29 matching lines...) Expand all
1376 1377
1377 let value = E("comment").value; 1378 let value = E("comment").value;
1378 appendElement(reportData.documentElement, "comment", null, value.substr(0, 100 0)); 1379 appendElement(reportData.documentElement, "comment", null, value.substr(0, 100 0));
1379 E("commentLengthWarning").setAttribute("visible", value.length > 1000); 1380 E("commentLengthWarning").setAttribute("visible", value.length > 1000);
1380 updateDataField(); 1381 updateDataField();
1381 } 1382 }
1382 1383
1383 function updateEmail() 1384 function updateEmail()
1384 { 1385 {
1385 removeReportElement("email"); 1386 removeReportElement("email");
1386 1387
1387 let anonymous = E("anonymousCheckbox").checked; 1388 let anonymous = E("anonymousCheckbox").checked;
1388 1389
1389 let value = E("email").value; 1390 let value = E("email").value;
1390 1391
1391 // required for persist to work on textbox, see: https://bugzilla.mozilla.org/ show_bug.cgi?id=111486 1392 // required for persist to work on textbox, see: https://bugzilla.mozilla.org/ show_bug.cgi?id=111486
1392 E("email").setAttribute("value", value); 1393 E("email").setAttribute("value", value);
1393 1394
1394 E("email").disabled = anonymous; 1395 E("email").disabled = anonymous;
1395 E("emailLabel").disabled = anonymous; 1396 E("emailLabel").disabled = anonymous;
1396 E("anonymityWarning").setAttribute("visible", anonymous); 1397 E("anonymityWarning").setAttribute("visible", anonymous);
1397 1398
1398 if (!anonymous) 1399 if (!anonymous)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 1523
1523 if (success) 1524 if (success)
1524 { 1525 {
1525 try 1526 try
1526 { 1527 {
1527 let link = request.responseXML.getElementById("link").getAttribute("href") ; 1528 let link = request.responseXML.getElementById("link").getAttribute("href") ;
1528 let button = E("copyLink"); 1529 let button = E("copyLink");
1529 button.setAttribute("url", link); 1530 button.setAttribute("url", link);
1530 button.removeAttribute("disabled"); 1531 button.removeAttribute("disabled");
1531 1532
1532 if (!PrivateBrowsing.enabled) 1533 if (!PrivateBrowsing.enabledForWindow(contentWindow) && !PrivateBrowsing.e nabled)
1533 reportsListDataSource.addReport(framesDataSource.site, link); 1534 reportsListDataSource.addReport(framesDataSource.site, link);
1534 } catch (e) {} 1535 } catch (e) {}
1535 E("copyLinkBox").hidden = false; 1536 E("copyLinkBox").hidden = false;
1536 1537
1537 document.documentElement.getButton("finish").disabled = false; 1538 document.documentElement.getButton("finish").disabled = false;
1538 document.documentElement.getButton("cancel").disabled = true; 1539 document.documentElement.getButton("cancel").disabled = true;
1539 E("progressBar").activeItemComplete = true; 1540 E("progressBar").activeItemComplete = true;
1540 } 1541 }
1541 } 1542 }
1542 1543
(...skipping 16 matching lines...) Expand all
1559 1560
1560 function censorURL(url) 1561 function censorURL(url)
1561 { 1562 {
1562 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); 1563 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*");
1563 } 1564 }
1564 1565
1565 function encodeHTML(str) 1566 function encodeHTML(str)
1566 { 1567 {
1567 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;"); 1568 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;");
1568 } 1569 }
OLDNEW
« no previous file with comments | « no previous file | lib/contentPolicy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld