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_process_type = ProcessType::UNINITIALIZED; |
| 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 InitializeProcessType() { |
| 199 assert(g_process_type == ProcessType::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_process_type = ProcessType::NON_BROWSER_PROCESS; |
| 206 return; |
| 207 } |
202 | 208 |
203 // TODO(robertshield): Drop the command line check when we drop support for | 209 // TODO(robertshield): Drop the command line check when we drop support for |
204 // enabling chrome_elf in unsandboxed processes. | 210 // enabling chrome_elf in unsandboxed processes. |
205 wchar_t* command_line = GetCommandLine(); | 211 const wchar_t* command_line = GetCommandLine(); |
206 bool has_process_type_flag = command_line && wcsstr(command_line, L"--type"); | 212 if (command_line && wcsstr(command_line, L"--type")) { |
| 213 g_process_type = ProcessType::NON_BROWSER_PROCESS; |
| 214 return; |
| 215 } |
207 | 216 |
208 return (has_process_type_flag || is_sandboxed_process); | 217 g_process_type = ProcessType::BROWSER_PROCESS; |
209 } | 218 } |
| 219 |
| 220 bool IsNonBrowserProcess() { |
| 221 assert(g_process_type != ProcessType::UNINITIALIZED); |
| 222 return g_process_type == ProcessType::NON_BROWSER_PROCESS; |
| 223 } |
OLD | NEW |