Skip to content

Commit

Permalink
Bug 1878401 - part 3 - Update nsIFilePicker users in toolkit/ to pass…
Browse files Browse the repository at this point in the history
… BrowsingContext to init r=extension-reviewers,Gijs,ng,robwu

Depends on D200547

Differential Revision: https://phabricator.services.mozilla.com/D200548
  • Loading branch information
gregorypappas committed Feb 28, 2024
1 parent 2783888 commit 37e8e74
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 11 deletions.
6 changes: 5 additions & 1 deletion toolkit/components/aboutmemory/content/aboutMemory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,11 @@ function saveReportsToFile() {
};

try {
fp.init(window, "Save Memory Reports", Ci.nsIFilePicker.modeSave);
fp.init(
window.browsingContext,
"Save Memory Reports",
Ci.nsIFilePicker.modeSave
);
} catch (ex) {
// This will fail on Android, since there is no Save as file picker there.
// Just save to the default downloads dir if it does.
Expand Down
6 changes: 5 additions & 1 deletion toolkit/components/apppicker/content/appPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ AppPicker.prototype = {
var nsIFilePicker = Ci.nsIFilePicker;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);

fp.init(window, this._incomingParams.title, nsIFilePicker.modeOpen);
fp.init(
window.browsingContext,
this._incomingParams.title,
nsIFilePicker.modeOpen
);
fp.appendFilters(nsIFilePicker.filterApps);

var startLocation;
Expand Down
6 changes: 5 additions & 1 deletion toolkit/components/extensions/parent/ext-downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,11 @@ this.downloads = class extends ExtensionAPIPersistent {
const picker = Cc["@mozilla.org/filepicker;1"].createInstance(
Ci.nsIFilePicker
);
picker.init(window, null, Ci.nsIFilePicker.modeSave);
picker.init(
window.browsingContext,
null,
Ci.nsIFilePicker.modeSave
);
if (lastFilePickerDirectory) {
picker.displayDirectory = lastFilePickerDirectory;
} else {
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/printing/content/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -2811,7 +2811,7 @@ async function pickFileName(contentTitle, currentURI) {
filename = DownloadPaths.sanitize(filename);

picker.init(
window.docShell.chromeEventHandler.ownerGlobal,
window.docShell.chromeEventHandler.ownerGlobal.browsingContext,
title,
Ci.nsIFilePicker.modeSave
);
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/aboutwebrtc/aboutWebrtc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class SavePage extends Control {
]);
let FilePicker = makeFilePickerService();
const lazyFileUtils = lazy.FileUtils;
FilePicker.init(window, dialogTitle, FilePicker.modeSave);
FilePicker.init(window.browsingContext, dialogTitle, FilePicker.modeSave);
FilePicker.defaultString = LOGFILE_NAME_DEFAULT;
const rv = await new Promise(r => FilePicker.open(r));
if (rv != FilePicker.returnOK && rv != FilePicker.returnReplace) {
Expand Down
2 changes: 1 addition & 1 deletion toolkit/content/contentAreaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ function promiseTargetFile(
let fp = makeFilePicker();
let titleKey = aFpP.fpTitleKey || "SaveLinkTitle";
fp.init(
window,
window.browsingContext,
ContentAreaUtils.stringBundle.GetStringFromName(titleKey),
Ci.nsIFilePicker.modeSave
);
Expand Down
4 changes: 2 additions & 2 deletions toolkit/mozapps/downloads/HelperAppDlg.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ nsUnknownContentTypeDialog.prototype = {
var picker =
Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
var windowTitle = bundle.GetStringFromName("saveDialogTitle");
picker.init(parent, windowTitle, nsIFilePicker.modeSave);
picker.init(parent.browsingContext, windowTitle, nsIFilePicker.modeSave);
if (aDefaultFileName) {
picker.defaultString = this.getFinalLeafName(aDefaultFileName);
}
Expand Down Expand Up @@ -1270,7 +1270,7 @@ nsUnknownContentTypeDialog.prototype = {
var nsIFilePicker = Ci.nsIFilePicker;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
fp.init(
this.mDialog,
this.mDialog.browsingContext,
this.dialogElement("strings").getString("chooseAppFilePickerTitle"),
nsIFilePicker.modeOpen
);
Expand Down
6 changes: 5 additions & 1 deletion toolkit/mozapps/extensions/content/aboutaddonsCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ async function installAddonsFromFilePicker() {
]);
const nsIFilePicker = Ci.nsIFilePicker;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
fp.init(window, dialogTitle.value, nsIFilePicker.modeOpenMultiple);
fp.init(
window.browsingContext,
dialogTitle.value,
nsIFilePicker.modeOpenMultiple
);
try {
fp.appendFilter(filterName.value, "*.xpi;*.jar;*.zip");
fp.appendFilters(nsIFilePicker.filterAll);
Expand Down
2 changes: 1 addition & 1 deletion toolkit/mozapps/handling/content/appChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ let dialog = {
let title = await this.getChooseAppWindowTitle();

var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, title, Ci.nsIFilePicker.modeOpen);
fp.init(window.browsingContext, title, Ci.nsIFilePicker.modeOpen);
fp.appendFilters(Ci.nsIFilePicker.filterApps);

fp.open(rv => {
Expand Down
2 changes: 1 addition & 1 deletion toolkit/profile/content/createProfileWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function chooseProfileFolder() {
I.nsIFilePicker
);
dirChooser.init(
window,
window.browsingContext,
gProfileManagerBundle.getString("chooseFolder"),
I.nsIFilePicker.modeGetFolder
);
Expand Down

0 comments on commit 37e8e74

Please sign in to comment.