Bug 1399787 - Part 12. Put temporay PDF and EMF files into NS_APP_CONTENT_PROCESS_TEMP_DIR.
So that we make sure those intermidiate file will be removed by ClearOnShutdown
when the chrome process been shutdown.
MozReview-Commit-ID: 7xQH9KE8AGl
--- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
+++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
@@ -884,16 +884,20 @@ SandboxBroker::SetSecurityLevelForPDFium
// in the \pipe\ namespace. We restrict it to pipes that start with
// "chrome." so the sandboxed process cannot connect to system services.
result = mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
sandbox::TargetPolicy::FILES_ALLOW_ANY,
L"\\??\\pipe\\chrome.*");
SANDBOX_ENSURE_SUCCESS(result,
"With these static arguments AddRule should never fail, what happened?");
+ // Add rule to allow read / write access to content temp dir.
+ AddCachedDirRule(mPolicy, sandbox::TargetPolicy::FILES_ALLOW_ANY,
+ sContentTempDir, NS_LITERAL_STRING("\\*"));
+
// Add this rule for loading pdfium.dll.
AddCachedDirRule(mPolicy, sandbox::TargetPolicy::FILES_ALLOW_READONLY,
sBinDir, NS_LITERAL_STRING("\\*"));
return true;
}
#endif
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -39,16 +39,17 @@
#include "nsIUUIDGenerator.h"
#include "mozilla/widget/PDFViaEMFPrintHelper.h"
#include "nsDirectoryServiceDefs.h"
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#include "PDFiumProcessParent.h"
#include "PDFiumParent.h"
#include "WindowsEMF.h"
+#include "nsAppDirectoryServiceDefs.h"
#endif
static mozilla::LazyLogModule kWidgetPrintingLogMod("printing-widget");
#define PR_PL(_p1) MOZ_LOG(kWidgetPrintingLogMod, mozilla::LogLevel::Debug, _p1)
using namespace mozilla;
using namespace mozilla::gfx;
@@ -245,17 +246,17 @@ already_AddRefed<PrintTarget> nsDeviceCo
if (mDevMode) {
// When printing to a printer via Skia PDF we open a temporary file that
// we draw the print output into as PDF output, then once we reach
// EndDcoument we'll convert that PDF file to EMF page by page to print
// each page. Here we create the temporary file and wrap it in a
// PrintTargetSkPDF that we return.
nsresult rv =
- NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mPDFTempFile));
+ NS_GetSpecialDirectory(NS_APP_CONTENT_PROCESS_TEMP_DIR, getter_AddRefs(mPDFTempFile));
NS_ENSURE_SUCCESS(rv, nullptr);
nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
do_GetService("@mozilla.org/uuid-generator;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
nsID uuid;