mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
Enhance PDF handling by introducing DISPOSITION_FORCE_INLINE and updating content disposition logic
This commit is contained in:
parent
9a60e2c532
commit
257ddfa48d
6 changed files with 63 additions and 7 deletions
|
|
@ -41,6 +41,10 @@
|
|||
#include "nsCExternalHandlerService.h" // contains contractids for the helper app service
|
||||
|
||||
#include "nsIMIMEHeaderParam.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
#include "nsMimeTypes.h"
|
||||
|
|
@ -389,6 +393,36 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
|
|||
forceExternalHandling = true;
|
||||
}
|
||||
|
||||
// For a PDF, check if it will be handled internally. If so, don't force
|
||||
// external handling for top-level document loads.
|
||||
if (forceExternalHandling &&
|
||||
mContentType.LowerCaseEqualsASCII(APPLICATION_PDF)) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
if (loadInfo &&
|
||||
loadInfo->GetExternalContentPolicyType() ==
|
||||
nsIContentPolicy::TYPE_DOCUMENT) {
|
||||
nsCOMPtr<nsIMIMEInfo> mimeInfo;
|
||||
nsCOMPtr<nsIMIMEService> mimeSvc(
|
||||
do_GetService(NS_MIMESERVICE_CONTRACTID));
|
||||
if (mimeSvc) {
|
||||
mimeSvc->GetFromTypeAndExtension(nsLiteralCString(APPLICATION_PDF),
|
||||
EmptyCString(),
|
||||
getter_AddRefs(mimeInfo));
|
||||
}
|
||||
|
||||
if (mimeInfo) {
|
||||
int32_t action = nsIHandlerInfo::saveToDisk;
|
||||
mimeInfo->GetPreferredAction(&action);
|
||||
|
||||
bool alwaysAsk = true;
|
||||
mimeInfo->GetAlwaysAskBeforeHandling(&alwaysAsk);
|
||||
forceExternalHandling =
|
||||
alwaysAsk || action != nsIHandlerInfo::handleInternally;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG((" forceExternalHandling: %s", forceExternalHandling ? "yes" : "no"));
|
||||
|
||||
// The type or data the contentListener wants.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue