| 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> | |
| 8 #include <windows.h> | 7 #include <windows.h> |
| 9 | 8 |
| 10 #include "base/macros.h" | 9 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 12 | 11 |
| 13 ProcessType g_process_type = ProcessType::UNINITIALIZED; | |
| 14 | |
| 15 namespace { | 12 namespace { |
| 16 | 13 |
| 17 const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; | 14 const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; |
| 18 const wchar_t kRegPathClientStateMedium[] = | 15 const wchar_t kRegPathClientStateMedium[] = |
| 19 L"Software\\Google\\Update\\ClientStateMedium"; | 16 L"Software\\Google\\Update\\ClientStateMedium"; |
| 20 #if defined(GOOGLE_CHROME_BUILD) | 17 #if defined(GOOGLE_CHROME_BUILD) |
| 21 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Google\\Chrome"; | 18 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Google\\Chrome"; |
| 22 #else | 19 #else |
| 23 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Chromium"; | 20 const wchar_t kRegPathChromePolicy[] = L"SOFTWARE\\Policies\\Chromium"; |
| 24 #endif // defined(GOOGLE_CHROME_BUILD) | 21 #endif // defined(GOOGLE_CHROME_BUILD) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 value_bytes, &size) == ERROR_SUCCESS) { | 185 value_bytes, &size) == ERROR_SUCCESS) { |
| 189 *breakpad_enabled = value != 0; | 186 *breakpad_enabled = value != 0; |
| 190 } | 187 } |
| 191 ::RegCloseKey(key); | 188 ::RegCloseKey(key); |
| 192 return size == sizeof(value); | 189 return size == sizeof(value); |
| 193 } | 190 } |
| 194 | 191 |
| 195 return false; | 192 return false; |
| 196 } | 193 } |
| 197 | 194 |
| 198 void InitializeProcessType() { | 195 bool IsNonBrowserProcess() { |
| 199 assert(g_process_type == UNINITIALIZED); | |
| 200 typedef bool (*IsSandboxedProcessFunc)(); | 196 typedef bool (*IsSandboxedProcessFunc)(); |
| 201 IsSandboxedProcessFunc is_sandboxed_process_func = | 197 IsSandboxedProcessFunc is_sandboxed_process_func = |
| 202 reinterpret_cast<IsSandboxedProcessFunc>( | 198 reinterpret_cast<IsSandboxedProcessFunc>( |
| 203 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); | 199 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); |
| 204 if (is_sandboxed_process_func && is_sandboxed_process_func()) { | 200 bool is_sandboxed_process = |
| 205 g_process_type = NON_BROWSER_PROCESS; | 201 is_sandboxed_process_func && is_sandboxed_process_func(); |
| 206 return; | |
| 207 } | |
| 208 | 202 |
| 209 const wchar_t* command_line = GetCommandLine(); | 203 // TODO(robertshield): Drop the command line check when we drop support for |
| 210 if (command_line && wcsstr(command_line, L"--type")) { | 204 // enabling chrome_elf in unsandboxed processes. |
| 211 g_process_type = NON_BROWSER_PROCESS; | 205 wchar_t* command_line = GetCommandLine(); |
| 212 return; | 206 bool has_process_type_flag = command_line && wcsstr(command_line, L"--type"); |
| 213 } | |
| 214 | 207 |
| 215 g_process_type = BROWSER_PROCESS; | 208 return (has_process_type_flag || is_sandboxed_process); |
| 216 } | 209 } |
| 217 | |
| 218 bool IsNonBrowserProcess() { | |
| 219 assert(g_process_type != UNINITIALIZED); | |
| 220 return g_process_type == NON_BROWSER_PROCESS; | |
| 221 } | |
| OLD | NEW |