| 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 "chrome/test/mini_installer_test/chrome_mini_installer.h" | 5 #include "chrome/test/mini_installer_test/chrome_mini_installer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process.h" | 10 #include "base/process.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 if (base::GetProcessCount(installer::kNaClExe, NULL) > 0) { | 358 if (base::GetProcessCount(installer::kNaClExe, NULL) > 0) { |
| 359 printf("NaCl.exe is still running even after closing all windows\n"); | 359 printf("NaCl.exe is still running even after closing all windows\n"); |
| 360 return false; | 360 return false; |
| 361 } | 361 } |
| 362 return true; | 362 return true; |
| 363 } | 363 } |
| 364 | 364 |
| 365 // Checks for Chrome registry keys. | 365 // Checks for Chrome registry keys. |
| 366 bool ChromeMiniInstaller::CheckRegistryKey(const std::wstring& key_path) { | 366 bool ChromeMiniInstaller::CheckRegistryKey(const std::wstring& key_path) { |
| 367 RegKey key; | 367 RegKey key; |
| 368 if (!key.Open(GetRootRegistryKey(), key_path.c_str(), KEY_ALL_ACCESS)) { | 368 LONG ret = key.Open(GetRootRegistryKey(), key_path.c_str(), KEY_ALL_ACCESS); |
| 369 printf("Cannot open reg key\n"); | 369 if (ret != ERROR_SUCCESS) { |
| 370 printf("Cannot open reg key. error: %d\n", ret); |
| 370 return false; | 371 return false; |
| 371 } | 372 } |
| 372 std::wstring reg_key_value_returned; | 373 std::wstring reg_key_value_returned; |
| 373 if (!GetChromeVersionFromRegistry(®_key_value_returned)) | 374 if (!GetChromeVersionFromRegistry(®_key_value_returned)) |
| 374 return false; | 375 return false; |
| 375 return true; | 376 return true; |
| 376 } | 377 } |
| 377 | 378 |
| 378 // Checks for Chrome registry keys on uninstall. | 379 // Checks for Chrome registry keys on uninstall. |
| 379 bool ChromeMiniInstaller::CheckRegistryKeyOnUninstall( | 380 bool ChromeMiniInstaller::CheckRegistryKeyOnUninstall( |
| 380 const std::wstring& key_path) { | 381 const std::wstring& key_path) { |
| 381 RegKey key; | 382 RegKey key; |
| 382 int timer = 0; | 383 int timer = 0; |
| 383 while ((key.Open(GetRootRegistryKey(), key_path.c_str(), KEY_ALL_ACCESS)) && | 384 while ((key.Open(GetRootRegistryKey(), key_path.c_str(), |
| 385 KEY_ALL_ACCESS) == ERROR_SUCCESS) && |
| 384 (timer < 20000)) { | 386 (timer < 20000)) { |
| 385 base::PlatformThread::Sleep(200); | 387 base::PlatformThread::Sleep(200); |
| 386 timer = timer + 200; | 388 timer = timer + 200; |
| 387 } | 389 } |
| 388 return CheckRegistryKey(key_path); | 390 return CheckRegistryKey(key_path); |
| 389 } | 391 } |
| 390 | 392 |
| 391 // Deletes Installer folder from Applications directory. | 393 // Deletes Installer folder from Applications directory. |
| 392 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { | 394 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { |
| 393 FilePath install_path(GetChromeInstallDirectoryLocation()); | 395 FilePath install_path(GetChromeInstallDirectoryLocation()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 439 |
| 438 // Deletes pv key from Clients. | 440 // Deletes pv key from Clients. |
| 439 void ChromeMiniInstaller::DeletePvRegistryKey() { | 441 void ChromeMiniInstaller::DeletePvRegistryKey() { |
| 440 std::wstring pv_key(google_update::kRegPathClients); | 442 std::wstring pv_key(google_update::kRegPathClients); |
| 441 pv_key.append(L"\\"); | 443 pv_key.append(L"\\"); |
| 442 | 444 |
| 443 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 445 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 444 pv_key.append(dist->GetAppGuid()); | 446 pv_key.append(dist->GetAppGuid()); |
| 445 | 447 |
| 446 RegKey key; | 448 RegKey key; |
| 447 if (key.Open(GetRootRegistryKey(), pv_key.c_str(), KEY_ALL_ACCESS)) | 449 LONG ret = key.Open(GetRootRegistryKey(), pv_key.c_str(), KEY_ALL_ACCESS); |
| 448 ASSERT_TRUE(key.DeleteValue(L"pv")); | 450 if (ret == ERROR_SUCCESS) |
| 451 ASSERT_EQ(ERROR_SUCCESS, key.DeleteValue(L"pv")); |
| 449 printf("Deleted %ls key\n", pv_key.c_str()); | 452 printf("Deleted %ls key\n", pv_key.c_str()); |
| 450 } | 453 } |
| 451 | 454 |
| 452 // Verifies if Chrome shortcut exists. | 455 // Verifies if Chrome shortcut exists. |
| 453 void ChromeMiniInstaller::FindChromeShortcut() { | 456 void ChromeMiniInstaller::FindChromeShortcut() { |
| 454 bool return_val = false; | 457 bool return_val = false; |
| 455 FilePath uninstall_lnk; | 458 FilePath uninstall_lnk; |
| 456 FilePath path = GetStartMenuShortcutPath(); | 459 FilePath path = GetStartMenuShortcutPath(); |
| 457 path = path.Append(mini_installer_constants::kChromeBuildType); | 460 path = path.Append(mini_installer_constants::kChromeBuildType); |
| 458 // Verify if path exists. | 461 // Verify if path exists. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 } | 519 } |
| 517 printf("uninstall path is %ls\n", path.c_str()); | 520 printf("uninstall path is %ls\n", path.c_str()); |
| 518 return path; | 521 return path; |
| 519 } | 522 } |
| 520 | 523 |
| 521 // Returns Chrome pv registry key value | 524 // Returns Chrome pv registry key value |
| 522 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( | 525 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( |
| 523 std::wstring* build_key_value) { | 526 std::wstring* build_key_value) { |
| 524 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 527 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 525 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ); | 528 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ); |
| 526 if (!key.ReadValue(L"pv", build_key_value)) { | 529 LONG result = key.ReadValue(L"pv", build_key_value); |
| 527 printf("registry key not found\n"); | 530 if (result != ERROR_SUCCESS) { |
| 531 printf("registry read for chrome version failed. error: %d\n", result); |
| 528 return false; | 532 return false; |
| 529 } | 533 } |
| 530 printf("Build key value is %ls\n\n", build_key_value->c_str()); | 534 printf("Build key value is %ls\n\n", build_key_value->c_str()); |
| 531 return true; | 535 return true; |
| 532 } | 536 } |
| 533 | 537 |
| 534 // Get HKEY based on install type. | 538 // Get HKEY based on install type. |
| 535 HKEY ChromeMiniInstaller::GetRootRegistryKey() { | 539 HKEY ChromeMiniInstaller::GetRootRegistryKey() { |
| 536 HKEY type = HKEY_CURRENT_USER; | 540 HKEY type = HKEY_CURRENT_USER; |
| 537 if (install_type_ == mini_installer_constants::kSystemInstall) | 541 if (install_type_ == mini_installer_constants::kSystemInstall) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 // This method will verify if the installed build is correct. | 680 // This method will verify if the installed build is correct. |
| 677 bool ChromeMiniInstaller::VerifyStandaloneInstall() { | 681 bool ChromeMiniInstaller::VerifyStandaloneInstall() { |
| 678 std::wstring reg_key_value_returned, standalone_installer_version; | 682 std::wstring reg_key_value_returned, standalone_installer_version; |
| 679 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version); | 683 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version); |
| 680 GetChromeVersionFromRegistry(®_key_value_returned); | 684 GetChromeVersionFromRegistry(®_key_value_returned); |
| 681 if (standalone_installer_version.compare(reg_key_value_returned) == 0) | 685 if (standalone_installer_version.compare(reg_key_value_returned) == 0) |
| 682 return true; | 686 return true; |
| 683 else | 687 else |
| 684 return false; | 688 return false; |
| 685 } | 689 } |
| OLD | NEW |