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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/file_version_info.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/rand_util.h" // For PreRead experiment. | 15 #include "base/rand_util.h" // For PreRead experiment. |
15 #include "base/sha1.h" // For PreRead experiment. | 16 #include "base/sha1.h" // For PreRead experiment. |
| 17 #include "base/string16.h" |
16 #include "base/string_util.h" | 18 #include "base/string_util.h" |
17 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
18 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
19 #include "base/version.h" | 21 #include "base/version.h" |
20 #include "base/win/registry.h" | 22 #include "base/win/registry.h" |
21 #include "chrome/app/breakpad_win.h" | 23 #include "chrome/app/breakpad_win.h" |
22 #include "chrome/app/client_util.h" | 24 #include "chrome/app/client_util.h" |
23 #include "chrome/app/image_pre_reader_win.h" | 25 #include "chrome/app/image_pre_reader_win.h" |
24 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/chrome_result_codes.h" | 27 #include "chrome/common/chrome_result_codes.h" |
26 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/installer/util/browser_distribution.h" | 29 #include "chrome/installer/util/browser_distribution.h" |
28 #include "chrome/installer/util/channel_info.h" | 30 #include "chrome/installer/util/channel_info.h" |
29 #include "chrome/installer/util/install_util.h" | 31 #include "chrome/installer/util/install_util.h" |
30 #include "chrome/installer/util/google_update_constants.h" | 32 #include "chrome/installer/util/google_update_constants.h" |
31 #include "chrome/installer/util/google_update_settings.h" | 33 #include "chrome/installer/util/google_update_settings.h" |
32 #include "chrome/installer/util/util_constants.h" | 34 #include "chrome/installer/util/util_constants.h" |
33 | 35 |
34 namespace { | 36 namespace { |
35 // The entry point signature of chrome.dll. | 37 // The entry point signature of chrome.dll. |
36 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); | 38 typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*); |
37 | 39 |
38 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); | 40 typedef void (*RelaunchChromeBrowserWithNewCommandLineIfNeededFunc)(); |
39 | 41 |
40 // Gets chrome version according to the load path. |exe_path| must be the | 42 // Gets chrome version according to the load path. |exe_path| must be the |
41 // backslash terminated directory of the current chrome.exe. | 43 // backslash terminated directory of the current chrome.exe. |
42 bool GetChromeVersion(const wchar_t* exe_dir, const wchar_t* key_path, | 44 bool GetChromeVersion(const wchar_t* exe_dir, const wchar_t* key_path, |
43 std::wstring* version) { | 45 string16* version) { |
44 HKEY reg_root = InstallUtil::IsPerUserInstall(exe_dir) ? HKEY_CURRENT_USER : | 46 HKEY reg_root = InstallUtil::IsPerUserInstall(exe_dir) ? HKEY_CURRENT_USER : |
45 HKEY_LOCAL_MACHINE; | 47 HKEY_LOCAL_MACHINE; |
46 bool success = false; | 48 bool success = false; |
47 | 49 |
48 base::win::RegKey key(reg_root, key_path, KEY_QUERY_VALUE); | 50 base::win::RegKey key(reg_root, key_path, KEY_QUERY_VALUE); |
49 if (key.Valid()) { | 51 if (key.Valid()) { |
50 // If 'new_chrome.exe' is present it means chrome was auto-updated while | 52 // If 'new_chrome.exe' is present it means chrome was auto-updated while |
51 // running. We need to consult the opv value so we can load the old dll. | 53 // running. We need to consult the opv value so we can load the old dll. |
52 // TODO(cpu) : This is solving the same problem as the environment variable | 54 // TODO(cpu) : This is solving the same problem as the environment variable |
53 // so one of them will eventually be deprecated. | 55 // so one of them will eventually be deprecated. |
54 std::wstring new_chrome_exe(exe_dir); | 56 string16 new_chrome_exe(exe_dir); |
55 new_chrome_exe.append(installer::kChromeNewExe); | 57 new_chrome_exe.append(installer::kChromeNewExe); |
56 if (::PathFileExistsW(new_chrome_exe.c_str()) && | 58 if (::PathFileExistsW(new_chrome_exe.c_str()) && |
57 key.ReadValue(google_update::kRegOldVersionField, | 59 key.ReadValue(google_update::kRegOldVersionField, |
58 version) == ERROR_SUCCESS) { | 60 version) == ERROR_SUCCESS) { |
59 success = true; | 61 success = true; |
60 } else { | 62 } else { |
61 success = (key.ReadValue(google_update::kRegVersionField, | 63 success = (key.ReadValue(google_update::kRegVersionField, |
62 version) == ERROR_SUCCESS); | 64 version) == ERROR_SUCCESS); |
63 } | 65 } |
64 } | 66 } |
65 | 67 |
66 return success; | 68 return success; |
67 } | 69 } |
68 | 70 |
69 // Not generic, we only handle strings up to 128 chars. | 71 // Not generic, we only handle strings up to 128 chars. |
70 bool EnvQueryStr(const wchar_t* key_name, std::wstring* value) { | 72 bool EnvQueryStr(const wchar_t* key_name, string16* value) { |
71 wchar_t out[128]; | 73 wchar_t out[128]; |
72 DWORD count = sizeof(out)/sizeof(out[0]); | 74 DWORD count = sizeof(out)/sizeof(out[0]); |
73 DWORD rv = ::GetEnvironmentVariableW(key_name, out, count); | 75 DWORD rv = ::GetEnvironmentVariableW(key_name, out, count); |
74 if ((rv == 0) || (rv >= count)) | 76 if ((rv == 0) || (rv >= count)) |
75 return false; | 77 return false; |
76 *value = out; | 78 *value = out; |
77 return true; | 79 return true; |
78 } | 80 } |
79 | 81 |
80 #if defined(OS_WIN) | 82 #if defined(OS_WIN) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 bool GetPreReadExperimentGroup(DWORD* pre_read_percentage) { | 161 bool GetPreReadExperimentGroup(DWORD* pre_read_percentage) { |
160 DCHECK(pre_read_percentage != NULL); | 162 DCHECK(pre_read_percentage != NULL); |
161 | 163 |
162 // Check if the experiment has expired. | 164 // Check if the experiment has expired. |
163 if (!PreReadExperimentShouldRun()) | 165 if (!PreReadExperimentShouldRun()) |
164 return false; | 166 return false; |
165 | 167 |
166 // Get the MetricsId of the installation. This is only set if the user has | 168 // Get the MetricsId of the installation. This is only set if the user has |
167 // opted in to reporting. Doing things this way ensures that we only enable | 169 // opted in to reporting. Doing things this way ensures that we only enable |
168 // the experiment if its results are actually going to be reported. | 170 // the experiment if its results are actually going to be reported. |
169 std::wstring metrics_id; | 171 string16 metrics_id; |
170 if (!GoogleUpdateSettings::GetMetricsId(&metrics_id) || metrics_id.empty()) | 172 if (!GoogleUpdateSettings::GetMetricsId(&metrics_id) || metrics_id.empty()) |
171 return false; | 173 return false; |
172 | 174 |
173 // We use the same technique as FieldTrial::HashClientId. | 175 // We use the same technique as FieldTrial::HashClientId. |
174 unsigned char sha1_hash[base::kSHA1Length]; | 176 unsigned char sha1_hash[base::kSHA1Length]; |
175 base::SHA1HashBytes( | 177 base::SHA1HashBytes( |
176 reinterpret_cast<const unsigned char*>(metrics_id.c_str()), | 178 reinterpret_cast<const unsigned char*>(metrics_id.c_str()), |
177 metrics_id.size() * sizeof(metrics_id[0]), | 179 metrics_id.size() * sizeof(metrics_id[0]), |
178 sha1_hash); | 180 sha1_hash); |
179 COMPILE_ASSERT(sizeof(uint64) < sizeof(sha1_hash), need_more_data); | 181 COMPILE_ASSERT(sizeof(uint64) < sizeof(sha1_hash), need_more_data); |
(...skipping 11 matching lines...) Expand all Loading... |
191 GetSmallPopulationPreReadBucket(rand_unit)); | 193 GetSmallPopulationPreReadBucket(rand_unit)); |
192 | 194 |
193 return true; | 195 return true; |
194 } | 196 } |
195 #endif // if defined(GOOGLE_CHROME_BUILD) | 197 #endif // if defined(GOOGLE_CHROME_BUILD) |
196 #endif // if defined(OS_WIN) | 198 #endif // if defined(OS_WIN) |
197 | 199 |
198 // Expects that |dir| has a trailing backslash. |dir| is modified so it | 200 // Expects that |dir| has a trailing backslash. |dir| is modified so it |
199 // contains the full path that was tried. Caller must check for the return | 201 // contains the full path that was tried. Caller must check for the return |
200 // value not being null to determine if this path contains a valid dll. | 202 // value not being null to determine if this path contains a valid dll. |
201 HMODULE LoadChromeWithDirectory(std::wstring* dir) { | 203 HMODULE LoadChromeWithDirectory(string16* dir) { |
202 ::SetCurrentDirectoryW(dir->c_str()); | 204 ::SetCurrentDirectoryW(dir->c_str()); |
203 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 205 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
204 dir->append(installer::kChromeDll); | 206 dir->append(installer::kChromeDll); |
205 | 207 |
206 #ifndef WIN_DISABLE_PREREAD | 208 #ifndef WIN_DISABLE_PREREAD |
207 #ifdef NDEBUG | 209 #ifdef NDEBUG |
208 // Experimental pre-reading optimization | 210 // Experimental pre-reading optimization |
209 // The idea is to pre-read a significant portion of chrome.dll in advance | 211 // The idea is to pre-read a significant portion of chrome.dll in advance |
210 // so that subsequent hard page faults are avoided. | 212 // so that subsequent hard page faults are avoided. |
211 // | 213 // |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 pre_read_step_size); | 302 pre_read_step_size); |
301 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); | 303 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); |
302 } | 304 } |
303 #endif // NDEBUG | 305 #endif // NDEBUG |
304 #endif // WIN_DISABLE_PREREAD | 306 #endif // WIN_DISABLE_PREREAD |
305 | 307 |
306 return ::LoadLibraryExW(dir->c_str(), NULL, | 308 return ::LoadLibraryExW(dir->c_str(), NULL, |
307 LOAD_WITH_ALTERED_SEARCH_PATH); | 309 LOAD_WITH_ALTERED_SEARCH_PATH); |
308 } | 310 } |
309 | 311 |
310 void RecordDidRun(const std::wstring& dll_path) { | 312 void RecordDidRun(const string16& dll_path) { |
311 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); | 313 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); |
312 GoogleUpdateSettings::UpdateDidRunState(true, system_level); | 314 GoogleUpdateSettings::UpdateDidRunState(true, system_level); |
313 } | 315 } |
314 | 316 |
315 void ClearDidRun(const std::wstring& dll_path) { | 317 void ClearDidRun(const string16& dll_path) { |
316 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); | 318 bool system_level = !InstallUtil::IsPerUserInstall(dll_path.c_str()); |
317 GoogleUpdateSettings::UpdateDidRunState(false, system_level); | 319 GoogleUpdateSettings::UpdateDidRunState(false, system_level); |
318 } | 320 } |
319 | 321 |
320 } // namespace | 322 } // namespace |
321 | 323 |
322 std::wstring GetExecutablePath() { | 324 string16 GetExecutablePath() { |
323 wchar_t path[MAX_PATH]; | 325 wchar_t path[MAX_PATH]; |
324 ::GetModuleFileNameW(NULL, path, MAX_PATH); | 326 ::GetModuleFileNameW(NULL, path, MAX_PATH); |
325 if (!::PathRemoveFileSpecW(path)) | 327 if (!::PathRemoveFileSpecW(path)) |
326 return std::wstring(); | 328 return string16(); |
327 std::wstring exe_path(path); | 329 string16 exe_path(path); |
328 return exe_path.append(1, L'\\'); | 330 return exe_path.append(1, L'\\'); |
329 } | 331 } |
330 | 332 |
331 //============================================================================= | 333 //============================================================================= |
332 | 334 |
333 MainDllLoader::MainDllLoader() : dll_(NULL) { | 335 MainDllLoader::MainDllLoader() : dll_(NULL) { |
334 } | 336 } |
335 | 337 |
336 MainDllLoader::~MainDllLoader() { | 338 MainDllLoader::~MainDllLoader() { |
337 } | 339 } |
338 | 340 |
339 // Loading chrome is an interesting affair. First we try loading from the | 341 // Loading chrome is an interesting affair. First we try loading from the |
340 // current directory to support run-what-you-compile and other development | 342 // current directory to support run-what-you-compile and other development |
341 // scenarios. | 343 // scenarios. |
342 // If that fails then we look at the --chrome-version command line flag followed | 344 // If that fails then we look at the --chrome-version command line flag followed |
343 // by the 'CHROME_VERSION' env variable to determine if we should stick with an | 345 // by the 'CHROME_VERSION' env variable to determine if we should stick with an |
344 // older dll version even if a new one is available to support upgrade-in-place | 346 // older dll version even if a new one is available to support upgrade-in-place |
345 // scenarios. | 347 // scenarios. |
346 // If that fails then finally we look at the registry which should point us | 348 // If that fails then finally we look at the registry which should point us |
347 // to the latest version. This is the expected path for the first chrome.exe | 349 // to the latest version. This is the expected path for the first chrome.exe |
348 // browser instance in an installed build. | 350 // browser instance in an installed build. |
349 HMODULE MainDllLoader::Load(std::wstring* out_version, std::wstring* out_file) { | 351 HMODULE MainDllLoader::Load(string16* out_version, string16* out_file) { |
350 const std::wstring dir(GetExecutablePath()); | 352 const string16 dir(GetExecutablePath()); |
351 *out_file = dir; | 353 *out_file = dir; |
352 HMODULE dll = LoadChromeWithDirectory(out_file); | 354 HMODULE dll = LoadChromeWithDirectory(out_file); |
353 if (dll) | 355 if (dll) |
354 return dll; | 356 return dll; |
355 | 357 |
356 std::wstring version_string; | 358 string16 version_string; |
357 Version version; | 359 Version version; |
358 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 360 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
359 if (cmd_line.HasSwitch(switches::kChromeVersion)) { | 361 if (cmd_line.HasSwitch(switches::kChromeVersion)) { |
360 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); | 362 version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion); |
361 version = Version(WideToASCII(version_string)); | 363 version = Version(WideToASCII(version_string)); |
362 | 364 |
363 if (!version.IsValid()) { | 365 if (!version.IsValid()) { |
364 // If a bogus command line flag was given, then abort. | 366 // If a bogus command line flag was given, then abort. |
365 LOG(ERROR) << "Invalid command line version: " << version_string; | 367 LOG(ERROR) << "Invalid command line version: " << version_string; |
366 return NULL; | 368 return NULL; |
367 } | 369 } |
368 } | 370 } |
369 | 371 |
370 // If no version on the command line, then look in the environment. | 372 // If no version on the command line, then look at the version resource in |
| 373 // the current module and try loading that. |
| 374 if (!version.IsValid()) { |
| 375 scoped_ptr<FileVersionInfo> file_version_info( |
| 376 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
| 377 if (file_version_info.get()) { |
| 378 version_string = file_version_info->file_version(); |
| 379 version = Version(WideToASCII(version_string)); |
| 380 } |
| 381 } |
| 382 |
| 383 // TODO(robertshield): in theory, these next two checks (env and registry) |
| 384 // should never be needed. Remove them when I become 100% certain this is |
| 385 // also true in practice. |
| 386 |
| 387 // If no version in the current module, then look in the environment. |
371 if (!version.IsValid()) { | 388 if (!version.IsValid()) { |
372 if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), | 389 if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(), |
373 &version_string)) { | 390 &version_string)) { |
374 version = Version(WideToASCII(version_string)); | 391 version = Version(WideToASCII(version_string)); |
375 LOG_IF(ERROR, !version.IsValid()) << "Invalid environment version: " | 392 LOG_IF(ERROR, !version.IsValid()) << "Invalid environment version: " |
376 << version_string; | 393 << version_string; |
377 } | 394 } |
378 } | 395 } |
379 | 396 |
380 // If no version in the environment, then look in the registry. | 397 // If no version in the environment, then look in the registry. |
(...skipping 15 matching lines...) Expand all Loading... |
396 } | 413 } |
397 | 414 |
398 return dll; | 415 return dll; |
399 } | 416 } |
400 | 417 |
401 // Launching is a matter of loading the right dll, setting the CHROME_VERSION | 418 // Launching is a matter of loading the right dll, setting the CHROME_VERSION |
402 // environment variable and just calling the entry point. Derived classes can | 419 // environment variable and just calling the entry point. Derived classes can |
403 // add custom code in the OnBeforeLaunch callback. | 420 // add custom code in the OnBeforeLaunch callback. |
404 int MainDllLoader::Launch(HINSTANCE instance, | 421 int MainDllLoader::Launch(HINSTANCE instance, |
405 sandbox::SandboxInterfaceInfo* sbox_info) { | 422 sandbox::SandboxInterfaceInfo* sbox_info) { |
406 std::wstring version; | 423 string16 version; |
407 std::wstring file; | 424 string16 file; |
408 dll_ = Load(&version, &file); | 425 dll_ = Load(&version, &file); |
409 if (!dll_) | 426 if (!dll_) |
410 return chrome::RESULT_CODE_MISSING_DATA; | 427 return chrome::RESULT_CODE_MISSING_DATA; |
411 | 428 |
412 scoped_ptr<base::Environment> env(base::Environment::Create()); | 429 scoped_ptr<base::Environment> env(base::Environment::Create()); |
413 env->SetVar(chrome::kChromeVersionEnvVar, WideToUTF8(version)); | 430 env->SetVar(chrome::kChromeVersionEnvVar, WideToUTF8(version)); |
414 | 431 |
415 InitCrashReporter(); | 432 InitCrashReporter(); |
416 OnBeforeLaunch(file); | 433 OnBeforeLaunch(file); |
417 | 434 |
418 DLL_MAIN entry_point = | 435 DLL_MAIN entry_point = |
419 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); | 436 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain")); |
420 if (!entry_point) | 437 if (!entry_point) |
421 return chrome::RESULT_CODE_BAD_PROCESS_TYPE; | 438 return chrome::RESULT_CODE_BAD_PROCESS_TYPE; |
422 | 439 |
423 int rc = entry_point(instance, sbox_info); | 440 int rc = entry_point(instance, sbox_info); |
424 return OnBeforeExit(rc, file); | 441 return OnBeforeExit(rc, file); |
425 } | 442 } |
426 | 443 |
427 std::wstring MainDllLoader::GetVersion() { | 444 string16 MainDllLoader::GetVersion() { |
428 std::wstring reg_path(GetRegistryPath()); | 445 string16 reg_path(GetRegistryPath()); |
429 std::wstring version_string; | 446 string16 version_string; |
430 std::wstring dir(GetExecutablePath()); | 447 string16 dir(GetExecutablePath()); |
431 if (!GetChromeVersion(dir.c_str(), reg_path.c_str(), &version_string)) | 448 if (!GetChromeVersion(dir.c_str(), reg_path.c_str(), &version_string)) |
432 return std::wstring(); | 449 return string16(); |
433 return version_string; | 450 return version_string; |
434 } | 451 } |
435 | 452 |
436 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { | 453 void MainDllLoader::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
437 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function = | 454 RelaunchChromeBrowserWithNewCommandLineIfNeededFunc relaunch_function = |
438 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>( | 455 reinterpret_cast<RelaunchChromeBrowserWithNewCommandLineIfNeededFunc>( |
439 ::GetProcAddress(dll_, | 456 ::GetProcAddress(dll_, |
440 "RelaunchChromeBrowserWithNewCommandLineIfNeeded")); | 457 "RelaunchChromeBrowserWithNewCommandLineIfNeeded")); |
441 if (!relaunch_function) { | 458 if (!relaunch_function) { |
442 LOG(ERROR) << "Could not find exported function " | 459 LOG(ERROR) << "Could not find exported function " |
443 << "RelaunchChromeBrowserWithNewCommandLineIfNeeded"; | 460 << "RelaunchChromeBrowserWithNewCommandLineIfNeeded"; |
444 } else { | 461 } else { |
445 relaunch_function(); | 462 relaunch_function(); |
446 } | 463 } |
447 } | 464 } |
448 | 465 |
449 //============================================================================= | 466 //============================================================================= |
450 | 467 |
451 class ChromeDllLoader : public MainDllLoader { | 468 class ChromeDllLoader : public MainDllLoader { |
452 public: | 469 public: |
453 virtual std::wstring GetRegistryPath() { | 470 virtual string16 GetRegistryPath() { |
454 std::wstring key(google_update::kRegPathClients); | 471 string16 key(google_update::kRegPathClients); |
455 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 472 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
456 key.append(L"\\").append(dist->GetAppGuid()); | 473 key.append(L"\\").append(dist->GetAppGuid()); |
457 return key; | 474 return key; |
458 } | 475 } |
459 | 476 |
460 virtual void OnBeforeLaunch(const std::wstring& dll_path) { | 477 virtual void OnBeforeLaunch(const string16& dll_path) { |
461 RecordDidRun(dll_path); | 478 RecordDidRun(dll_path); |
462 } | 479 } |
463 | 480 |
464 virtual int OnBeforeExit(int return_code, const std::wstring& dll_path) { | 481 virtual int OnBeforeExit(int return_code, const string16& dll_path) { |
465 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels | 482 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels |
466 // so we need to reset the did_run signal so omaha does not count | 483 // so we need to reset the did_run signal so omaha does not count |
467 // this run as active usage. | 484 // this run as active usage. |
468 if (chrome::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) { | 485 if (chrome::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) { |
469 ClearDidRun(dll_path); | 486 ClearDidRun(dll_path); |
470 } | 487 } |
471 return return_code; | 488 return return_code; |
472 } | 489 } |
473 }; | 490 }; |
474 | 491 |
475 //============================================================================= | 492 //============================================================================= |
476 | 493 |
477 class ChromiumDllLoader : public MainDllLoader { | 494 class ChromiumDllLoader : public MainDllLoader { |
478 public: | 495 public: |
479 virtual std::wstring GetRegistryPath() { | 496 virtual string16 GetRegistryPath() { |
480 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 497 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
481 return dist->GetVersionKey(); | 498 return dist->GetVersionKey(); |
482 } | 499 } |
483 }; | 500 }; |
484 | 501 |
485 MainDllLoader* MakeMainDllLoader() { | 502 MainDllLoader* MakeMainDllLoader() { |
486 #if defined(GOOGLE_CHROME_BUILD) | 503 #if defined(GOOGLE_CHROME_BUILD) |
487 return new ChromeDllLoader(); | 504 return new ChromeDllLoader(); |
488 #else | 505 #else |
489 return new ChromiumDllLoader(); | 506 return new ChromiumDllLoader(); |
490 #endif | 507 #endif |
491 } | 508 } |
OLD | NEW |