Commit a079462e authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Simplify MaybeInitializeGDI().

Pull out a hard-to-read conditional into its own boolean variable.
Also remove an unused variable and compact code after that.

Change-Id: I34b101a9fb95f734a4cb67967ad5874ca4d7a7a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425425Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809924}
parent 1755e561
......@@ -51,21 +51,16 @@ DWORD WINAPI GetFontDataPatch(HDC hdc,
void MaybeInitializeGDI() {
#if defined(OS_WIN)
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
const std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
// Patch utility processes which explicitly need GDI. Anything else, just
// return.
// Only patch utility processes which explicitly need GDI.
sandbox::policy::SandboxType service_sandbox_type =
sandbox::policy::SandboxTypeFromCommandLine(command_line);
if (!(service_sandbox_type == sandbox::policy::SandboxType::kPpapi ||
service_sandbox_type ==
sandbox::policy::SandboxType::kPrintCompositor ||
service_sandbox_type == sandbox::policy::SandboxType::kPdfConversion)) {
sandbox::policy::SandboxTypeFromCommandLine(
*base::CommandLine::ForCurrentProcess());
bool need_gdi =
service_sandbox_type == sandbox::policy::SandboxType::kPpapi ||
service_sandbox_type == sandbox::policy::SandboxType::kPrintCompositor ||
service_sandbox_type == sandbox::policy::SandboxType::kPdfConversion;
if (!need_gdi)
return;
}
#if defined(COMPONENT_BUILD)
HMODULE module = ::GetModuleHandleA("pdfium.dll");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment