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 <windows.h> | 5 #include <windows.h> |
6 #include <shlwapi.h> | 6 #include <shlwapi.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void RecordDidRun(const string16& dll_path) { | 67 void RecordDidRun(const string16& dll_path) { |
68 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); | 68 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); |
69 GoogleUpdateSettings::UpdateDidRunState(true, system_level); | 69 GoogleUpdateSettings::UpdateDidRunState(true, system_level); |
70 } | 70 } |
71 | 71 |
72 void ClearDidRun(const string16& dll_path) { | 72 void ClearDidRun(const string16& dll_path) { |
73 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); | 73 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); |
74 GoogleUpdateSettings::UpdateDidRunState(false, system_level); | 74 GoogleUpdateSettings::UpdateDidRunState(false, system_level); |
75 } | 75 } |
76 | 76 |
| 77 #if defined(CHROME_SPLIT_DLL) |
| 78 // Deferred initialization entry point for chrome1.dll. |
| 79 typedef BOOL (__stdcall *DoDeferredCrtInitFunc)(HINSTANCE hinstance); |
| 80 |
| 81 bool InitSplitChromeDll(HMODULE mod) { |
| 82 if (!mod) |
| 83 return false; |
| 84 DoDeferredCrtInitFunc init = reinterpret_cast<DoDeferredCrtInitFunc>( |
| 85 ::GetProcAddress(mod, "_DoDeferredCrtInit@4")); |
| 86 return (init(mod) == TRUE); |
| 87 } |
| 88 #endif |
77 } // namespace | 89 } // namespace |
78 | 90 |
79 string16 GetExecutablePath() { | 91 string16 GetExecutablePath() { |
80 wchar_t path[MAX_PATH]; | 92 wchar_t path[MAX_PATH]; |
81 ::GetModuleFileNameW(NULL, path, MAX_PATH); | 93 ::GetModuleFileNameW(NULL, path, MAX_PATH); |
82 if (!::PathRemoveFileSpecW(path)) | 94 if (!::PathRemoveFileSpecW(path)) |
83 return string16(); | 95 return string16(); |
84 string16 exe_path(path); | 96 string16 exe_path(path); |
85 return exe_path.append(1, L'\\'); | 97 return exe_path.append(1, L'\\'); |
86 } | 98 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 out_file->append(*out_version).append(1, L'\\'); | 159 out_file->append(*out_version).append(1, L'\\'); |
148 dll = LoadChromeWithDirectory(out_file); | 160 dll = LoadChromeWithDirectory(out_file); |
149 if (!dll) { | 161 if (!dll) { |
150 PLOG(ERROR) << "Failed to load Chrome DLL from " << *out_file; | 162 PLOG(ERROR) << "Failed to load Chrome DLL from " << *out_file; |
151 return NULL; | 163 return NULL; |
152 } | 164 } |
153 } | 165 } |
154 | 166 |
155 DCHECK(dll); | 167 DCHECK(dll); |
156 | 168 |
| 169 #if defined(CHROME_SPLIT_DLL) |
| 170 // In split dlls mode, we need to manually initialize both DLLs because |
| 171 // the circular dependencies between them make the loader not call the |
| 172 // Dllmain for DLL_PROCESS_ATTACH. |
| 173 InitSplitChromeDll(dll); |
| 174 InitSplitChromeDll(::GetModuleHandleA("chrome1.dll")); |
| 175 #endif |
| 176 |
157 return dll; | 177 return dll; |
158 } | 178 } |
159 | 179 |
160 // Launching is a matter of loading the right dll, setting the CHROME_VERSION | 180 // Launching is a matter of loading the right dll, setting the CHROME_VERSION |
161 // environment variable and just calling the entry point. Derived classes can | 181 // environment variable and just calling the entry point. Derived classes can |
162 // add custom code in the OnBeforeLaunch callback. | 182 // add custom code in the OnBeforeLaunch callback. |
163 int MainDllLoader::Launch(HINSTANCE instance, | 183 int MainDllLoader::Launch(HINSTANCE instance, |
164 sandbox::SandboxInterfaceInfo* sbox_info) { | 184 sandbox::SandboxInterfaceInfo* sbox_info) { |
165 string16 version; | 185 string16 version; |
166 string16 file; | 186 string16 file; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 256 } |
237 }; | 257 }; |
238 | 258 |
239 MainDllLoader* MakeMainDllLoader() { | 259 MainDllLoader* MakeMainDllLoader() { |
240 #if defined(GOOGLE_CHROME_BUILD) | 260 #if defined(GOOGLE_CHROME_BUILD) |
241 return new ChromeDllLoader(); | 261 return new ChromeDllLoader(); |
242 #else | 262 #else |
243 return new ChromiumDllLoader(); | 263 return new ChromiumDllLoader(); |
244 #endif | 264 #endif |
245 } | 265 } |
OLD | NEW |