Bug 773942 - Hide the 'Open with Firefox' option if the download is started from the download button in pdf.js. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D72779
This commit is contained in:
Jared Wein 2020-05-16 05:59:55 +00:00
parent 3ab25176e5
commit 9b0a889740
3 changed files with 17 additions and 0 deletions

View File

@ -1240,7 +1240,13 @@ nsUnknownContentTypeDialog.prototype = {
shouldShowInternalHandlerOption() {
// This is currently available only for PDF files and when
// pdf.js is enabled.
let browsingContext = this.mDialog.BrowsingContext.get(
this.mLauncher.browsingContextId
);
return (
!browsingContext?.currentWindowGlobal?.documentPrincipal?.URI?.schemeIs(
"resource"
) &&
this.mLauncher.MIMEInfo.primaryExtension == "pdf" &&
!Services.prefs.getBoolPref("pdfjs.disabled", true) &&
Services.prefs.getBoolPref(

View File

@ -1275,6 +1275,12 @@ 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

View File

@ -176,4 +176,9 @@ 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;
};