OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "base/version.h" | 16 #include "base/version.h" |
16 #include "chrome/app/breakpad_win.h" | 17 #include "chrome/app/breakpad_win.h" |
17 #include "chrome/app/client_util.h" | 18 #include "chrome/app/client_util.h" |
18 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/result_codes.h" | 21 #include "chrome/common/result_codes.h" |
21 #include "chrome/installer/util/browser_distribution.h" | 22 #include "chrome/installer/util/browser_distribution.h" |
22 #include "chrome/installer/util/install_util.h" | 23 #include "chrome/installer/util/install_util.h" |
23 #include "chrome/installer/util/google_update_constants.h" | 24 #include "chrome/installer/util/google_update_constants.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // If that fails then finally we look at the registry which should point us | 207 // If that fails then finally we look at the registry which should point us |
207 // to the latest version. This is the expected path for the first chrome.exe | 208 // to the latest version. This is the expected path for the first chrome.exe |
208 // browser instance in an installed build. | 209 // browser instance in an installed build. |
209 HMODULE MainDllLoader::Load(std::wstring* out_version, std::wstring* out_file) { | 210 HMODULE MainDllLoader::Load(std::wstring* out_version, std::wstring* out_file) { |
210 std::wstring dir(GetExecutablePath()); | 211 std::wstring dir(GetExecutablePath()); |
211 *out_file = dir; | 212 *out_file = dir; |
212 HMODULE dll = LoadChromeWithDirectory(out_file); | 213 HMODULE dll = LoadChromeWithDirectory(out_file); |
213 if (dll) | 214 if (dll) |
214 return dll; | 215 return dll; |
215 | 216 |
216 std::wstring version_env_string; | 217 std::wstring version_string; |
217 scoped_ptr<Version> version; | 218 scoped_ptr<Version> version; |
218 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 219 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
219 if (cmd_line.HasSwitch(switches::kChromeVersion)) { | 220 if (cmd_line.HasSwitch(switches::kChromeVersion)) { |
220 version_env_string = cmd_line.GetSwitchValueNative( | 221 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); |
221 switches::kChromeVersion); | 222 version.reset(Version::GetVersionFromString(WideToASCII(version_string))); |
222 version.reset(Version::GetVersionFromString(version_env_string)); | |
223 | 223 |
224 if (!version.get()) { | 224 if (!version.get()) { |
225 // If a bogus command line flag was given, then abort. | 225 // If a bogus command line flag was given, then abort. |
226 LOG(ERROR) << "Invalid version string received on command line: " | 226 LOG(ERROR) << "Invalid version string received on command line: " |
227 << version_env_string; | 227 << version_string; |
228 return NULL; | 228 return NULL; |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 if (!version.get()) { | 232 if (!version.get()) { |
233 if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), | 233 if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), |
234 &version_env_string)) { | 234 &version_string)) { |
235 version.reset(Version::GetVersionFromString(version_env_string)); | 235 version.reset(Version::GetVersionFromString(WideToASCII(version_string))); |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 if (!version.get()) { | 239 if (!version.get()) { |
240 std::wstring reg_path(GetRegistryPath()); | 240 std::wstring reg_path(GetRegistryPath()); |
241 // Look into the registry to find the latest version. We don't validate | 241 // Look into the registry to find the latest version. We don't validate |
242 // this by building a Version object to avoid harming normal case startup | 242 // this by building a Version object to avoid harming normal case startup |
243 // time. | 243 // time. |
244 version_env_string.clear(); | 244 version_string.clear(); |
245 GetVersion(dir.c_str(), reg_path.c_str(), &version_env_string); | 245 GetVersion(dir.c_str(), reg_path.c_str(), &version_string); |
246 } | 246 } |
247 | 247 |
248 if (version.get() || !version_env_string.empty()) { | 248 if (version.get() || !version_string.empty()) { |
249 *out_file = dir; | 249 *out_file = dir; |
250 *out_version = version_env_string; | 250 *out_version = version_string; |
251 out_file->append(*out_version).append(L"\\"); | 251 out_file->append(*out_version).append(L"\\"); |
252 return LoadChromeWithDirectory(out_file); | 252 return LoadChromeWithDirectory(out_file); |
253 } else { | 253 } else { |
254 return NULL; | 254 return NULL; |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 // Launching is a matter of loading the right dll, setting the CHROME_VERSION | 258 // Launching is a matter of loading the right dll, setting the CHROME_VERSION |
259 // environment variable and just calling the entry point. Derived classes can | 259 // environment variable and just calling the entry point. Derived classes can |
260 // add custom code in the OnBeforeLaunch callback. | 260 // add custom code in the OnBeforeLaunch callback. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 332 } |
333 }; | 333 }; |
334 | 334 |
335 MainDllLoader* MakeMainDllLoader() { | 335 MainDllLoader* MakeMainDllLoader() { |
336 #if defined(GOOGLE_CHROME_BUILD) | 336 #if defined(GOOGLE_CHROME_BUILD) |
337 return new ChromeDllLoader(); | 337 return new ChromeDllLoader(); |
338 #else | 338 #else |
339 return new ChromiumDllLoader(); | 339 return new ChromiumDllLoader(); |
340 #endif | 340 #endif |
341 } | 341 } |
OLD | NEW |