Index: chrome/content/ui/sendReport.js |
=================================================================== |
--- a/chrome/content/ui/sendReport.js |
+++ b/chrome/content/ui/sendReport.js |
@@ -14,18 +14,19 @@ |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
// |
// Report data template, more data will be added during data collection |
// |
-Cu.import("resource://gre/modules/Services.jsm"); |
-Cu.import("resource://gre/modules/FileUtils.jsm"); |
+let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
+let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", {}); |
+let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm", {}); |
const MILLISECONDS_IN_SECOND = 1000; |
const SECONDS_IN_MINUTE = 60; |
const SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE; |
const SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR; |
let contentWindow = window.arguments[0]; |
let windowURI = (window.arguments[1] instanceof Ci.nsIURI ? window.arguments[1] : null); |
@@ -89,17 +90,17 @@ function serializeReportData() |
element.setAttribute("version", Services.appinfo.platformVersion); |
element.setAttribute("build", Services.appinfo.platformBuildID); |
}; |
{ |
let element = reportElement("options"); |
appendElement(element, "option", {id: "enabled"}, Prefs.enabled); |
appendElement(element, "option", {id: "objecttabs"}, Prefs.frameobjects); |
appendElement(element, "option", {id: "collapse"}, !Prefs.fastcollapse); |
- appendElement(element, "option", {id: "privateBrowsing"}, PrivateBrowsing.enabledForWindow(contentWindow) || PrivateBrowsing.enabled); |
+ appendElement(element, "option", {id: "privateBrowsing"}, PrivateBrowsingUtils.isContentWindowPrivate(contentWindow)); |
appendElement(element, "option", {id: "subscriptionsAutoUpdate"}, Prefs.subscriptions_autoupdate); |
appendElement(element, "option", {id: "javascript"}, Services.prefs.getBoolPref("javascript.enabled")); |
appendElement(element, "option", {id: "cookieBehavior"}, Services.prefs.getIntPref("network.cookie.cookieBehavior")); |
}; |
// |
// Data collectors |
// |
@@ -188,21 +189,24 @@ let requestsDataSource = |
requests: reportElement("requests"), |
origRequests: [], |
requestNotifier: null, |
callback: null, |
nodeByKey: Object.create(null), |
collectData: function(wnd, windowURI, callback) |
{ |
+ let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
+ .getInterface(Ci.nsIDOMWindowUtils) |
+ .outerWindowID; |
this.callback = callback; |
- this.requestNotifier = new RequestNotifier(wnd, this.onRequestFound, this); |
+ this.requestNotifier = new RequestNotifier(outerWindowID, this.onRequestFound, this); |
}, |
- onRequestFound: function(frame, node, entry, scanComplete) |
+ onRequestFound: function(entry, scanComplete) |
{ |
if (entry) |
{ |
let key = entry.location + " " + entry.type + " " + entry.docDomain; |
let requestXML; |
if (key in this.nodeByKey) |
{ |
requestXML = this.nodeByKey[key]; |
@@ -212,34 +216,25 @@ let requestsDataSource = |
{ |
requestXML = this.nodeByKey[key] = appendElement(this.requests, "request", { |
location: censorURL(entry.location), |
type: entry.type, |
docDomain: entry.docDomain, |
thirdParty: entry.thirdParty, |
count: 1 |
}); |
+ |
+ // Location is meaningless for element hiding hits |
+ if (requestXML.getAttribute("location")[0] == "#") |
+ requestXML.removeAttribute("location"); |
} |
- // Location is meaningless for element hiding hits |
- if (entry.filter && entry.filter instanceof ElemHideBase) |
- requestXML.removeAttribute("location"); |
+ if (entry.filter) |
+ requestXML.setAttribute("filter", entry.filter); |
- if (entry.filter) |
- requestXML.setAttribute("filter", entry.filter.text); |
- |
- if (node instanceof Element) |
- { |
- requestXML.setAttribute("node", (node.namespaceURI ? node.namespaceURI + "#" : "") + node.localName); |
- |
- try |
- { |
- requestXML.setAttribute("size", node.offsetWidth + "x" + node.offsetHeight); |
- } catch(e) {} |
- } |
this.origRequests.push(entry); |
} |
if (scanComplete) |
{ |
this.requestNotifier.shutdown(); |
this.requestNotifier = null; |
this.callback(); |
@@ -248,33 +243,38 @@ let requestsDataSource = |
}; |
let filtersDataSource = |
{ |
origFilters: [], |
collectData: function(wnd, windowURI, callback) |
{ |
- let wndStats = RequestNotifier.getWindowStatistics(wnd); |
- if (wndStats) |
+ let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) |
+ .getInterface(Ci.nsIDOMWindowUtils) |
+ .outerWindowID; |
+ RequestNotifier.getWindowStatistics(outerWindowID, (wndStats) => |
{ |
- let filters = reportElement("filters"); |
- for (let f in wndStats.filters) |
+ if (wndStats) |
{ |
- let filter = Filter.fromText(f) |
- let hitCount = wndStats.filters[f]; |
- appendElement(filters, "filter", { |
- text: filter.text, |
- subscriptions: filter.subscriptions.filter(subscriptionsDataSource.subscriptionFilter).map(s => s.url).join(" "), |
- hitCount: hitCount |
- }); |
- this.origFilters.push(filter); |
+ let filters = reportElement("filters"); |
+ for (let f in wndStats.filters) |
+ { |
+ let filter = Filter.fromText(f) |
+ let hitCount = wndStats.filters[f]; |
+ appendElement(filters, "filter", { |
+ text: filter.text, |
+ subscriptions: filter.subscriptions.filter(subscriptionsDataSource.subscriptionFilter).map(s => s.url).join(" "), |
+ hitCount: hitCount |
+ }); |
+ this.origFilters.push(filter); |
+ } |
} |
- } |
- callback(); |
+ callback(); |
+ }); |
} |
}; |
let subscriptionsDataSource = |
{ |
subscriptionFilter: function(s) |
{ |
if (s.disabled || !(s instanceof RegularSubscription)) |
@@ -1539,17 +1539,17 @@ function reportSent(event) |
{ |
try |
{ |
let link = request.responseXML.getElementById("link").getAttribute("href"); |
let button = E("copyLink"); |
button.setAttribute("url", link); |
button.removeAttribute("disabled"); |
- if (!PrivateBrowsing.enabledForWindow(contentWindow) && !PrivateBrowsing.enabled) |
+ if (!PrivateBrowsingUtils.isContentWindowPrivate(contentWindow)) |
reportsListDataSource.addReport(framesDataSource.site, link); |
} catch (e) {} |
E("copyLinkBox").hidden = false; |
document.documentElement.getButton("finish").disabled = false; |
document.documentElement.getButton("cancel").disabled = true; |
E("progressBar").activeItemComplete = true; |
} |