Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome_elf/chrome_elf_util.h" | 5 #include "chrome_elf/chrome_elf_util.h" |
| 6 | 6 |
| 7 #include <assert.h> | |
| 7 #include <windows.h> | 8 #include <windows.h> |
| 8 | 9 |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 11 | 12 |
| 13 ProcessType g_is_non_browser_process = ProcessType::UNINITIALIZED; | |
|
csharp
2015/05/11 20:31:32
As discussed, maybe flip it to become g_is_browser
Sigurður Ásgeirsson
2015/05/11 20:37:41
g_process_type, perhaps?
Cait (Slow)
2015/05/11 21:16:21
Done.
Cait (Slow)
2015/05/11 21:16:21
Acknowledged.
| |
| 14 | |
| 12 namespace { | 15 namespace { |
| 13 | 16 |
| 14 const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; | 17 const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; |
| 15 const wchar_t kRegPathClientStateMedium[] = | 18 const wchar_t kRegPathClientStateMedium[] = |
| 16 L"Software\\Google\\Update\\ClientStateMedium"; | 19 L"Software\\Google\\Update\\ClientStateMedium"; |
| 17 #if defined(GOOGLE_CHROME_BUILD) | 20 #if defined(GOOGLE_CHROME_BUILD) |
| 18 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Google\\Chrome"; | 21 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Google\\Chrome"; |
| 19 #else | 22 #else |
| 20 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Chromium"; | 23 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Chromium"; |
| 21 #endif // defined(GOOGLE_CHROME_BUILD) | 24 #endif // defined(GOOGLE_CHROME_BUILD) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 value_bytes, &size) == ERROR_SUCCESS) { | 188 value_bytes, &size) == ERROR_SUCCESS) { |
| 186 *breakpad_enabled = value != 0; | 189 *breakpad_enabled = value != 0; |
| 187 } | 190 } |
| 188 ::RegCloseKey(key); | 191 ::RegCloseKey(key); |
| 189 return size == sizeof(value); | 192 return size == sizeof(value); |
| 190 } | 193 } |
| 191 | 194 |
| 192 return false; | 195 return false; |
| 193 } | 196 } |
| 194 | 197 |
| 195 bool IsNonBrowserProcess() { | 198 void InitializeIsNonBrowserProcess() { |
| 199 assert(g_is_non_browser_process == UNINITIALIZED); | |
| 196 typedef bool (*IsSandboxedProcessFunc)(); | 200 typedef bool (*IsSandboxedProcessFunc)(); |
| 197 IsSandboxedProcessFunc is_sandboxed_process_func = | 201 IsSandboxedProcessFunc is_sandboxed_process_func = |
| 198 reinterpret_cast<IsSandboxedProcessFunc>( | 202 reinterpret_cast<IsSandboxedProcessFunc>( |
| 199 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); | 203 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); |
| 200 bool is_sandboxed_process = | 204 if (is_sandboxed_process_func && is_sandboxed_process_func()) { |
| 201 is_sandboxed_process_func && is_sandboxed_process_func(); | 205 g_is_non_browser_process = NON_BROWSER_PROCESS; |
| 206 return; | |
| 207 } | |
| 202 | 208 |
| 203 // TODO(robertshield): Drop the command line check when we drop support for | 209 const wchar_t* command_line = GetCommandLine(); |
| 204 // enabling chrome_elf in unsandboxed processes. | 210 if (command_line && wcsstr(command_line, L"--type")) { |
| 205 wchar_t* command_line = GetCommandLine(); | 211 g_is_non_browser_process = NON_BROWSER_PROCESS; |
| 206 bool has_process_type_flag = command_line && wcsstr(command_line, L"--type"); | 212 return; |
| 213 } | |
| 207 | 214 |
| 208 return (has_process_type_flag || is_sandboxed_process); | 215 g_is_non_browser_process = BROWSER_PROCESS; |
| 209 } | 216 } |
| 217 | |
| 218 bool IsNonBrowserProcess() { | |
| 219 assert(g_is_non_browser_process != UNINITIALIZED); | |
| 220 return g_is_non_browser_process == NON_BROWSER_PROCESS; | |
| 221 } | |
| OLD | NEW |