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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // to the latest version. This is the expected path for the first chrome.exe | 347 // to the latest version. This is the expected path for the first chrome.exe |
348 // browser instance in an installed build. | 348 // browser instance in an installed build. |
349 HMODULE MainDllLoader::Load(std::wstring* out_version, std::wstring* out_file) { | 349 HMODULE MainDllLoader::Load(std::wstring* out_version, std::wstring* out_file) { |
350 const std::wstring dir(GetExecutablePath()); | 350 const std::wstring dir(GetExecutablePath()); |
351 *out_file = dir; | 351 *out_file = dir; |
352 HMODULE dll = LoadChromeWithDirectory(out_file); | 352 HMODULE dll = LoadChromeWithDirectory(out_file); |
353 if (dll) | 353 if (dll) |
354 return dll; | 354 return dll; |
355 | 355 |
356 std::wstring version_string; | 356 std::wstring version_string; |
357 scoped_ptr<Version> version; | 357 Version version; |
358 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 358 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
359 if (cmd_line.HasSwitch(switches::kChromeVersion)) { | 359 if (cmd_line.HasSwitch(switches::kChromeVersion)) { |
360 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); | 360 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); |
361 version.reset(Version::GetVersionFromString(WideToASCII(version_string))); | 361 version = Version(WideToASCII(version_string)); |
362 | 362 |
363 if (!version.get()) { | 363 if (!version.IsValid()) { |
364 // If a bogus command line flag was given, then abort. | 364 // If a bogus command line flag was given, then abort. |
365 LOG(ERROR) << "Invalid command line version: " << version_string; | 365 LOG(ERROR) << "Invalid command line version: " << version_string; |
366 return NULL; | 366 return NULL; |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 // If no version on the command line, then look in the environment. | 370 // If no version on the command line, then look in the environment. |
371 if (!version.get()) { | 371 if (!version.IsValid()) { |
372 if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), | 372 if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), |
373 &version_string)) { | 373 &version_string)) { |
374 version.reset(Version::GetVersionFromString(WideToASCII(version_string))); | 374 version = Version(WideToASCII(version_string)); |
375 LOG_IF(ERROR, !version.get()) << "Invalid environment version: " | 375 LOG_IF(ERROR, !version.IsValid()) << "Invalid environment version: " |
376 << version_string; | 376 << version_string; |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 // If no version in the environment, then look in the registry. | 380 // If no version in the environment, then look in the registry. |
381 if (!version.get()) { | 381 if (!version.IsValid()) { |
382 version_string = GetVersion(); | 382 version_string = GetVersion(); |
383 if (version_string.empty()) { | 383 if (version_string.empty()) { |
384 LOG(ERROR) << "Could not get Chrome DLL version."; | 384 LOG(ERROR) << "Could not get Chrome DLL version."; |
385 return NULL; | 385 return NULL; |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 *out_file = dir; | 389 *out_file = dir; |
390 *out_version = version_string; | 390 *out_version = version_string; |
391 out_file->append(*out_version).append(1, L'\\'); | 391 out_file->append(*out_version).append(1, L'\\'); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 } | 482 } |
483 }; | 483 }; |
484 | 484 |
485 MainDllLoader* MakeMainDllLoader() { | 485 MainDllLoader* MakeMainDllLoader() { |
486 #if defined(GOOGLE_CHROME_BUILD) | 486 #if defined(GOOGLE_CHROME_BUILD) |
487 return new ChromeDllLoader(); | 487 return new ChromeDllLoader(); |
488 #else | 488 #else |
489 return new ChromiumDllLoader(); | 489 return new ChromiumDllLoader(); |
490 #endif | 490 #endif |
491 } | 491 } |
OLD | NEW |