| 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 <stdint.h> | 10 #include <stdint.h> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 GoogleUpdateSettings::UpdateDidRunState(true, system_level); | 67 GoogleUpdateSettings::UpdateDidRunState(true, system_level); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ClearDidRun(const base::FilePath& dll_path) { | 70 void ClearDidRun(const base::FilePath& dll_path) { |
| 71 bool system_level = !InstallUtil::IsPerUserInstall(dll_path); | 71 bool system_level = !InstallUtil::IsPerUserInstall(dll_path); |
| 72 GoogleUpdateSettings::UpdateDidRunState(false, system_level); | 72 GoogleUpdateSettings::UpdateDidRunState(false, system_level); |
| 73 } | 73 } |
| 74 | 74 |
| 75 typedef int (*InitMetro)(); | 75 typedef int (*InitMetro)(); |
| 76 | 76 |
| 77 bool ProcessTypeUsesMainDll(const std::string& process_type) { |
| 78 return process_type.empty() || process_type == switches::kServiceProcess; |
| 79 } |
| 80 |
| 77 } // namespace | 81 } // namespace |
| 78 | 82 |
| 79 //============================================================================= | 83 //============================================================================= |
| 80 | 84 |
| 81 MainDllLoader::MainDllLoader() | 85 MainDllLoader::MainDllLoader() |
| 82 : dll_(nullptr) { | 86 : dll_(nullptr) { |
| 83 } | 87 } |
| 84 | 88 |
| 85 MainDllLoader::~MainDllLoader() { | 89 MainDllLoader::~MainDllLoader() { |
| 86 } | 90 } |
| 87 | 91 |
| 88 HMODULE MainDllLoader::Load(base::FilePath* module) { | 92 HMODULE MainDllLoader::Load(base::FilePath* module) { |
| 89 const base::char16* dll_name = nullptr; | 93 const base::char16* dll_name = nullptr; |
| 90 if (process_type_ == switches::kServiceProcess || process_type_.empty()) { | 94 if (ProcessTypeUsesMainDll(process_type_)) { |
| 91 dll_name = installer::kChromeDll; | 95 dll_name = installer::kChromeDll; |
| 92 } else if (process_type_ == switches::kWatcherProcess) { | 96 } else if (process_type_ == switches::kWatcherProcess) { |
| 93 dll_name = kChromeWatcherDll; | 97 dll_name = kChromeWatcherDll; |
| 94 } else { | 98 } else { |
| 95 #if defined(CHROME_MULTIPLE_DLL) | 99 #if defined(CHROME_MULTIPLE_DLL) |
| 96 dll_name = installer::kChromeChildDll; | 100 dll_name = installer::kChromeChildDll; |
| 97 #else | 101 #else |
| 98 dll_name = installer::kChromeDll; | 102 dll_name = installer::kChromeDll; |
| 99 #endif | 103 #endif |
| 100 } | 104 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 178 } |
| 175 | 179 |
| 176 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { | 180 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 177 if (!dll_) | 181 if (!dll_) |
| 178 return; | 182 return; |
| 179 | 183 |
| 180 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function = | 184 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function = |
| 181 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>( | 185 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>( |
| 182 ::GetProcAddress(dll_, | 186 ::GetProcAddress(dll_, |
| 183 "RelaunchChromeBrowserWithNewCommandLineIfNeeded")); | 187 "RelaunchChromeBrowserWithNewCommandLineIfNeeded")); |
| 184 if (!relaunch_function) { | 188 if (relaunch_function) { |
| 185 LOG(ERROR) << "Could not find exported function " | |
| 186 << "RelaunchChromeBrowserWithNewCommandLineIfNeeded " | |
| 187 << "(" << process_type_ << " process)"; | |
| 188 } else { | |
| 189 relaunch_function(); | 189 relaunch_function(); |
| 190 } else if (ProcessTypeUsesMainDll(process_type_)) { |
| 191 LOG(DFATAL) << "Could not find exported function " |
| 192 << "RelaunchChromeBrowserWithNewCommandLineIfNeeded " |
| 193 << "(" << process_type_ << " process)"; |
| 190 } | 194 } |
| 191 } | 195 } |
| 192 | 196 |
| 193 //============================================================================= | 197 //============================================================================= |
| 194 | 198 |
| 195 class ChromeDllLoader : public MainDllLoader { | 199 class ChromeDllLoader : public MainDllLoader { |
| 196 protected: | 200 protected: |
| 197 // MainDllLoader implementation. | 201 // MainDllLoader implementation. |
| 198 void OnBeforeLaunch(const std::string& process_type, | 202 void OnBeforeLaunch(const std::string& process_type, |
| 199 const base::FilePath& dll_path) override; | 203 const base::FilePath& dll_path) override; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 254 } |
| 251 }; | 255 }; |
| 252 | 256 |
| 253 MainDllLoader* MakeMainDllLoader() { | 257 MainDllLoader* MakeMainDllLoader() { |
| 254 #if defined(GOOGLE_CHROME_BUILD) | 258 #if defined(GOOGLE_CHROME_BUILD) |
| 255 return new ChromeDllLoader(); | 259 return new ChromeDllLoader(); |
| 256 #else | 260 #else |
| 257 return new ChromiumDllLoader(); | 261 return new ChromiumDllLoader(); |
| 258 #endif | 262 #endif |
| 259 } | 263 } |
| OLD | NEW |