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

Unified Diff: chrome/content/ui/sendReport.js

Issue 29333320: Issue 3486 - Issue reporter: remove content window access (Closed)
Patch Set: Created Jan. 7, 2016, 7:32 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/ui.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/sendReport.js
===================================================================
--- a/chrome/content/ui/sendReport.js
+++ b/chrome/content/ui/sendReport.js
@@ -22,17 +22,17 @@
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.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 outerWindowID = window.arguments[0];
let windowURI = window.arguments[1];
if (typeof windowURI == "string")
windowURI = Services.newURI(windowURI, null, null);
let browser = window.arguments[2];
let isPrivate = false;
let reportData = new DOMParser().parseFromString("<report></report>", "text/xml");
@@ -106,17 +106,17 @@ function serializeReportData()
//
// Data collectors
//
var reportsListDataSource =
{
list: [],
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
let data = Prefs.recentReports;
if (data && "length" in data)
{
for (let i = 0; i < data.length; i++)
{
let entry = data[i];
if (typeof entry.reportURL == "string" && entry.reportURL &&
@@ -189,21 +189,18 @@ var reportsListDataSource =
var requestsDataSource =
{
requests: reportElement("requests"),
origRequests: [],
requestNotifier: null,
callback: null,
nodeByKey: Object.create(null),
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
- let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils)
- .outerWindowID;
this.callback = callback;
this.requestNotifier = new RequestNotifier(outerWindowID, this.onRequestFound, this);
},
onRequestFound: function(entry, scanComplete)
{
if (entry)
{
@@ -243,21 +240,18 @@ var requestsDataSource =
}
}
};
var filtersDataSource =
{
origFilters: [],
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
- let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils)
- .outerWindowID;
RequestNotifier.getWindowStatistics(outerWindowID, (wndStats) =>
{
if (wndStats)
{
let filters = reportElement("filters");
for (let f in wndStats.filters)
{
let filter = Filter.fromText(f)
@@ -281,17 +275,17 @@ var subscriptionsDataSource =
{
if (s.disabled || !(s instanceof RegularSubscription))
return false;
if (s instanceof DownloadableSubscription && !/^(http|https|ftp):/i.test(s.url))
return false;
return true;
},
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
let subscriptions = reportElement("subscriptions");
let now = Math.round(Date.now() / 1000);
for (let i = 0; i < FilterStorage.subscriptions.length; i++)
{
let subscription = FilterStorage.subscriptions[i];
if (!this.subscriptionFilter(subscription))
continue;
@@ -316,21 +310,18 @@ var subscriptionsDataSource =
}
}
callback();
}
};
var remoteDataSource =
{
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
- let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils)
- .outerWindowID;
let dataCollector = require("dataCollector");
let screenshotWidth = screenshotDataSource.getWidth();
dataCollector.collectData(outerWindowID, screenshotWidth, data => {
screenshotDataSource.setData(data && data.screenshot);
framesDataSource.setData(windowURI, data && data.opener, data && data.referrer, data && data.frames);
if (data && data.isPrivate)
isPrivate = true;
@@ -583,17 +574,17 @@ var framesDataSource =
});
this.addFrames(frame.frames, frameXML);
}
}
};
var errorsDataSource =
{
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
let {addonID} = require("info");
addonID = addonID.replace(/[\{\}]/g, "");
// See https://bugzilla.mozilla.org/show_bug.cgi?id=664695 - starting with
// Gecko 19 this function returns the result, before that it wrote to a
// parameter.
let outparam = {};
@@ -658,17 +649,17 @@ var errorsDataSource =
callback();
}
};
var extensionsDataSource =
{
data: reportData.createElement("extensions"),
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
try
{
let AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm", null).AddonManager;
AddonManager.getAddonsByTypes(["extension", "plugin"], function(items)
{
for (let i = 0; i < items.length; i++)
{
@@ -711,17 +702,17 @@ var subscriptionUpdateDataSource =
subscriptionFilter: function(s)
{
if (s instanceof DownloadableSubscription)
return subscriptionsDataSource.subscriptionFilter(s);
else
return false;
},
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
this.browser = browser;
let now = Date.now() / MILLISECONDS_IN_SECOND;
let outdatedThreshold = now - 14 * SECONDS_IN_DAY;
let needUpdateThreshold = now - 1 * SECONDS_IN_HOUR;
this.outdated = [];
this.needUpdate = [];
@@ -877,17 +868,17 @@ var issuesDataSource =
s.url != Prefs.subscriptions_antiadblockurl)
{
return subscriptionsDataSource.subscriptionFilter(s);
}
else
return false;
},
- collectData: function(wnd, windowURI, browser, callback)
+ collectData: function(outerWindowID, windowURI, browser, callback)
{
this.browser = browser;
this.whitelistFilter = Policy.isWhitelisted(windowURI.spec);
if (!this.whitelistFilter && this.isEnabled)
{
// Find disabled filters in active subscriptions matching any of the requests
let disabledMatcher = new CombinedMatcher();
@@ -1235,17 +1226,17 @@ function initDataCollectorPage()
progressMeter.mode = "determined";
progressMeter.value = progress;
}
// Continue with the next data source, asynchronously to allow progress meter to update
let dataSource = dataCollectors.shift();
Utils.runAsync(function()
{
- dataSource.collectData(contentWindow, windowURI, browser, initNextDataSource);
+ dataSource.collectData(outerWindowID, windowURI, browser, initNextDataSource);
});
};
initNextDataSource();
}
function initTypeSelectorPage()
{
« no previous file with comments | « no previous file | lib/ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld