diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index 21211759e508..653b33425c29 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -369,11 +369,6 @@ pref("browser.download.autohideButton", true);
pref("browser.helperApps.deleteTempFileOnExit", true);
#endif
-// This controls the visibility of the radio button in the
-// Unknown Content Type (Helper App) dialog that will open
-// the content in the browser.
-pref("browser.helperApps.showOpenOptionForPdfJS", false);
-
// search engines URL
pref("browser.search.searchEnginesURL", "https://addons.mozilla.org/%LOCALE%/firefox/search-engines/");
diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js
index 58dec1a036de..a7421f819033 100644
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -111,12 +111,13 @@ function doGetProtocolFlags(aURI) {
/**
* openUILink handles clicks on UI elements that cause URLs to load.
*
- * @param {string} url
- * @param {Event | Object} event Event or JSON object representing an Event
+ * As the third argument, you may pass an object with the same properties as
+ * accepted by openUILinkIn, plus "ignoreButton" and "ignoreAlt".
+ *
+ * @param url {string}
+ * @param event {Event | Object} Event or JSON object representing an Event
* @param {Boolean | Object} aIgnoreButton
- * Boolean or object with the same properties as
- * accepted by openUILinkIn, plus "ignoreButton"
- * and "ignoreAlt".
+ * @param {Boolean} aIgnoreButton
* @param {Boolean} aIgnoreAlt
* @param {Boolean} aAllowThirdPartyFixup
* @param {Object} aPostData
diff --git a/toolkit/components/downloads/DownloadCore.jsm b/toolkit/components/downloads/DownloadCore.jsm
index a22ed21908c6..7baefca75f7d 100644
--- a/toolkit/components/downloads/DownloadCore.jsm
+++ b/toolkit/components/downloads/DownloadCore.jsm
@@ -1207,7 +1207,6 @@ const kPlainSerializableDownloadProperties = [
"launcherPath",
"launchWhenSucceeded",
"contentType",
- "handleInternally",
];
/**
@@ -1429,10 +1428,8 @@ DownloadSource.fromSerializable = function(aSerializable) {
} else {
// Convert String objects to primitive strings at this point.
source.url = aSerializable.url.toString();
- for (let propName of ["isPrivate", "userContextId", "browsingContextId"]) {
- if (propName in aSerializable) {
- source[propName] = aSerializable[propName];
- }
+ if ("isPrivate" in aSerializable) {
+ source.isPrivate = aSerializable.isPrivate;
}
if ("referrerInfo" in aSerializable) {
// Quick pass, pass directly nsIReferrerInfo, we don't need to serialize
diff --git a/toolkit/components/downloads/DownloadIntegration.jsm b/toolkit/components/downloads/DownloadIntegration.jsm
index 8bbfae69206f..02aaecaf66f7 100644
--- a/toolkit/components/downloads/DownloadIntegration.jsm
+++ b/toolkit/components/downloads/DownloadIntegration.jsm
@@ -784,43 +784,6 @@ var DownloadIntegration = {
return;
}
- if (aDownload.handleInternally) {
- let win = Services.wm.getMostRecentBrowserWindow();
- let browsingContext =
- win && win.BrowsingContext.get(aDownload.source.browsingContextId);
- win = Services.wm.getOuterWindowWithId(
- browsingContext &&
- browsingContext.embedderWindowGlobal &&
- browsingContext.embedderWindowGlobal.outerWindowId
- );
- let fileURI = Services.io.newFileURI(file);
- if (win) {
- // TODO: Replace openTrustedLinkIn with openUILink once
- // we have access to the event.
- win.openTrustedLinkIn(fileURI.spec, "tab", {
- triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
- userContextId: aDownload.source.userContextId,
- });
- return;
- }
- let features = "chrome,dialog=no,all";
- if (aDownload.source.isPrivate) {
- features += ",private";
- }
- let args = Cc["@mozilla.org/supports-string;1"].createInstance(
- Ci.nsISupportsString
- );
- args.data = fileURI.spec;
- win = Services.ww.openWindow(
- null,
- AppConstants.BROWSER_CHROME_URL,
- "_blank",
- features,
- args
- );
- return;
- }
-
// No custom application chosen, let's launch the file with the default
// handler. First, let's try to launch it through the MIME service.
if (mimeInfo) {
diff --git a/toolkit/components/downloads/DownloadLegacy.jsm b/toolkit/components/downloads/DownloadLegacy.jsm
index f398bc8d679e..364006288590 100644
--- a/toolkit/components/downloads/DownloadLegacy.jsm
+++ b/toolkit/components/downloads/DownloadLegacy.jsm
@@ -270,67 +270,6 @@ DownloadLegacyTransfer.prototype = {
aTempFile,
aCancelable,
aIsPrivate
- ) {
- return this._nsITransferInitInternal(
- aSource,
- aTarget,
- aDisplayName,
- aMIMEInfo,
- aStartTime,
- aTempFile,
- aCancelable,
- aIsPrivate
- );
- },
-
- // nsITransfer
- initWithBrowsingContext(
- aSource,
- aTarget,
- aDisplayName,
- aMIMEInfo,
- aStartTime,
- aTempFile,
- aCancelable,
- aIsPrivate,
- aBrowsingContext,
- aHandleInternally
- ) {
- let browsingContextId;
- let userContextId;
- if (aBrowsingContext && aBrowsingContext.currentWindowGlobal) {
- browsingContextId = aBrowsingContext.id;
- let windowGlobal = aBrowsingContext.currentWindowGlobal;
- let originAttributes = windowGlobal.documentPrincipal.originAttributes;
- userContextId = originAttributes.userContextId;
- }
- return this._nsITransferInitInternal(
- aSource,
- aTarget,
- aDisplayName,
- aMIMEInfo,
- aStartTime,
- aTempFile,
- aCancelable,
- aIsPrivate,
- userContextId,
- browsingContextId,
- aHandleInternally
- );
- },
-
- _nsITransferInitInternal(
- aSource,
- aTarget,
- aDisplayName,
- aMIMEInfo,
- aStartTime,
- aTempFile,
- aCancelable,
- isPrivate,
- userContextId = 0,
- browsingContextId = 0,
- handleInternally = false
) {
this._cancelable = aCancelable;
@@ -356,12 +295,7 @@ DownloadLegacyTransfer.prototype = {
// wait for it to be available. This operation may cause the entire
// download system to initialize before the object is created.
Downloads.createDownload({
- source: {
- url: aSource.spec,
- isPrivate,
- userContextId,
- browsingContextId,
- },
+ source: { url: aSource.spec, isPrivate: aIsPrivate },
target: {
path: aTarget.QueryInterface(Ci.nsIFileURL).file.path,
partFilePath: aTempFile && aTempFile.path,
@@ -370,7 +304,6 @@ DownloadLegacyTransfer.prototype = {
launchWhenSucceeded,
contentType,
launcherPath,
- handleInternally,
})
.then(aDownload => {
// Legacy components keep partial data when they use a ".part" file.
diff --git a/toolkit/components/telemetry/Scalars.yaml b/toolkit/components/telemetry/Scalars.yaml
index e267bc97f38e..a52c01d1b4b8 100644
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -3340,38 +3340,6 @@ pdf.viewer:
- 'main'
- 'content'
-# The following section contains scalars for the Unknown Content Type (Helper App) dialog.
-unknowncontenttype:
- pdf_action:
- bug_numbers:
- - 773942
- description: >
- A counter incremented every time a user uses the Unknown Content Type dialog
- for PDF files, with counts grouped by action chosen (see keys). Some external
- applications that have very high adoption are counted specifically.
- Note: 'OPEN_WITH_SYSTEM_DEFAULT' may eventually resolve to one of Acrobat, Foxit, MsEdge, Chromium, etc.
- keyed: true
- keys:
- - 'OPEN_WITH_INTERNAL_HANDLER'
- - 'OPEN_WITH_SYSTEM_DEFAULT'
- - 'OPEN_WITH_ACROBAT'
- - 'OPEN_WITH_FOXIT'
- - 'OPEN_WITH_MSEDGE'
- - 'OPEN_WITH_CHROMIUM'
- - 'OPEN_WITH_PREVIEW'
- - 'OPEN_WITH_OTHER'
- - 'SAVE'
- - 'CANCEL'
- expires: "85"
- kind: uint
- notification_emails:
- - jaws@mozilla.com
- release_channel_collection: opt-out
- products:
- - 'firefox'
- record_in_processes:
- - 'main'
-
# The following section contains scalars for printing.
printing:
error:
diff --git a/toolkit/content/tests/browser/common/mockTransfer.js b/toolkit/content/tests/browser/common/mockTransfer.js
index 397cc8569759..2c37f32f4d2f 100644
--- a/toolkit/content/tests/browser/common/mockTransfer.js
+++ b/toolkit/content/tests/browser/common/mockTransfer.js
@@ -68,7 +68,6 @@ MockTransfer.prototype = {
/* nsITransfer */
init() {},
- initWithBrowsingContext() {},
setSha256Hash() {},
setSignatureInfo() {},
};
diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
index 657aa8f9aa46..2e98525c4faa 100644
--- a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
@@ -16,4 +16,3 @@ unknownCancel.label=Cancel
fileType=%S file
# LOCALIZATION NOTE (orderedFileSizeWithType): first %S is type, second %S is size, and third %S is unit
orderedFileSizeWithType=%1$S (%2$S %3$S)
-pdfHandlerDescription=Portable Document Format (PDF)
diff --git a/toolkit/locales/en-US/toolkit/global/unknownContentType.ftl b/toolkit/locales/en-US/toolkit/global/unknownContentType.ftl
deleted file mode 100644
index d6373459f3bb..000000000000
--- a/toolkit/locales/en-US/toolkit/global/unknownContentType.ftl
+++ /dev/null
@@ -1,7 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-unknowncontenttype-handleinternally =
- .label = Open with { -brand-short-name }
- .accesskey = e
diff --git a/toolkit/mozapps/downloads/HelperAppDlg.jsm b/toolkit/mozapps/downloads/HelperAppDlg.jsm
index ce447da07ab3..6104ac80cc72 100644
--- a/toolkit/mozapps/downloads/HelperAppDlg.jsm
+++ b/toolkit/mozapps/downloads/HelperAppDlg.jsm
@@ -552,7 +552,7 @@ nsUnknownContentTypeDialog.prototype = {
// set save as the selected option
this.dialogElement("mode").selectedItem = this.dialogElement("save");
} else {
- this.initInteractiveControls();
+ this.initAppAndSaveToDiskValues();
// Initialize "always ask me" box. This should always be disabled
// and set to true for the ambiguous type application/octet-stream.
@@ -573,6 +573,12 @@ nsUnknownContentTypeDialog.prototype = {
// uriloader has passed, rather we want to ask the MIME Service.
// This is so we don't needlessly disable the "autohandle" checkbox.
+ // commented out to close the opening brace in the if statement.
+ // var mimeService = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
+ // var type = mimeService.getTypeFromURI(this.mLauncher.source);
+ // this.realMIMEInfo = mimeService.getFromTypeAndExtension(type, "");
+
+ // if (type == "application/octet-stream") {
if (shouldntRememberChoice) {
rememberChoice.checked = false;
rememberChoice.hidden = true;
@@ -583,6 +589,12 @@ nsUnknownContentTypeDialog.prototype = {
this.nsIMIMEInfo.handleInternally;
}
this.toggleRememberChoice(rememberChoice);
+
+ // XXXben - menulist won't init properly, hack.
+ var openHandler = this.dialogElement("openHandler");
+ openHandler.remove();
+ var openHandlerBox = this.dialogElement("openHandlerBox");
+ openHandlerBox.appendChild(openHandler);
}
this.mDialog.setTimeout(function() {
@@ -622,6 +634,7 @@ nsUnknownContentTypeDialog.prototype = {
this.dialogElement("mode").focus();
},
+ // initIntro:
initIntro(url, filename, displayname) {
this.dialogElement("location").value = displayname;
this.dialogElement("location").setAttribute("realname", filename);
@@ -727,6 +740,7 @@ nsUnknownContentTypeDialog.prototype = {
}
},
+ // getPath:
getPath(aFile) {
if (AppConstants.platform == "macosx") {
return aFile.leafName || aFile.path;
@@ -734,7 +748,8 @@ nsUnknownContentTypeDialog.prototype = {
return aFile.path;
},
- initInteractiveControls() {
+ // initAppAndSaveToDiskValues:
+ initAppAndSaveToDiskValues() {
var modeGroup = this.dialogElement("mode");
// We don't let users open .exe files or random binary data directly
@@ -786,10 +801,6 @@ nsUnknownContentTypeDialog.prototype = {
openHandler.selectedIndex = 0;
var defaultOpenHandler = this.dialogElement("defaultHandler");
- if (this.shouldShowInternalHandlerOption()) {
- this.dialogElement("handleInternally").hidden = false;
- }
-
if (
this.mLauncher.MIMEInfo.preferredAction ==
this.nsIMIMEInfo.useSystemDefault
@@ -805,13 +816,6 @@ nsUnknownContentTypeDialog.prototype = {
otherHandler && !otherHandler.hidden
? otherHandler
: defaultOpenHandler;
- } else if (
- !this.dialogElement("handleInternally").hidden &&
- this.mLauncher.MIMEInfo.preferredAction ==
- this.nsIMIMEInfo.handleInternally
- ) {
- // Handle internally
- modeGroup.selectedItem = this.dialogElement("handleInternally");
} else {
// Save to disk.
modeGroup.selectedItem = this.dialogElement("save");
@@ -857,10 +861,6 @@ nsUnknownContentTypeDialog.prototype = {
);
},
- get handleInternally() {
- return this.dialogElement("handleInternally").selected;
- },
-
toggleRememberChoice(aCheckbox) {
this.dialogElement("settingsChange").hidden = !aCheckbox.checked;
this.mDialog.sizeToContent();
@@ -937,7 +937,7 @@ nsUnknownContentTypeDialog.prototype = {
if (needUpdate) {
this.mLauncher.MIMEInfo.preferredAction = this.nsIMIMEInfo.useSystemDefault;
}
- } else if (this.useOtherHandler) {
+ } else {
// For "open with", we need to check both preferred action and whether the user chose
// a new app.
needUpdate =
@@ -982,8 +982,8 @@ nsUnknownContentTypeDialog.prototype = {
hs.store(handlerInfo);
},
+ // onOK:
onOK(aEvent) {
- let shouldLogAction = this.dialogElement("basicBox").collapsed;
// Verify typed app path, if necessary.
if (this.useOtherHandler) {
var helperApp = this.helperAppChoice();
@@ -1013,7 +1013,6 @@ nsUnknownContentTypeDialog.prototype = {
// Leave dialog up.
aEvent.preventDefault();
- shouldLogAction = false;
}
}
@@ -1025,12 +1024,10 @@ nsUnknownContentTypeDialog.prototype = {
// certain circumstances (e.g. The user clicks cancel in the
// "Save to Disk" dialog. In those cases, we don't want to
// update the helper application preferences in the RDF file.
- let action;
try {
var needUpdate = this.updateMIMEInfo();
if (this.dialogElement("save").selected) {
- action = "SAVE";
// see @notify
// we cannot use opener's setTimeout, see bug 420405
this._saveToDiskTimer = Cc["@mozilla.org/timer;1"].createInstance(
@@ -1038,8 +1035,7 @@ nsUnknownContentTypeDialog.prototype = {
);
this._saveToDiskTimer.initWithCallback(this, 0, nsITimer.TYPE_ONE_SHOT);
} else {
- action = this.getOpenWithActionForTelemetry();
- this.mLauncher.launchWithApplication(this.handleInternally);
+ this.mLauncher.launchWithApplication();
}
// Update user pref for this mime type (if necessary). We do not
@@ -1053,19 +1049,12 @@ nsUnknownContentTypeDialog.prototype = {
) {
this.updateHelperAppPref();
}
- } catch (e) {
- } finally {
- if (shouldLogAction) {
- this.logActionInTelemetryIfExtensionIsPDF(action);
- }
- }
-
+ } catch (e) {}
this.onUnload();
},
+ // onCancel:
onCancel() {
- this.logActionInTelemetryIfExtensionIsPDF("CANCEL");
-
// Remove our web progress listener.
this.mLauncher.setWebProgressListener(null);
@@ -1095,6 +1084,7 @@ nsUnknownContentTypeDialog.prototype = {
}
},
+ // dialogElement: Convenience.
dialogElement(id) {
return this.mDialog.document.getElementById(id);
},
@@ -1250,88 +1240,6 @@ nsUnknownContentTypeDialog.prototype = {
this.finishChooseApp();
},
- shouldShowInternalHandlerOption() {
- // This is currently available only for PDF files and when
- // pdf.js is enabled.
- let browsingContext = this.mDialog.BrowsingContext.get(
- this.mLauncher.browsingContextId
- );
- let primaryExtension = "";
- try {
- // The primaryExtension getter may throw if there are no
- // known extensions for this mimetype.
- primaryExtension = this.mLauncher.MIMEInfo.primaryExtension;
- } catch (e) {}
- return (
- !browsingContext?.currentWindowGlobal?.documentPrincipal?.URI?.schemeIs(
- "resource"
- ) &&
- primaryExtension == "pdf" &&
- !Services.prefs.getBoolPref("pdfjs.disabled", true) &&
- Services.prefs.getBoolPref(
- "browser.helperApps.showOpenOptionForPdfJS",
- false
- )
- );
- },
-
- getOpenWithActionForTelemetry() {
- if (this.handleInternally) {
- return "OPEN_WITH_INTERNAL_HANDLER";
- }
- let name = this.mLauncher.MIMEInfo.preferredApplicationHandler?.name;
- let { defaultDescription } = this.mLauncher.MIMEInfo;
- if (name) {
- name = name.toLowerCase();
- // Reduce "firefox-bin", "Firefox.app", and "firefox.exe" to just "firefox"
- let delimeter = AppConstants.platform == "linux" ? "-" : ".";
- name = name.substring(0, name.indexOf(delimeter));
- } else if (defaultDescription.includes("Edge")) {
- name = "msedge";
- } else if (defaultDescription.includes("Chrome")) {
- name = "chrome";
- } else if (defaultDescription == "Preview") {
- name = "preview";
- }
- switch (name) {
- case "acrobat":
- case "acrord32":
- case "adobe acrobat reader dc":
- return "OPEN_WITH_ACROBAT";
- case "chrome":
- // Chromium also uses "chrome.exe" as the executable name.
- return "OPEN_WITH_CHROMIUM";
- case "foxitreader":
- return "OPEN_WITH_FOXIT";
- case "msedge":
- return "OPEN_WITH_MSEDGE";
- case "preview":
- return "OPEN_WITH_PREVIEW";
- case undefined:
- if (
- this.mLauncher.MIMEInfo.preferredAction ==
- this.mLauncher.MIMEInfo.useSystemDefault
- ) {
- return "OPEN_WITH_SYSTEM_DEFAULT";
- }
- // Fall through
- default:
- return "OPEN_WITH_OTHER";
- }
- },
-
- logActionInTelemetryIfExtensionIsPDF(action) {
- try {
- if (this.mLauncher.MIMEInfo.primaryExtension == "pdf") {
- Services.telemetry.keyedScalarAdd(
- "unknowncontenttype.pdf_action",
- action,
- 1
- );
- }
- } catch (ex) {}
- },
-
// Turn this on to get debugging messages.
debug: false,
diff --git a/toolkit/mozapps/downloads/content/unknownContentType.xhtml b/toolkit/mozapps/downloads/content/unknownContentType.xhtml
index 9a9551d59a43..bebd56f3a72c 100644
--- a/toolkit/mozapps/downloads/content/unknownContentType.xhtml
+++ b/toolkit/mozapps/downloads/content/unknownContentType.xhtml
@@ -28,10 +28,6 @@
screenX="" screenY=""
persist="screenX screenY"
aria-describedby="intro location whichIs type from source unknownPrompt">
-
-
-
-
diff --git a/uriloader/base/nsITransfer.idl b/uriloader/base/nsITransfer.idl
index 0cbd41c4708d..881934c54a52 100644
--- a/uriloader/base/nsITransfer.idl
+++ b/uriloader/base/nsITransfer.idl
@@ -10,7 +10,6 @@ interface nsIURI;
interface nsICancelable;
interface nsIMIMEInfo;
interface nsIFile;
-webidl BrowsingContext;
[scriptable, uuid(37ec75d3-97ad-4da8-afaa-eabe5b4afd73)]
interface nsITransfer : nsIWebProgressListener2 {
@@ -50,7 +49,6 @@ interface nsITransfer : nsIWebProgressListener2 {
* @param aIsPrivate Used to determine the privacy status of the new transfer.
* If true, indicates that the transfer was initiated from
* a source that desires privacy.
- *
*/
void init(in nsIURI aSource,
in nsIURI aTarget,
@@ -61,27 +59,6 @@ interface nsITransfer : nsIWebProgressListener2 {
in nsICancelable aCancelable,
in boolean aIsPrivate);
- /**
- * Same as init, but allows for passing the browsingContext
- * which will allow for opening the download with the same
- * userContextId
- *
- * @param aBrowsingContext BrowsingContext of the initiating document.
- *
- * @param aHandleInternally Set to true if the download should be opened within
- * the browser.
- */
- void initWithBrowsingContext(in nsIURI aSource,
- in nsIURI aTarget,
- in AString aDisplayName,
- in nsIMIMEInfo aMIMEInfo,
- in PRTime startTime,
- in nsIFile aTempFile,
- in nsICancelable aCancelable,
- in boolean aIsPrivate,
- in BrowsingContext aBrowsingContext,
- in boolean aHandleInternally);
-
/*
* Used to notify the transfer object of the hash of the downloaded file.
* Must be called on the main thread, only after the download has finished
diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp
index c6d5897f45b3..5f4940aeb535 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1155,7 +1155,6 @@ nsExternalAppHandler::nsExternalAppHandler(
mStopRequestIssued(false),
mIsFileChannel(false),
mShouldCloseWindow(false),
- mHandleInternally(false),
mReason(aReason),
mTempFileIsExecutable(false),
mTimeDownloadStarted(0),
@@ -1275,12 +1274,6 @@ NS_IMETHODIMP nsExternalAppHandler::GetContentLength(int64_t* aContentLength) {
return NS_OK;
}
-NS_IMETHODIMP nsExternalAppHandler::GetBrowsingContextId(
- uint64_t* aBrowsingContextId) {
- *aBrowsingContextId = mBrowsingContext->Id();
- return NS_OK;
-}
-
void nsExternalAppHandler::RetargetLoadNotifications(nsIRequest* request) {
// we are going to run the downloading of the helper app in our own little
// docloader / load group context. so go ahead and force the creation of a
@@ -1589,7 +1582,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
if (NS_FAILED(rv)) {
nsresult transferError = rv;
- rv = CreateFailedTransfer();
+ rv = CreateFailedTransfer(aChannel && NS_UsePrivateBrowsing(aChannel));
if (NS_FAILED(rv)) {
LOG(
("Failed to create transfer to report failure."
@@ -1741,7 +1734,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
#endif
if (action == nsIMIMEInfo::useHelperApp ||
action == nsIMIMEInfo::useSystemDefault) {
- rv = LaunchWithApplication(mHandleInternally);
+ rv = LaunchWithApplication();
} else {
rv = PromptForSaveDestination();
}
@@ -2017,7 +2010,7 @@ nsExternalAppHandler::OnSaveComplete(nsIBackgroundFileSaver* aSaver,
// have to.
if (!mTransfer) {
// We don't care if this fails.
- CreateFailedTransfer();
+ CreateFailedTransfer(channel && NS_UsePrivateBrowsing(channel));
}
SendStatusChange(kWriteError, aStatus, nullptr, path);
@@ -2110,17 +2103,10 @@ nsresult nsExternalAppHandler::CreateTransfer() {
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr channel = do_QueryInterface(mRequest);
- if (mBrowsingContext) {
- rv = transfer->InitWithBrowsingContext(
- mSourceUrl, target, EmptyString(), mMimeInfo, mTimeDownloadStarted,
- mTempFile, this, channel && NS_UsePrivateBrowsing(channel),
- mBrowsingContext, mHandleInternally);
- } else {
- rv = transfer->Init(mSourceUrl, target, EmptyString(), mMimeInfo,
- mTimeDownloadStarted, mTempFile, this,
- channel && NS_UsePrivateBrowsing(channel));
- }
+ rv = transfer->Init(mSourceUrl, target, EmptyString(), mMimeInfo,
+ mTimeDownloadStarted, mTempFile, this,
+ channel && NS_UsePrivateBrowsing(channel));
NS_ENSURE_SUCCESS(rv, rv);
// If we were cancelled since creating the transfer, just return. It is
@@ -2156,7 +2142,7 @@ nsresult nsExternalAppHandler::CreateTransfer() {
return rv;
}
-nsresult nsExternalAppHandler::CreateFailedTransfer() {
+nsresult nsExternalAppHandler::CreateFailedTransfer(bool aIsPrivateBrowsing) {
nsresult rv;
nsCOMPtr transfer =
do_CreateInstance(NS_TRANSFER_CONTRACTID, &rv);
@@ -2177,18 +2163,8 @@ nsresult nsExternalAppHandler::CreateFailedTransfer() {
rv = NS_NewFileURI(getter_AddRefs(pseudoTarget), pseudoFile);
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr channel = do_QueryInterface(mRequest);
- if (mBrowsingContext) {
- rv = transfer->InitWithBrowsingContext(
- mSourceUrl, pseudoTarget, EmptyString(), mMimeInfo,
- mTimeDownloadStarted, nullptr, this,
- channel && NS_UsePrivateBrowsing(channel), mBrowsingContext,
- mHandleInternally);
- } else {
- rv = transfer->Init(mSourceUrl, pseudoTarget, EmptyString(), mMimeInfo,
- mTimeDownloadStarted, nullptr, this,
- channel && NS_UsePrivateBrowsing(channel));
- }
+ rv = transfer->Init(mSourceUrl, pseudoTarget, EmptyString(), mMimeInfo,
+ mTimeDownloadStarted, nullptr, this, aIsPrivateBrowsing);
NS_ENSURE_SUCCESS(rv, rv);
// Our failed transfer is ready.
@@ -2315,12 +2291,9 @@ nsresult nsExternalAppHandler::ContinueSave(nsIFile* aNewFileLocation) {
// LaunchWithApplication should only be called by the helper app dialog which
// allows the user to say launch with application or save to disk.
-NS_IMETHODIMP nsExternalAppHandler::LaunchWithApplication(
- bool aHandleInternally) {
+NS_IMETHODIMP nsExternalAppHandler::LaunchWithApplication() {
if (mCanceled) return NS_OK;
- mHandleInternally = aHandleInternally;
-
// Now check if the file is local, in which case we won't bother with saving
// it to a temporary directory and just launch it from where it is
nsCOMPtr fileUrl(do_QueryInterface(mSourceUrl));
@@ -2488,28 +2461,6 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(
// If we got no mimeinfo, something went wrong. Probably lack of memory.
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
- // (1.5) Overwrite with generic description if the extension is PDF
- // since the file format is supported by Firefox and we don't want
- // other brands positioning themselves as the sole viewer for a system.
- if (aFileExt.LowerCaseEqualsASCII("pdf") ||
- aFileExt.LowerCaseEqualsASCII(".pdf")) {
- nsCOMPtr bundleService =
- do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr unknownContentTypeBundle;
- rv = bundleService->CreateBundle(
- "chrome://mozapps/locale/downloads/unknownContentType.properties",
- getter_AddRefs(unknownContentTypeBundle));
- if (NS_SUCCEEDED(rv)) {
- nsAutoString pdfHandlerDescription;
- rv = unknownContentTypeBundle->GetStringFromName("pdfHandlerDescription",
- pdfHandlerDescription);
- if (NS_SUCCEEDED(rv)) {
- (*_retval)->SetDescription(pdfHandlerDescription);
- }
- }
- }
-
// (2) Now, let's see if we can find something in our datastore
// This will not overwrite the OS information that interests us
// (i.e. default application, default app. description)
diff --git a/uriloader/exthandler/nsExternalHelperAppService.h b/uriloader/exthandler/nsExternalHelperAppService.h
index cc67078ac977..e942fe38e1fd 100644
--- a/uriloader/exthandler/nsExternalHelperAppService.h
+++ b/uriloader/exthandler/nsExternalHelperAppService.h
@@ -308,11 +308,6 @@ class nsExternalAppHandler final : public nsIStreamListener,
*/
bool mShouldCloseWindow;
- /**
- * True if the file should be handled internally.
- */
- bool mHandleInternally;
-
/**
* One of the REASON_ constants from nsIHelperAppLauncherDialog. Indicates the
* reason the dialog was shown (unknown content type, server requested it,
@@ -388,7 +383,7 @@ class nsExternalAppHandler final : public nsIStreamListener,
* If we fail to create the necessary temporary file to initiate a transfer
* we will report the failure by creating a failed nsITransfer.
*/
- nsresult CreateFailedTransfer();
+ nsresult CreateFailedTransfer(bool aIsPrivateBrowsing);
/*
* The following two functions are part of the split of SaveToDisk
diff --git a/uriloader/exthandler/nsIExternalHelperAppService.idl b/uriloader/exthandler/nsIExternalHelperAppService.idl
index ea8b9b08f3e6..a897c0da97f8 100644
--- a/uriloader/exthandler/nsIExternalHelperAppService.idl
+++ b/uriloader/exthandler/nsIExternalHelperAppService.idl
@@ -138,9 +138,8 @@ interface nsIHelperAppLauncher : nsICancelable
/**
* Tell the launcher that we will want to open the file.
* NOTE: This will release the reference to the nsIHelperAppLauncherDialog.
- * @param aHandleInternally TRUE if we should handle opening this internally.
*/
- void launchWithApplication(in boolean aHandleInternally);
+ void launchWithApplication();
/**
* Callback invoked by nsIHelperAppLauncherDialog::promptForSaveToFileAsync
@@ -176,9 +175,4 @@ interface nsIHelperAppLauncher : nsICancelable
* The download content length, or -1 if the length is not available.
*/
readonly attribute int64_t contentLength;
-
- /**
- * The browsingContext ID of the launcher's source
- */
- readonly attribute uint64_t browsingContextId;
};
diff --git a/uriloader/exthandler/tests/mochitest/browser.ini b/uriloader/exthandler/tests/mochitest/browser.ini
index 7901d577f25c..b6fec684230d 100644
--- a/uriloader/exthandler/tests/mochitest/browser.ini
+++ b/uriloader/exthandler/tests/mochitest/browser.ini
@@ -11,12 +11,6 @@ support-files =
download.sjs
[browser_download_always_ask_preferred_app.js]
[browser_download_privatebrowsing.js]
-[browser_download_open_with_internal_handler.js]
-support-files =
- file_pdfjs_test.pdf
- file_pdfjs_test.pdf^headers^
- file_txt_attachment_test.txt
- file_txt_attachment_test.txt^headers^
[browser_download_urlescape.js]
support-files =
file_with@@funny_name.png
diff --git a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js b/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js
deleted file mode 100644
index 5d5c49eb289f..000000000000
--- a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js
+++ /dev/null
@@ -1,189 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-ChromeUtils.import("resource://gre/modules/Downloads.jsm", this);
-
-const TEST_PATH = getRootDirectory(gTestPath).replace(
- "chrome://mochitests/content",
- "https://example.com"
-);
-
-function waitForAcceptButtonToGetEnabled(doc) {
- let dialog = doc.querySelector("#unknownContentType");
- let button = dialog.getButton("accept");
- return TestUtils.waitForCondition(
- () => !button.disabled,
- "Wait for Accept button to get enabled"
- );
-}
-
-async function waitForPdfJS(browser, url) {
- await SpecialPowers.pushPrefEnv({
- set: [["pdfjs.eventBusDispatchToDOM", true]],
- });
- // Runs tests after all "load" event handlers have fired off
- let loadPromise = BrowserTestUtils.waitForContentEvent(
- browser,
- "documentloaded",
- false,
- null,
- true
- );
- await SpecialPowers.spawn(browser, [url], contentUrl => {
- content.location = contentUrl;
- });
- return loadPromise;
-}
-
-/**
- * Check that loading a PDF file with content-disposition: attachment
- * shows an option to open with the internal handler, and that the
- * internal option handler is not present when the download button
- * is clicked from pdf.js.
- */
-add_task(async function test_check_open_with_internal_handler() {
- await SpecialPowers.pushPrefEnv({
- set: [["browser.helperApps.showOpenOptionForPdfJS", true]],
- });
- let publicList = await Downloads.getList(Downloads.PUBLIC);
- registerCleanupFunction(async () => {
- await publicList.removeFinished();
- });
- let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
- let loadingTab = await BrowserTestUtils.openNewForegroundTab(
- gBrowser,
- TEST_PATH + "file_pdfjs_test.pdf"
- );
- let dialogWindow = await dialogWindowPromise;
- is(
- dialogWindow.location,
- "chrome://mozapps/content/downloads/unknownContentType.xhtml",
- "Should have seen the unknown content dialogWindow."
- );
- let doc = dialogWindow.document;
- let internalHandlerRadio = doc.querySelector("#handleInternally");
-
- await waitForAcceptButtonToGetEnabled(doc);
-
- ok(!internalHandlerRadio.hidden, "The option should be visible for PDF");
- ok(internalHandlerRadio.selected, "The option should be selected");
-
- let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser);
- let dialog = doc.querySelector("#unknownContentType");
- let button = dialog.getButton("accept");
- button.disabled = false;
- dialog.acceptDialog();
- info("waiting for new tab to open");
- let newTab = await newTabPromise;
-
- await ContentTask.spawn(newTab.linkedBrowser, null, async () => {
- await ContentTaskUtils.waitForCondition(
- () => content.document.readyState == "complete"
- );
- });
-
- let publicDownloads = await publicList.getAll();
- Assert.equal(
- publicDownloads.length,
- 1,
- "download should appear in publicDownloads list"
- );
- let subdialogPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
- await SpecialPowers.spawn(newTab.linkedBrowser, [], async () => {
- let downloadButton;
- await ContentTaskUtils.waitForCondition(() => {
- downloadButton = content.document.querySelector("#download");
- return !!downloadButton;
- });
- ok(downloadButton, "Download button should be present in pdf.js");
- downloadButton.click();
- });
- info(
- "Waiting for unknown content type dialog to appear from pdf.js download button click"
- );
- let subDialogWindow = await subdialogPromise;
- let subDoc = subDialogWindow.document;
- // Prevent racing with initialization of the dialog and make sure that
- // the final state of the dialog has the correct visibility of the internal-handler option.
- await waitForAcceptButtonToGetEnabled(subDoc);
- let subInternalHandlerRadio = subDoc.querySelector("#handleInternally");
- ok(
- subInternalHandlerRadio.hidden,
- "The option should be hidden when the dialog is opened from pdf.js"
- );
-
- subDoc.querySelector("#unknownContentType").cancelDialog();
-
- BrowserTestUtils.removeTab(loadingTab);
- BrowserTestUtils.removeTab(newTab);
-});
-
-/**
- * Check that the "Open with internal handler" option is not presented
- * for non-PDF types.
- */
-add_task(async function test_internal_handler_hidden_with_nonpdf_type() {
- let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
- let loadingTab = await BrowserTestUtils.openNewForegroundTab(
- gBrowser,
- TEST_PATH + "file_txt_attachment_test.txt"
- );
- let dialogWindow = await dialogWindowPromise;
- is(
- dialogWindow.location,
- "chrome://mozapps/content/downloads/unknownContentType.xhtml",
- "Should have seen the unknown content dialogWindow."
- );
- let doc = dialogWindow.document;
-
- // Prevent racing with initialization of the dialog and make sure that
- // the final state of the dialog has the correct visibility of the internal-handler option.
- await waitForAcceptButtonToGetEnabled(doc);
-
- let internalHandlerRadio = doc.querySelector("#handleInternally");
- ok(
- internalHandlerRadio.hidden,
- "The option should be hidden for unknown file type"
- );
-
- let dialog = doc.querySelector("#unknownContentType");
- dialog.cancelDialog();
- BrowserTestUtils.removeTab(loadingTab);
-});
-
-/**
- * Check that the "Open with internal handler" option is not presented
- * when the feature is disabled.
- */
-add_task(async function test_internal_handler_hidden_with_pref_disabled() {
- await SpecialPowers.pushPrefEnv({
- set: [["browser.helperApps.showOpenOptionForPdfJS", false]],
- });
-
- let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
- let loadingTab = await BrowserTestUtils.openNewForegroundTab(
- gBrowser,
- TEST_PATH + "file_pdfjs_test.pdf"
- );
- let dialogWindow = await dialogWindowPromise;
- is(
- dialogWindow.location,
- "chrome://mozapps/content/downloads/unknownContentType.xhtml",
- "Should have seen the unknown content dialogWindow."
- );
- let doc = dialogWindow.document;
-
- await waitForAcceptButtonToGetEnabled(doc);
-
- let internalHandlerRadio = doc.querySelector("#handleInternally");
- ok(
- internalHandlerRadio.hidden,
- "The option should be hidden for PDF when the pref is false"
- );
-
- let dialog = doc.querySelector("#unknownContentType");
- dialog.cancelDialog();
- BrowserTestUtils.removeTab(loadingTab);
-});
diff --git a/uriloader/exthandler/tests/mochitest/file_pdfjs_test.pdf b/uriloader/exthandler/tests/mochitest/file_pdfjs_test.pdf
deleted file mode 100644
index 7ad87e3c2e32..000000000000
Binary files a/uriloader/exthandler/tests/mochitest/file_pdfjs_test.pdf and /dev/null differ
diff --git a/uriloader/exthandler/tests/mochitest/file_pdfjs_test.pdf^headers^ b/uriloader/exthandler/tests/mochitest/file_pdfjs_test.pdf^headers^
deleted file mode 100644
index 0f882c970c2b..000000000000
--- a/uriloader/exthandler/tests/mochitest/file_pdfjs_test.pdf^headers^
+++ /dev/null
@@ -1,2 +0,0 @@
-Content-Disposition: attachment; filename=file_pdfjs_test.pdf
-Content-Type: application/pdf
diff --git a/uriloader/exthandler/tests/mochitest/file_txt_attachment_test.txt b/uriloader/exthandler/tests/mochitest/file_txt_attachment_test.txt
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/uriloader/exthandler/tests/mochitest/file_txt_attachment_test.txt^headers^ b/uriloader/exthandler/tests/mochitest/file_txt_attachment_test.txt^headers^
deleted file mode 100644
index 37823166a487..000000000000
--- a/uriloader/exthandler/tests/mochitest/file_txt_attachment_test.txt^headers^
+++ /dev/null
@@ -1,2 +0,0 @@
-Content-Disposition: attachment; filename=file_text_attachment_test.txt
-Content-Type: text/plain
diff --git a/uriloader/exthandler/tests/unit/test_getMIMEInfo_pdf.js b/uriloader/exthandler/tests/unit/test_getMIMEInfo_pdf.js
deleted file mode 100644
index 58b1343d62ab..000000000000
--- a/uriloader/exthandler/tests/unit/test_getMIMEInfo_pdf.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-XPCOMUtils.defineLazyServiceGetter(
- this,
- "gMIMEService",
- "@mozilla.org/mime;1",
- "nsIMIMEService"
-);
-
-// PDF files should always have a generic description instead
-// of relying on what is registered with the Operating System.
-add_task(async function test_check_unknown_mime_type() {
- const mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
- let pdfType = mimeService.getTypeFromExtension("pdf");
- Assert.equal(pdfType, "application/pdf");
- let extension = mimeService.getPrimaryExtension("application/pdf", "");
- Assert.equal(extension, "pdf", "Expect pdf extension when given mime");
- let mimeInfo = gMIMEService.getFromTypeAndExtension("", "pdf");
- Assert.equal(
- mimeInfo.description,
- "Portable Document Format (PDF)",
- "PDF has generic description"
- );
-});
diff --git a/uriloader/exthandler/tests/unit/xpcshell.ini b/uriloader/exthandler/tests/unit/xpcshell.ini
index a6ce26606a15..32801c3559f5 100644
--- a/uriloader/exthandler/tests/unit/xpcshell.ini
+++ b/uriloader/exthandler/tests/unit/xpcshell.ini
@@ -7,7 +7,6 @@ firefox-appdir = browser
# No default stored handlers on android given lack of support.
# No default stored handlers on Thunderbird.
skip-if = os == "android" || appname == "thunderbird"
-[test_getMIMEInfo_pdf.js]
[test_getMIMEInfo_unknown_mime_type.js]
run-if = os == "win" # Windows only test
[test_getTypeFromExtension_ext_to_type_mapping.js]