| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app/main_dll_loader_win.h" | 5 #include "chrome/app/main_dll_loader_win.h" |
| 6 | 6 |
| 7 #include <windows.h> // NOLINT | 7 #include <windows.h> // NOLINT |
| 8 #include <shlwapi.h> // NOLINT | 8 #include <shlwapi.h> // NOLINT |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <userenv.h> // NOLINT | 10 #include <userenv.h> // NOLINT |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
| 36 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
| 37 #include "chrome/common/chrome_result_codes.h" | 37 #include "chrome/common/chrome_result_codes.h" |
| 38 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 39 #include "chrome/common/metrics_constants_util_win.h" | 39 #include "chrome/common/metrics_constants_util_win.h" |
| 40 #include "chrome/installer/util/google_update_constants.h" | 40 #include "chrome/installer/util/google_update_constants.h" |
| 41 #include "chrome/installer/util/google_update_settings.h" | 41 #include "chrome/installer/util/google_update_settings.h" |
| 42 #include "chrome/installer/util/install_util.h" | 42 #include "chrome/installer/util/install_util.h" |
| 43 #include "chrome/installer/util/module_util_win.h" | 43 #include "chrome/installer/util/module_util_win.h" |
| 44 #include "chrome/installer/util/util_constants.h" | 44 #include "chrome/installer/util/util_constants.h" |
| 45 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" | |
| 46 #include "content/public/app/sandbox_helper_win.h" | 45 #include "content/public/app/sandbox_helper_win.h" |
| 47 #include "content/public/common/content_switches.h" | 46 #include "content/public/common/content_switches.h" |
| 48 #include "sandbox/win/src/sandbox.h" | 47 #include "sandbox/win/src/sandbox.h" |
| 49 | 48 |
| 50 namespace { | 49 namespace { |
| 51 // The entry point signature of chrome.dll. | 50 // The entry point signature of chrome.dll. |
| 52 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); | 51 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); |
| 53 | 52 |
| 54 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); | 53 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); |
| 55 | 54 |
| 56 // Loads |module| after setting the CWD to |module|'s directory. Returns a | 55 // Loads |module| after setting the CWD to |module|'s directory. Returns a |
| 57 // reference to the loaded module on success, or null on error. | 56 // reference to the loaded module on success, or null on error. |
| 58 HMODULE LoadModuleWithDirectory(const base::FilePath& module) { | 57 HMODULE LoadModuleWithDirectory(const base::FilePath& module) { |
| 59 ::SetCurrentDirectoryW(module.DirName().value().c_str()); | 58 ::SetCurrentDirectoryW(module.DirName().value().c_str()); |
| 60 | 59 PreReadFile(module); |
| 61 const startup_metric_utils::PreReadOptions pre_read_options = | |
| 62 startup_metric_utils::GetPreReadOptions(); | |
| 63 | |
| 64 // If enabled by the PreRead field trial, pre-read the binary to avoid a lot | |
| 65 // of random IO. | |
| 66 if (pre_read_options.pre_read) | |
| 67 PreReadFile(module, pre_read_options); | |
| 68 | |
| 69 return ::LoadLibraryExW(module.value().c_str(), nullptr, | 60 return ::LoadLibraryExW(module.value().c_str(), nullptr, |
| 70 LOAD_WITH_ALTERED_SEARCH_PATH); | 61 LOAD_WITH_ALTERED_SEARCH_PATH); |
| 71 } | 62 } |
| 72 | 63 |
| 73 void RecordDidRun(const base::FilePath& dll_path) { | 64 void RecordDidRun(const base::FilePath& dll_path) { |
| 74 bool system_level = !InstallUtil::IsPerUserInstall(dll_path); | 65 bool system_level = !InstallUtil::IsPerUserInstall(dll_path); |
| 75 GoogleUpdateSettings::UpdateDidRunState(true, system_level); | 66 GoogleUpdateSettings::UpdateDidRunState(true, system_level); |
| 76 } | 67 } |
| 77 | 68 |
| 78 void ClearDidRun(const base::FilePath& dll_path) { | 69 void ClearDidRun(const base::FilePath& dll_path) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 238 } |
| 248 }; | 239 }; |
| 249 | 240 |
| 250 MainDllLoader* MakeMainDllLoader() { | 241 MainDllLoader* MakeMainDllLoader() { |
| 251 #if defined(GOOGLE_CHROME_BUILD) | 242 #if defined(GOOGLE_CHROME_BUILD) |
| 252 return new ChromeDllLoader(); | 243 return new ChromeDllLoader(); |
| 253 #else | 244 #else |
| 254 return new ChromiumDllLoader(); | 245 return new ChromiumDllLoader(); |
| 255 #endif | 246 #endif |
| 256 } | 247 } |
| OLD | NEW |