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, ...@@ -51,21 +51,16 @@ DWORD WINAPI GetFontDataPatch(HDC hdc,
void MaybeInitializeGDI() { void MaybeInitializeGDI() {
#if defined(OS_WIN) #if defined(OS_WIN)
const base::CommandLine& command_line = // Only patch utility processes which explicitly need GDI.
*base::CommandLine::ForCurrentProcess();
const std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
// Patch utility processes which explicitly need GDI. Anything else, just
// return.
sandbox::policy::SandboxType service_sandbox_type = sandbox::policy::SandboxType service_sandbox_type =
sandbox::policy::SandboxTypeFromCommandLine(command_line); sandbox::policy::SandboxTypeFromCommandLine(
if (!(service_sandbox_type == sandbox::policy::SandboxType::kPpapi || *base::CommandLine::ForCurrentProcess());
service_sandbox_type == bool need_gdi =
sandbox::policy::SandboxType::kPrintCompositor || service_sandbox_type == sandbox::policy::SandboxType::kPpapi ||
service_sandbox_type == sandbox::policy::SandboxType::kPdfConversion)) { service_sandbox_type == sandbox::policy::SandboxType::kPrintCompositor ||
service_sandbox_type == sandbox::policy::SandboxType::kPdfConversion;
if (!need_gdi)
return; return;
}
#if defined(COMPONENT_BUILD) #if defined(COMPONENT_BUILD)
HMODULE module = ::GetModuleHandleA("pdfium.dll"); 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