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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 *out_file = dir; | 354 *out_file = dir; |
355 HMODULE dll = LoadChromeWithDirectory(out_file); | 355 HMODULE dll = LoadChromeWithDirectory(out_file); |
356 if (dll) | 356 if (dll) |
357 return dll; | 357 return dll; |
358 | 358 |
359 string16 version_string; | 359 string16 version_string; |
360 Version version; | 360 Version version; |
361 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 361 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
362 if (cmd_line.HasSwitch(switches::kChromeVersion)) { | 362 if (cmd_line.HasSwitch(switches::kChromeVersion)) { |
363 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); | 363 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); |
364 version = Version(WideToASCII(version_string)); | 364 version = Version(base::WideToASCII(version_string)); |
365 | 365 |
366 if (!version.IsValid()) { | 366 if (!version.IsValid()) { |
367 // If a bogus command line flag was given, then abort. | 367 // If a bogus command line flag was given, then abort. |
368 LOG(ERROR) << "Invalid command line version: " << version_string; | 368 LOG(ERROR) << "Invalid command line version: " << version_string; |
369 return NULL; | 369 return NULL; |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 // If no version on the command line, then look at the version resource in | 373 // If no version on the command line, then look at the version resource in |
374 // the current module and try loading that. | 374 // the current module and try loading that. |
375 if (!version.IsValid()) { | 375 if (!version.IsValid()) { |
376 scoped_ptr<FileVersionInfo> file_version_info( | 376 scoped_ptr<FileVersionInfo> file_version_info( |
377 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 377 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
378 if (file_version_info.get()) { | 378 if (file_version_info.get()) { |
379 version_string = file_version_info->file_version(); | 379 version_string = file_version_info->file_version(); |
380 version = Version(WideToASCII(version_string)); | 380 version = Version(base::WideToASCII(version_string)); |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 // TODO(robertshield): in theory, these next two checks (env and registry) | 384 // TODO(robertshield): in theory, these next two checks (env and registry) |
385 // should never be needed. Remove them when I become 100% certain this is | 385 // should never be needed. Remove them when I become 100% certain this is |
386 // also true in practice. | 386 // also true in practice. |
387 | 387 |
388 // If no version in the current module, then look in the environment. | 388 // If no version in the current module, then look in the environment. |
389 if (!version.IsValid()) { | 389 if (!version.IsValid()) { |
390 if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), | 390 if (EnvQueryStr(base::ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), |
391 &version_string)) { | 391 &version_string)) { |
392 version = Version(WideToASCII(version_string)); | 392 version = Version(base::WideToASCII(version_string)); |
393 LOG_IF(ERROR, !version.IsValid()) << "Invalid environment version: " | 393 LOG_IF(ERROR, !version.IsValid()) << "Invalid environment version: " |
394 << version_string; | 394 << version_string; |
395 } | 395 } |
396 } | 396 } |
397 | 397 |
398 // If no version in the environment, then look in the registry. | 398 // If no version in the environment, then look in the registry. |
399 if (!version.IsValid()) { | 399 if (!version.IsValid()) { |
400 version_string = GetVersion(); | 400 version_string = GetVersion(); |
401 if (version_string.empty()) { | 401 if (version_string.empty()) { |
402 LOG(ERROR) << "Could not get Chrome DLL version."; | 402 LOG(ERROR) << "Could not get Chrome DLL version."; |
(...skipping 18 matching lines...) Expand all Loading... |
421 // add custom code in the OnBeforeLaunch callback. | 421 // add custom code in the OnBeforeLaunch callback. |
422 int MainDllLoader::Launch(HINSTANCE instance, | 422 int MainDllLoader::Launch(HINSTANCE instance, |
423 sandbox::SandboxInterfaceInfo* sbox_info) { | 423 sandbox::SandboxInterfaceInfo* sbox_info) { |
424 string16 version; | 424 string16 version; |
425 string16 file; | 425 string16 file; |
426 dll_ = Load(&version, &file); | 426 dll_ = Load(&version, &file); |
427 if (!dll_) | 427 if (!dll_) |
428 return chrome::RESULT_CODE_MISSING_DATA; | 428 return chrome::RESULT_CODE_MISSING_DATA; |
429 | 429 |
430 scoped_ptr<base::Environment> env(base::Environment::Create()); | 430 scoped_ptr<base::Environment> env(base::Environment::Create()); |
431 env->SetVar(chrome::kChromeVersionEnvVar, WideToUTF8(version)); | 431 env->SetVar(chrome::kChromeVersionEnvVar, base::WideToUTF8(version)); |
432 // TODO(erikwright): Remove this when http://crbug.com/174953 is fixed and | 432 // TODO(erikwright): Remove this when http://crbug.com/174953 is fixed and |
433 // widely deployed. | 433 // widely deployed. |
434 env->UnSetVar(env_vars::kGoogleUpdateIsMachineEnvVar); | 434 env->UnSetVar(env_vars::kGoogleUpdateIsMachineEnvVar); |
435 | 435 |
436 InitCrashReporter(); | 436 InitCrashReporter(); |
437 OnBeforeLaunch(file); | 437 OnBeforeLaunch(file); |
438 | 438 |
439 DLL_MAIN entry_point = | 439 DLL_MAIN entry_point = |
440 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); | 440 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); |
441 if (!entry_point) | 441 if (!entry_point) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 } | 503 } |
504 }; | 504 }; |
505 | 505 |
506 MainDllLoader* MakeMainDllLoader() { | 506 MainDllLoader* MakeMainDllLoader() { |
507 #if defined(GOOGLE_CHROME_BUILD) | 507 #if defined(GOOGLE_CHROME_BUILD) |
508 return new ChromeDllLoader(); | 508 return new ChromeDllLoader(); |
509 #else | 509 #else |
510 return new ChromiumDllLoader(); | 510 return new ChromiumDllLoader(); |
511 #endif | 511 #endif |
512 } | 512 } |
OLD | NEW |