Index: chrome_elf/chrome_elf_util.cc |
diff --git a/chrome_elf/chrome_elf_util.cc b/chrome_elf/chrome_elf_util.cc |
index a547d0bda04730b73f6c50dd6bb5ed3118dda50b..7e2e7103ce4f9ae839a5e6805ea17753567c6852 100644 |
--- a/chrome_elf/chrome_elf_util.cc |
+++ b/chrome_elf/chrome_elf_util.cc |
@@ -4,11 +4,14 @@ |
#include "chrome_elf/chrome_elf_util.h" |
+#include <assert.h> |
#include <windows.h> |
#include "base/macros.h" |
#include "base/strings/string16.h" |
+ProcessType g_process_type = ProcessType::UNINITIALIZED; |
+ |
namespace { |
const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; |
@@ -192,18 +195,29 @@ bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled) { |
return false; |
} |
-bool IsNonBrowserProcess() { |
+void InitializeProcessType() { |
+ assert(g_process_type == ProcessType::UNINITIALIZED); |
typedef bool (*IsSandboxedProcessFunc)(); |
IsSandboxedProcessFunc is_sandboxed_process_func = |
reinterpret_cast<IsSandboxedProcessFunc>( |
GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); |
- bool is_sandboxed_process = |
- is_sandboxed_process_func && is_sandboxed_process_func(); |
+ if (is_sandboxed_process_func && is_sandboxed_process_func()) { |
+ g_process_type = ProcessType::NON_BROWSER_PROCESS; |
+ return; |
+ } |
// TODO(robertshield): Drop the command line check when we drop support for |
// enabling chrome_elf in unsandboxed processes. |
- wchar_t* command_line = GetCommandLine(); |
- bool has_process_type_flag = command_line && wcsstr(command_line, L"--type"); |
+ const wchar_t* command_line = GetCommandLine(); |
+ if (command_line && wcsstr(command_line, L"--type")) { |
+ g_process_type = ProcessType::NON_BROWSER_PROCESS; |
+ return; |
+ } |
- return (has_process_type_flag || is_sandboxed_process); |
+ g_process_type = ProcessType::BROWSER_PROCESS; |
+} |
+ |
+bool IsNonBrowserProcess() { |
+ assert(g_process_type != ProcessType::UNINITIALIZED); |
+ return g_process_type == ProcessType::NON_BROWSER_PROCESS; |
} |