| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/process.h" | 12 #include "base/process.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
| 18 #include "base/win/registry.h" | 18 #include "base/win/registry.h" |
| 19 #include "chrome/installer/util/browser_distribution.h" | 19 #include "chrome/installer/util/browser_distribution.h" |
| 20 #include "chrome/installer/util/google_update_constants.h" | 20 #include "chrome/installer/util/google_update_constants.h" |
| 21 #include "chrome/installer/util/helper.h" |
| 22 #include "chrome/installer/util/install_util.h" |
| 21 #include "chrome/installer/util/installation_validation_helper.h" | 23 #include "chrome/installer/util/installation_validation_helper.h" |
| 24 #include "chrome/installer/util/util_constants.h" |
| 25 #include "chrome/test/base/chrome_process_util.h" |
| 22 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" | 26 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" |
| 23 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" | 27 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 29 |
| 26 using base::win::RegKey; | 30 using base::win::RegKey; |
| 31 using installer::InstallationValidator; |
| 27 | 32 |
| 28 namespace { | 33 namespace { |
| 29 | 34 |
| 30 struct FilePathInfo { | 35 struct FilePathInfo { |
| 31 file_util::FileEnumerator::FindInfo info; | 36 file_util::FileEnumerator::FindInfo info; |
| 32 FilePath path; | 37 FilePath path; |
| 33 }; | 38 }; |
| 34 | 39 |
| 35 bool CompareDate(const FilePathInfo& a, | 40 bool CompareDate(const FilePathInfo& a, |
| 36 const FilePathInfo& b) { | 41 const FilePathInfo& b) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 std::vector<FilePath> paths; | 88 std::vector<FilePath> paths; |
| 84 if (FindMatchingFiles(root, pattern, type, &paths)) { | 89 if (FindMatchingFiles(root, pattern, type, &paths)) { |
| 85 *path = paths[0]; | 90 *path = paths[0]; |
| 86 return true; | 91 return true; |
| 87 } | 92 } |
| 88 return false; | 93 return false; |
| 89 } | 94 } |
| 90 | 95 |
| 91 } // namespace | 96 } // namespace |
| 92 | 97 |
| 93 ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type, | 98 ChromeMiniInstaller::ChromeMiniInstaller(bool system_install, |
| 94 bool is_chrome_frame) | 99 bool is_chrome_frame) |
| 95 : is_chrome_frame_(is_chrome_frame), | 100 : is_chrome_frame_(is_chrome_frame), |
| 96 install_type_(install_type) {} | 101 system_install_(system_install) {} |
| 97 | 102 |
| 98 void ChromeMiniInstaller::SetBuildUnderTest( | 103 void ChromeMiniInstaller::SetBuildUnderTest( |
| 99 const std::wstring& build) { | 104 const std::wstring& build) { |
| 100 if (!LocateInstallers(build)) { | 105 if (!LocateInstallers(build)) { |
| 101 LOG(WARNING) << "Could not find one or more installers."; | 106 LOG(WARNING) << "Could not find one or more installers."; |
| 102 } | 107 } |
| 103 } | 108 } |
| 104 | 109 |
| 105 // Installs Chrome. | 110 // Installs Chrome. |
| 106 void ChromeMiniInstaller::Install() { | 111 void ChromeMiniInstaller::Install() { |
| 107 FilePath installer_path = MiniInstallerTestUtil::GetFilePath( | 112 InstallMiniInstaller(false, mini_installer_); |
| 108 mini_installer_constants::kChromeMiniInstallerExecutable); | |
| 109 InstallMiniInstaller(false, installer_path); | |
| 110 } | 113 } |
| 111 | 114 |
| 112 // This method will get the previous latest full installer from | 115 // This method will get the previous latest full installer from |
| 113 // nightly location, install it and over install with specified install_type. | 116 // nightly location, install it and over install with specified install_type. |
| 114 void ChromeMiniInstaller::OverInstallOnFullInstaller( | 117 void ChromeMiniInstaller::OverInstallOnFullInstaller( |
| 115 const std::wstring& install_type, bool should_start_ie) { | 118 const std::wstring& install_type, bool should_start_ie) { |
| 116 ASSERT_TRUE(!full_installer_.empty() && !diff_installer_.empty() && | 119 ASSERT_TRUE(!full_installer_.empty() && !diff_installer_.empty() && |
| 117 !previous_installer_.empty()); | 120 !previous_installer_.empty()); |
| 118 | 121 |
| 119 if (should_start_ie) | 122 if (should_start_ie) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // This method will get the latest full installer from nightly location | 160 // This method will get the latest full installer from nightly location |
| 158 // and installs it. | 161 // and installs it. |
| 159 void ChromeMiniInstaller::InstallFullInstaller(bool over_install) { | 162 void ChromeMiniInstaller::InstallFullInstaller(bool over_install) { |
| 160 if (!full_installer_.empty()) | 163 if (!full_installer_.empty()) |
| 161 InstallMiniInstaller(over_install, full_installer_); | 164 InstallMiniInstaller(over_install, full_installer_); |
| 162 } | 165 } |
| 163 | 166 |
| 164 // Installs the Chrome mini-installer, checks the registry and shortcuts. | 167 // Installs the Chrome mini-installer, checks the registry and shortcuts. |
| 165 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, | 168 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, |
| 166 const FilePath& path) { | 169 const FilePath& path) { |
| 167 LOG(INFO) << "Chrome will be installed at " | 170 LOG(INFO) << "Install level is: " |
| 168 << install_type_ << "level."; | 171 << (system_install_ ? "system" : "user"); |
| 169 LOG(INFO) << "Will proceed with the test only if this path exists: " | 172 RunInstaller(CommandLine(path)); |
| 170 << path.value(); | |
| 171 | 173 |
| 172 ASSERT_TRUE(file_util::PathExists(path)) << path.value() | 174 std::wstring version; |
| 173 << " does not exist."; | 175 ASSERT_TRUE(GetChromeVersionFromRegistry(&version)) |
| 174 LaunchInstaller(path, path.BaseName().value().c_str()); | 176 << "Install failed: unable to get version."; |
| 177 VerifyInstall(over_install); |
| 178 } |
| 179 |
| 180 void ChromeMiniInstaller::InstallUsingMultiInstall() { |
| 181 ASSERT_TRUE(file_util::PathExists(mini_installer_)); |
| 182 CommandLine cmd(mini_installer_); |
| 183 cmd.AppendSwitch(installer::switches::kMultiInstall); |
| 184 cmd.AppendSwitch(installer::switches::kChrome); |
| 185 RunInstaller(cmd); |
| 186 |
| 187 // Verify installation. |
| 188 InstallationValidator::InstallationType type = |
| 189 installer::ExpectValidInstallation(system_install_); |
| 175 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 190 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 176 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())) << dist->GetVersionKey() | 191 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); |
| 177 << " does not exist."; | 192 if (is_chrome_frame_) { |
| 178 VerifyInstall(over_install); | 193 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); |
| 194 VerifyChromeFrameInstall(); |
| 195 } else { |
| 196 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); |
| 197 } |
| 198 FindChromeShortcut(); |
| 199 LaunchChrome(false); |
| 179 } | 200 } |
| 180 | 201 |
| 181 // This method tests the standalone installer by verifying the steps listed at: | 202 // This method tests the standalone installer by verifying the steps listed at: |
| 182 // https://sites.google.com/a/google.com/chrome-pmo/ | 203 // https://sites.google.com/a/google.com/chrome-pmo/ |
| 183 // standalone-installers/testing-standalone-installers | 204 // standalone-installers/testing-standalone-installers |
| 184 // This method applies appropriate tags to standalone installer and deletes | 205 // This method applies appropriate tags to standalone installer and deletes |
| 185 // old installer before running the new tagged installer. It also verifies | 206 // old installer before running the new tagged installer. It also verifies |
| 186 // that the installed version is correct. | 207 // that the installed version is correct. |
| 187 void ChromeMiniInstaller::InstallStandaloneInstaller() { | 208 void ChromeMiniInstaller::InstallStandaloneInstaller() { |
| 188 file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); | 209 file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 211 tagged_installer.value().c_str(), | 232 tagged_installer.value().c_str(), |
| 212 mini_installer_constants::kChromeApplyTagParameters)); | 233 mini_installer_constants::kChromeApplyTagParameters)); |
| 213 LOG(INFO) << "Tagging command: " << command.GetCommandLineString(); | 234 LOG(INFO) << "Tagging command: " << command.GetCommandLineString(); |
| 214 return command; | 235 return command; |
| 215 } | 236 } |
| 216 | 237 |
| 217 // Installs chromesetup.exe, waits for the install to finish and then | 238 // Installs chromesetup.exe, waits for the install to finish and then |
| 218 // checks the registry and shortcuts. | 239 // checks the registry and shortcuts. |
| 219 void ChromeMiniInstaller::InstallMetaInstaller() { | 240 void ChromeMiniInstaller::InstallMetaInstaller() { |
| 220 // Install Google Chrome through meta installer. | 241 // Install Google Chrome through meta installer. |
| 221 LaunchInstaller(FilePath(mini_installer_constants::kChromeMetaInstallerExe), | 242 CommandLine installer(FilePath::FromWStringHack( |
| 222 mini_installer_constants::kChromeSetupExecutable); | 243 mini_installer_constants::kChromeMetaInstallerExe)); |
| 244 RunInstaller(installer); |
| 223 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( | 245 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( |
| 224 mini_installer_constants::kChromeMetaInstallerExecutable)); | 246 mini_installer_constants::kChromeMetaInstallerExecutable)); |
| 247 |
| 225 std::wstring chrome_google_update_state_key( | 248 std::wstring chrome_google_update_state_key( |
| 226 google_update::kRegPathClients); | 249 google_update::kRegPathClients); |
| 227 chrome_google_update_state_key.append(L"\\"); | 250 chrome_google_update_state_key.append(L"\\"); |
| 228 | 251 |
| 229 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 252 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 230 chrome_google_update_state_key.append(dist->GetAppGuid()); | 253 chrome_google_update_state_key.append(dist->GetAppGuid()); |
| 231 | 254 |
| 232 ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key)); | 255 ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key)); |
| 233 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); | 256 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); |
| 234 FindChromeShortcut(); | 257 FindChromeShortcut(); |
| 235 LaunchAndCloseChrome(false); | 258 LaunchChrome(true); |
| 236 } | 259 } |
| 237 | 260 |
| 238 // If the build type is Google Chrome, then it first installs meta installer | 261 // If the build type is Google Chrome, then it first installs meta installer |
| 239 // and then over installs with mini_installer. It also verifies if Chrome can | 262 // and then over installs with mini_installer. It also verifies if Chrome can |
| 240 // be launched successfully after overinstall. | 263 // be launched successfully after overinstall. |
| 241 void ChromeMiniInstaller::OverInstall() { | 264 void ChromeMiniInstaller::OverInstall() { |
| 242 InstallMetaInstaller(); | 265 InstallMetaInstaller(); |
| 243 std::wstring reg_key_value_returned; | 266 std::wstring reg_key_value_returned; |
| 244 // gets the registry key value before overinstall. | 267 // gets the registry key value before overinstall. |
| 245 GetChromeVersionFromRegistry(®_key_value_returned); | 268 GetChromeVersionFromRegistry(®_key_value_returned); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 267 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 290 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 268 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { | 291 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { |
| 269 DeleteFolder(L"version_folder"); | 292 DeleteFolder(L"version_folder"); |
| 270 printf("Deleted folder. Now trying to launch chrome\n"); | 293 printf("Deleted folder. Now trying to launch chrome\n"); |
| 271 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { | 294 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { |
| 272 DeletePvRegistryKey(); | 295 DeletePvRegistryKey(); |
| 273 printf("Deleted registry. Now trying to launch chrome\n"); | 296 printf("Deleted registry. Now trying to launch chrome\n"); |
| 274 } | 297 } |
| 275 FilePath current_path; | 298 FilePath current_path; |
| 276 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); | 299 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); |
| 277 VerifyChromeLaunch(false); | 300 LaunchChrome(false); |
| 278 printf("\nInstalling Chrome again to see if it can be repaired\n\n"); | 301 LOG(INFO) << "Installing Chrome again to see if it can be repaired."; |
| 279 InstallFullInstaller(true); | 302 InstallFullInstaller(true); |
| 280 printf("Chrome repair successful.\n"); | 303 LOG(INFO) << "Chrome repair successful."; |
| 281 // Set the current directory back to original path. | 304 // Set the current directory back to original path. |
| 282 file_util::SetCurrentDirectory(current_path); | 305 file_util::SetCurrentDirectory(current_path); |
| 283 } | 306 } |
| 284 | 307 |
| 285 // This method first checks if Chrome is running. | 308 // This method first checks if Chrome is running. |
| 286 // If yes, will close all the processes. | 309 // If yes, will close all the processes. |
| 287 // Then will find and spawn uninstall path. | 310 // Then will find and spawn uninstall path. |
| 288 // Handles uninstall confirm dialog. | 311 // Handles uninstall confirm dialog. |
| 289 // Waits until setup.exe ends. | 312 // Waits until setup.exe ends. |
| 290 // Checks if registry key exist even after uninstall. | 313 // Checks if registry key exist even after uninstall. |
| 291 // Deletes App dir. | 314 // Deletes App dir. |
| 292 // Closes feedback form. | 315 // Closes feedback form. |
| 293 void ChromeMiniInstaller::UnInstall() { | 316 void ChromeMiniInstaller::UnInstall() { |
| 294 std::wstring product_name; | |
| 295 if (is_chrome_frame_) | |
| 296 product_name = mini_installer_constants::kChromeFrameProductName; | |
| 297 else | |
| 298 product_name = mini_installer_constants::kChromeProductName; | |
| 299 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 317 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 300 if (!CheckRegistryKey(dist->GetVersionKey())) { | 318 std::wstring version; |
| 301 printf("%ls is not installed.\n", product_name.c_str()); | 319 std::string result; |
| 320 |
| 321 if (!GetChromeVersionFromRegistry(&version)) |
| 302 return; | 322 return; |
| 303 } | 323 |
| 324 // Close running products. |
| 304 if (is_chrome_frame_) { | 325 if (is_chrome_frame_) { |
| 305 MiniInstallerTestUtil::CloseProcesses( | 326 MiniInstallerTestUtil::CloseProcesses( |
| 306 mini_installer_constants::kIEProcessName); | 327 mini_installer_constants::kIEProcessName); |
| 307 } else { | 328 } else { |
| 308 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); | 329 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); |
| 309 } | 330 } |
| 310 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 331 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 311 std::wstring uninstall_path = GetUninstallPath(); | 332 // Get uninstall command. |
| 312 if (uninstall_path.empty()) { | 333 CommandLine cmd = InstallUtil::GetChromeUninstallCmd( |
| 313 printf("\n %ls install is in a weird state. Cleaning the machine...\n", | 334 system_install_, dist->GetType()); |
| 314 product_name.c_str()); | 335 |
| 315 CleanChromeInstall(); | 336 LOG(INFO) << "Uninstall command: " << cmd.GetCommandLineString(); |
| 316 return; | 337 ASSERT_TRUE(file_util::PathExists(cmd.GetProgram())) |
| 317 } | 338 << "Uninstall executable does not exist."; |
| 318 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path))); | 339 |
| 319 std::wstring uninstall_args(L"\""); | 340 cmd.AppendSwitch(installer::switches::kUninstall); |
| 320 uninstall_args.append(uninstall_path); | 341 cmd.AppendSwitch(installer::switches::kForceUninstall); |
| 321 uninstall_args.append(L"\" --uninstall --force-uninstall"); | |
| 322 if (is_chrome_frame_) | 342 if (is_chrome_frame_) |
| 323 uninstall_args.append(L" --chrome-frame"); | 343 cmd.AppendSwitch(installer::switches::kChromeFrame); |
| 324 if (install_type_ == mini_installer_constants::kSystemInstall) | 344 if (system_install_) |
| 325 uninstall_args = uninstall_args + L" --system-level"; | 345 cmd.AppendSwitch(installer::switches::kSystemLevel); |
| 326 | 346 |
| 327 base::ProcessHandle setup_handle; | 347 base::ProcessHandle setup_handle; |
| 328 base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle); | 348 ASSERT_TRUE(base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle)) |
| 349 << "Failed to launch uninstall command."; |
| 329 | 350 |
| 330 if (is_chrome_frame_) | 351 if (is_chrome_frame_) |
| 331 ASSERT_TRUE(CloseUninstallWindow()); | 352 ASSERT_TRUE(CloseUninstallWindow()); |
| 332 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); | 353 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); |
| 333 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); | 354 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())) |
| 355 << "It appears Chrome was not completely uninstalled."; |
| 334 | 356 |
| 335 DeleteUserDataFolder(); | 357 DeleteUserDataFolder(); |
| 336 // Close IE survey window that gets launched on uninstall. | 358 // Close IE survey window that gets launched on uninstall. |
| 337 if (!is_chrome_frame_) { | 359 if (!is_chrome_frame_) { |
| 338 FindChromeShortcut(); | 360 FindChromeShortcut(); |
| 339 MiniInstallerTestUtil::CloseProcesses( | 361 MiniInstallerTestUtil::CloseProcesses( |
| 340 mini_installer_constants::kIEExecutable); | 362 mini_installer_constants::kIEExecutable); |
| 341 ASSERT_EQ(0, | 363 ASSERT_EQ(0, |
| 342 base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL)); | 364 base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL)); |
| 343 } | 365 } |
| 344 } | 366 } |
| 345 | 367 |
| 346 void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() { | 368 void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() { |
| 369 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 347 std::wstring product_name = | 370 std::wstring product_name = |
| 348 mini_installer_constants::kChromeFrameProductName; | 371 mini_installer_constants::kChromeFrameProductName; |
| 349 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
| 350 if (!CheckRegistryKey(dist->GetVersionKey())) { | 372 if (!CheckRegistryKey(dist->GetVersionKey())) { |
| 351 printf("%ls is not installed.\n", product_name.c_str()); | 373 printf("%ls is not installed.\n", product_name.c_str()); |
| 352 return; | 374 return; |
| 353 } | 375 } |
| 354 | 376 |
| 355 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 377 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 356 std::wstring uninstall_path = GetUninstallPath(); | |
| 357 | 378 |
| 358 if (uninstall_path.empty()) { | 379 CommandLine cmd = InstallUtil::GetChromeUninstallCmd( |
| 359 printf("\n %ls install is in a weird state. Cleaning the machine...\n", | 380 system_install_, dist->GetType()); |
| 360 product_name.c_str()); | 381 |
| 382 if (cmd.GetProgram().empty()) { |
| 383 LOG(ERROR) << "Unable to get uninstall command."; |
| 361 CleanChromeInstall(); | 384 CleanChromeInstall(); |
| 362 return; | |
| 363 } | 385 } |
| 364 | 386 |
| 365 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path))); | 387 ASSERT_TRUE(file_util::PathExists(cmd.GetProgram())); |
| 366 std::wstring uninstall_args(L"\""); | |
| 367 uninstall_args.append(uninstall_path); | |
| 368 uninstall_args.append(L"\" --uninstall --force-uninstall"); | |
| 369 uninstall_args.append(L" --chrome-frame"); | |
| 370 | 388 |
| 371 if (install_type_ == mini_installer_constants::kSystemInstall) | 389 cmd.AppendSwitch(installer::switches::kUninstall); |
| 372 uninstall_args = uninstall_args + L" --system-level"; | 390 cmd.AppendSwitch(installer::switches::kForceUninstall); |
| 391 cmd.AppendSwitch(installer::switches::kChromeFrame); |
| 392 |
| 393 if (system_install_) |
| 394 cmd.AppendSwitch(installer::switches::kSystemLevel); |
| 373 | 395 |
| 374 base::ProcessHandle setup_handle; | 396 base::ProcessHandle setup_handle; |
| 375 base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle); | 397 base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle); |
| 376 | 398 |
| 377 ASSERT_TRUE(CloseUninstallWindow()); | 399 ASSERT_TRUE(CloseUninstallWindow()); |
| 378 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); | 400 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); |
| 379 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); | 401 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); |
| 380 | 402 |
| 381 DeleteUserDataFolder(); | 403 DeleteUserDataFolder(); |
| 382 MiniInstallerTestUtil::CloseProcesses( | 404 MiniInstallerTestUtil::CloseProcesses( |
| 383 mini_installer_constants::kIEProcessName); | 405 mini_installer_constants::kIEProcessName); |
| 384 } | 406 } |
| 385 | 407 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 KEY_ALL_ACCESS) == ERROR_SUCCESS) && | 499 KEY_ALL_ACCESS) == ERROR_SUCCESS) && |
| 478 (timer < 20000)) { | 500 (timer < 20000)) { |
| 479 base::PlatformThread::Sleep(200); | 501 base::PlatformThread::Sleep(200); |
| 480 timer = timer + 200; | 502 timer = timer + 200; |
| 481 } | 503 } |
| 482 return CheckRegistryKey(key_path); | 504 return CheckRegistryKey(key_path); |
| 483 } | 505 } |
| 484 | 506 |
| 485 // Deletes Installer folder from Applications directory. | 507 // Deletes Installer folder from Applications directory. |
| 486 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { | 508 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { |
| 487 FilePath install_path(GetChromeInstallDirectoryLocation()); | 509 FilePath install_path; |
| 510 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); |
| 488 std::wstring temp_chrome_dir; | 511 std::wstring temp_chrome_dir; |
| 489 if (is_chrome_frame_) { | 512 if (is_chrome_frame_) { |
| 490 temp_chrome_dir = mini_installer_constants::kChromeFrameAppDir; | 513 temp_chrome_dir = mini_installer_constants::kChromeFrameAppDir; |
| 491 } else { | |
| 492 temp_chrome_dir = mini_installer_constants::kChromeAppDir; | |
| 493 } | 514 } |
| 494 | 515 |
| 495 if (wcscmp(folder_name, L"version_folder") == 0) { | 516 if (wcscmp(folder_name, L"version_folder") == 0) { |
| 496 std::wstring build_number; | 517 std::wstring build_number; |
| 497 GetChromeVersionFromRegistry(&build_number); | 518 GetChromeVersionFromRegistry(&build_number); |
| 498 temp_chrome_dir = temp_chrome_dir + build_number; | 519 temp_chrome_dir = temp_chrome_dir + build_number; |
| 499 install_path = install_path.Append(temp_chrome_dir); | 520 install_path = install_path.Append(temp_chrome_dir); |
| 500 } else if (wcscmp(folder_name, temp_chrome_dir.c_str()) == 0) { | 521 } else if (wcscmp(folder_name, temp_chrome_dir.c_str()) == 0) { |
| 501 install_path = install_path.Append(folder_name).StripTrailingSeparators(); | 522 install_path = install_path.Append(folder_name).StripTrailingSeparators(); |
| 502 } | 523 } |
| 503 printf("This path will be deleted: %ls\n", install_path.value().c_str()); | 524 ASSERT_TRUE(file_util::PathExists(install_path)) |
| 525 << "Could not find path to delete:" << install_path.value(); |
| 526 LOG(INFO) << "This path will be deleted: " << install_path.value(); |
| 504 ASSERT_TRUE(file_util::Delete(install_path, true)); | 527 ASSERT_TRUE(file_util::Delete(install_path, true)); |
| 505 } | 528 } |
| 506 | 529 |
| 507 // Will delete user data profile. | 530 // Will delete user data profile. |
| 508 void ChromeMiniInstaller::DeleteUserDataFolder() { | 531 void ChromeMiniInstaller::DeleteUserDataFolder() { |
| 509 FilePath path = GetUserDataDirPath(); | 532 FilePath path = GetUserDataDirPath(); |
| 510 if (file_util::PathExists(path)) | 533 if (file_util::PathExists(path)) |
| 511 ASSERT_TRUE(file_util::Delete(path, true)); | 534 ASSERT_TRUE(file_util::Delete(path, true)); |
| 512 } | 535 } |
| 513 | 536 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (file_util::PathExists(path)) { | 577 if (file_util::PathExists(path)) { |
| 555 return_val = true; | 578 return_val = true; |
| 556 uninstall_lnk = path; | 579 uninstall_lnk = path; |
| 557 path = path.Append(mini_installer_constants::kChromeLaunchShortcut); | 580 path = path.Append(mini_installer_constants::kChromeLaunchShortcut); |
| 558 uninstall_lnk = uninstall_lnk.Append( | 581 uninstall_lnk = uninstall_lnk.Append( |
| 559 mini_installer_constants::kChromeUninstallShortcut); | 582 mini_installer_constants::kChromeUninstallShortcut); |
| 560 ASSERT_TRUE(file_util::PathExists(path)); | 583 ASSERT_TRUE(file_util::PathExists(path)); |
| 561 ASSERT_TRUE(file_util::PathExists(uninstall_lnk)); | 584 ASSERT_TRUE(file_util::PathExists(uninstall_lnk)); |
| 562 } | 585 } |
| 563 if (return_val) { | 586 if (return_val) { |
| 564 printf("Chrome shortcuts found are:\n%ls\n%ls\n\n", | 587 LOG(INFO) << "Found Chrome shortcuts:\n" |
| 565 path.value().c_str(), uninstall_lnk.value().c_str()); | 588 << path.value() << "\n" |
| 589 << uninstall_lnk.value(); |
| 566 } else { | 590 } else { |
| 567 printf("Chrome shortcuts not found\n\n"); | 591 LOG(INFO) << "No Chrome shortcuts found."; |
| 568 } | 592 } |
| 569 } | 593 } |
| 570 | 594 |
| 571 // This method returns path to either program files | 595 bool ChromeMiniInstaller::GetChromeInstallDirectoryLocation(FilePath* path) { |
| 572 // or documents and setting based on the install type. | 596 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 573 std::wstring ChromeMiniInstaller::GetChromeInstallDirectoryLocation() { | 597 *path = installer::GetChromeInstallPath(system_install_, dist); |
| 574 FilePath path; | 598 FilePath parent; |
| 575 if (install_type_ == mini_installer_constants::kSystemInstall) | 599 if (system_install_) { |
| 576 PathService::Get(base::DIR_PROGRAM_FILES, &path); | 600 PathService::Get(base::DIR_PROGRAM_FILES, &parent); |
| 577 else | 601 return file_util::ContainsPath(parent, *path); |
| 578 PathService::Get(base::DIR_LOCAL_APP_DATA, &path); | 602 } else { |
| 579 return path.value(); | 603 PathService::Get(base::DIR_LOCAL_APP_DATA, &parent); |
| 604 return file_util::ContainsPath(parent, *path); |
| 605 } |
| 580 } | 606 } |
| 581 | 607 |
| 582 FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() { | 608 FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() { |
| 583 FilePath path_name; | 609 FilePath path_name; |
| 584 if (install_type_ == mini_installer_constants::kSystemInstall) | 610 if (system_install_) |
| 585 PathService::Get(base::DIR_COMMON_START_MENU, &path_name); | 611 PathService::Get(base::DIR_COMMON_START_MENU, &path_name); |
| 586 else | 612 else |
| 587 PathService::Get(base::DIR_START_MENU, &path_name); | 613 PathService::Get(base::DIR_START_MENU, &path_name); |
| 588 return path_name; | 614 return path_name; |
| 589 } | 615 } |
| 590 | 616 |
| 591 // Gets the path for uninstall. | |
| 592 std::wstring ChromeMiniInstaller::GetUninstallPath() { | |
| 593 std::wstring path, reg_key_value; | |
| 594 if (!GetChromeVersionFromRegistry(®_key_value)) | |
| 595 return std::wstring(); | |
| 596 path = GetChromeInstallDirectoryLocation(); | |
| 597 if (is_chrome_frame_) { | |
| 598 file_util::AppendToPath(&path, | |
| 599 mini_installer_constants::kChromeFrameAppDir); | |
| 600 } else { | |
| 601 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); | |
| 602 } | |
| 603 file_util::AppendToPath(&path, reg_key_value); | |
| 604 file_util::AppendToPath(&path, installer::kInstallerDir); | |
| 605 file_util::AppendToPath(&path, | |
| 606 mini_installer_constants::kChromeSetupExecutable); | |
| 607 if (!file_util::PathExists(FilePath(path))) { | |
| 608 printf("This uninstall path is not correct %ls. Will not proceed further", | |
| 609 path.c_str()); | |
| 610 return L""; | |
| 611 } | |
| 612 printf("uninstall path is %ls\n", path.c_str()); | |
| 613 return path; | |
| 614 } | |
| 615 | |
| 616 // Returns Chrome pv registry key value | 617 // Returns Chrome pv registry key value |
| 617 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( | 618 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( |
| 618 std::wstring* build_key_value) { | 619 std::wstring* build_key_value) { |
| 619 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 620 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 620 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ); | 621 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ); |
| 621 LONG result = key.ReadValue(L"pv", build_key_value); | 622 LONG result = key.ReadValue(L"pv", build_key_value); |
| 622 if (result != ERROR_SUCCESS) { | 623 if (result != ERROR_SUCCESS) { |
| 623 printf("registry read for chrome version failed. error: %d\n", result); | 624 LOG(WARNING) << "Registry read for Chrome version error: " << result; |
| 624 return false; | 625 return false; |
| 625 } | 626 } |
| 626 printf("Build key value is %ls\n\n", build_key_value->c_str()); | 627 LOG(INFO) << "Build key value is " << build_key_value; |
| 627 return true; | 628 return true; |
| 628 } | 629 } |
| 629 | 630 |
| 630 // Get HKEY based on install type. | 631 // Get HKEY based on install type. |
| 631 HKEY ChromeMiniInstaller::GetRootRegistryKey() { | 632 HKEY ChromeMiniInstaller::GetRootRegistryKey() { |
| 632 HKEY type = HKEY_CURRENT_USER; | 633 HKEY type = HKEY_CURRENT_USER; |
| 633 if (install_type_ == mini_installer_constants::kSystemInstall) | 634 if (system_install_) |
| 634 type = HKEY_LOCAL_MACHINE; | 635 type = HKEY_LOCAL_MACHINE; |
| 635 return type; | 636 return type; |
| 636 } | 637 } |
| 637 | 638 |
| 638 // Launches the chrome installer and waits for it to end. | 639 // Launches the chrome installer and waits for it to end. |
| 639 void ChromeMiniInstaller::LaunchInstaller(const FilePath& path, | 640 void ChromeMiniInstaller::RunInstaller(const CommandLine& command) { |
| 640 const wchar_t* process_name) { | 641 ASSERT_TRUE(file_util::PathExists(command.GetProgram())); |
| 641 ASSERT_TRUE(file_util::PathExists(path)); | 642 CommandLine installer(command); |
| 642 std::wstring launch_args; | |
| 643 if (is_chrome_frame_) { | 643 if (is_chrome_frame_) { |
| 644 launch_args.append(L" --do-not-create-shortcuts"); | 644 installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts); |
| 645 launch_args.append(L" --do-not-launch-chrome"); | 645 installer.AppendSwitch(installer::switches::kDoNotLaunchChrome); |
| 646 launch_args.append(L" --do-not-register-for-update-launch"); | 646 installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); |
| 647 launch_args.append(L" --chrome-frame"); | 647 installer.AppendSwitch(installer::switches::kChromeFrame); |
| 648 } | 648 } |
| 649 if (install_type_ == mini_installer_constants::kSystemInstall) { | 649 if (system_install_) { |
| 650 launch_args.append(L" --system-level"); | 650 installer.AppendSwitch(installer::switches::kSystemLevel); |
| 651 } | 651 } |
| 652 | 652 |
| 653 LOG(INFO) << "Running installer command: " |
| 654 << installer.GetCommandLineString(); |
| 653 base::ProcessHandle app_handle; | 655 base::ProcessHandle app_handle; |
| 654 base::LaunchProcess(L"\"" + path.value() + L"\"" + launch_args, | 656 ASSERT_TRUE( |
| 655 base::LaunchOptions(), &app_handle); | 657 base::LaunchProcess(installer, base::LaunchOptions(), &app_handle)) |
| 656 | 658 << "Installer failed."; |
| 657 printf("Waiting while this process is running %ls ....\n", process_name); | 659 ASSERT_TRUE(base::WaitForSingleProcess(app_handle, 60 * 1000)) |
| 658 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); | 660 << "Installer did not complete."; |
| 659 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(app_handle)); | |
| 660 } | 661 } |
| 661 | 662 |
| 662 // Gets the path to launch Chrome. | 663 void ChromeMiniInstaller::LaunchChrome(bool kill) { |
| 663 bool ChromeMiniInstaller::GetChromeLaunchPath(FilePath* launch_path) { | 664 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 664 std::wstring path; | |
| 665 path = GetChromeInstallDirectoryLocation(); | |
| 666 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); | |
| 667 file_util::AppendToPath(&path, installer::kChromeExe); | |
| 668 *launch_path = FilePath(path); | |
| 669 return file_util::PathExists(*launch_path); | |
| 670 } | |
| 671 | 665 |
| 672 // Launch Chrome to see if it works after overinstall. Then close it. | 666 FilePath install_path; |
| 673 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { | 667 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); |
| 674 VerifyChromeLaunch(true); | 668 install_path = install_path.Append(installer::kChromeExe); |
| 675 if ((install_type_ == mini_installer_constants::kSystemInstall) && | 669 CommandLine browser(install_path); |
| 676 (!over_install)) { | 670 |
| 677 MiniInstallerTestUtil::VerifyProcessLaunch( | 671 FilePath exe = browser.GetProgram(); |
| 678 installer::kChromeExe, true); | 672 LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString(); |
| 673 base::ProcessHandle chrome; |
| 674 ASSERT_TRUE(base::LaunchProcess(browser, base::LaunchOptions(), &chrome)) |
| 675 << "Could not launch process: " << exe.value(); |
| 676 |
| 677 if (kill) { |
| 678 ASSERT_TRUE(base::KillProcess(chrome, 0, true)) |
| 679 << "Failed to kill chrome.exe"; |
| 679 } | 680 } |
| 680 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | |
| 681 } | |
| 682 | |
| 683 // This method will get Chrome exe path and launch it. | |
| 684 void ChromeMiniInstaller::VerifyChromeLaunch(bool expected_status) { | |
| 685 FilePath launch_path; | |
| 686 GetChromeLaunchPath(&launch_path); | |
| 687 LaunchBrowser(launch_path, L"", expected_status); | |
| 688 } | 681 } |
| 689 | 682 |
| 690 // Verifies Chrome/Chrome Frame install. | 683 // Verifies Chrome/Chrome Frame install. |
| 691 void ChromeMiniInstaller::VerifyInstall(bool over_install) { | 684 void ChromeMiniInstaller::VerifyInstall(bool over_install) { |
| 692 VerifyMachineState(); | |
| 693 if (is_chrome_frame_) { | |
| 694 VerifyChromeFrameInstall(); | |
| 695 } else { | |
| 696 if ((install_type_ == mini_installer_constants::kUserInstall) && | |
| 697 (!over_install)) { | |
| 698 MiniInstallerTestUtil::VerifyProcessLaunch( | |
| 699 installer::kChromeExe, true); | |
| 700 } | |
| 701 base::PlatformThread::Sleep(800); | |
| 702 FindChromeShortcut(); | |
| 703 LaunchAndCloseChrome(over_install); | |
| 704 } | |
| 705 } | |
| 706 | |
| 707 // This method verifies installation of Chrome/Chrome Frame via machine | |
| 708 // introspection. | |
| 709 void ChromeMiniInstaller::VerifyMachineState() { | |
| 710 using installer::InstallationValidator; | |
| 711 | |
| 712 InstallationValidator::InstallationType type = | 685 InstallationValidator::InstallationType type = |
| 713 installer::ExpectValidInstallation( | 686 installer::ExpectValidInstallation(system_install_); |
| 714 install_type_ == mini_installer_constants::kSystemInstall); | |
| 715 if (is_chrome_frame_) { | 687 if (is_chrome_frame_) { |
| 716 EXPECT_NE(0, | 688 EXPECT_NE(0, |
| 717 type & InstallationValidator::ProductBits::CHROME_FRAME_SINGLE); | 689 type & InstallationValidator::ProductBits::CHROME_FRAME_SINGLE); |
| 718 } else { | 690 } else { |
| 719 EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_SINGLE); | 691 EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_SINGLE); |
| 720 } | 692 } |
| 693 |
| 694 if (is_chrome_frame_) |
| 695 VerifyChromeFrameInstall(); |
| 696 else if (!system_install_ && !over_install) |
| 697 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); |
| 698 |
| 699 base::PlatformThread::Sleep(800); |
| 700 FindChromeShortcut(); |
| 701 LaunchChrome(true); |
| 721 } | 702 } |
| 722 | 703 |
| 723 // This method will verify if ChromeFrame installed successfully. It will | 704 // This method will verify if ChromeFrame installed successfully. It will |
| 724 // launch IE with cf:about:version, then check if | 705 // launch IE with cf:about:version, then check if |
| 725 // chrome.exe process got spawned. | 706 // chrome.exe process got spawned. |
| 726 void ChromeMiniInstaller::VerifyChromeFrameInstall() { | 707 void ChromeMiniInstaller::VerifyChromeFrameInstall() { |
| 727 // Launch IE | 708 // Launch IE |
| 728 LaunchIE(L"gcf:about:version"); | 709 LaunchIE(L"gcf:about:version"); |
| 729 | 710 |
| 730 // Check if Chrome process got spawned. | 711 // Check if Chrome process got spawned. |
| 731 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); | 712 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); |
| 732 } | 713 } |
| 733 | 714 |
| 734 void ChromeMiniInstaller::LaunchIE(const std::wstring& navigate_url) { | 715 void ChromeMiniInstaller::LaunchIE(const std::wstring& navigate_url) { |
| 735 FilePath browser_path; | 716 FilePath browser_path; |
| 736 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); | 717 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); |
| 737 browser_path = browser_path.Append(mini_installer_constants::kIELocation); | 718 browser_path = browser_path.Append(mini_installer_constants::kIELocation); |
| 738 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); | 719 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); |
| 739 | 720 |
| 740 CommandLine cmd_line(browser_path); | 721 CommandLine cmd_line(browser_path); |
| 741 cmd_line.AppendArgNative(navigate_url); | 722 cmd_line.AppendArgNative(navigate_url); |
| 742 | 723 |
| 743 base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); | 724 base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); |
| 744 } | 725 } |
| 745 | 726 |
| 746 // This method will launch any requested browser. | |
| 747 void ChromeMiniInstaller::LaunchBrowser(const FilePath& path, | |
| 748 const std::wstring& args, | |
| 749 bool expected_status) { | |
| 750 LOG(INFO) << "Browser executable: " << path.value(); | |
| 751 bool launched = base::LaunchProcess( | |
| 752 L"\"" + path.value() + L"\"" + L" " + args, | |
| 753 base::LaunchOptions(), NULL); | |
| 754 if (!launched) { | |
| 755 LOG(ERROR) << "Could not launch process: " << path.BaseName().value(); | |
| 756 } | |
| 757 base::PlatformThread::Sleep(1000); | |
| 758 MiniInstallerTestUtil::VerifyProcessLaunch(path.BaseName().value().c_str(), | |
| 759 expected_status); | |
| 760 } | |
| 761 | |
| 762 // This method compares the registry keys after overinstall. | 727 // This method compares the registry keys after overinstall. |
| 763 bool ChromeMiniInstaller::VerifyOverInstall( | 728 bool ChromeMiniInstaller::VerifyOverInstall( |
| 764 const std::wstring& value_before_overinstall, | 729 const std::wstring& value_before_overinstall, |
| 765 const std::wstring& value_after_overinstall) { | 730 const std::wstring& value_after_overinstall) { |
| 766 int64 reg_key_value_before_overinstall; | 731 int64 reg_key_value_before_overinstall; |
| 767 base::StringToInt64(value_before_overinstall, | 732 base::StringToInt64(value_before_overinstall, |
| 768 ®_key_value_before_overinstall); | 733 ®_key_value_before_overinstall); |
| 769 int64 reg_key_value_after_overinstall; | 734 int64 reg_key_value_after_overinstall; |
| 770 base::StringToInt64(value_after_overinstall, | 735 base::StringToInt64(value_after_overinstall, |
| 771 ®_key_value_after_overinstall); | 736 ®_key_value_after_overinstall); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 791 else | 756 else |
| 792 return false; | 757 return false; |
| 793 } | 758 } |
| 794 | 759 |
| 795 // Search all the specified |build| directory to find the latest | 760 // Search all the specified |build| directory to find the latest |
| 796 // diff and full installers. |build| can be empty. | 761 // diff and full installers. |build| can be empty. |
| 797 bool ChromeMiniInstaller::LocateInstallers( | 762 bool ChromeMiniInstaller::LocateInstallers( |
| 798 const std::wstring& build) { | 763 const std::wstring& build) { |
| 799 FilePath::StringType full_installer_pattern = | 764 FilePath::StringType full_installer_pattern = |
| 800 FILE_PATH_LITERAL("*_chrome_installer*"); | 765 FILE_PATH_LITERAL("*_chrome_installer*"); |
| 801 FilePath::StringType diff_installer_pattern = FILE_PATH_LITERAL("*_from_*"); | 766 FilePath::StringType diff_installer_pattern = |
| 767 FILE_PATH_LITERAL("*_from_*"); |
| 768 FilePath::StringType mini_installer_pattern = |
| 769 FILE_PATH_LITERAL("mini_installer.exe"); |
| 802 FilePath root(mini_installer_constants::kChromeInstallersLocation); | 770 FilePath root(mini_installer_constants::kChromeInstallersLocation); |
| 803 std::vector<FilePath> paths; | 771 std::vector<FilePath> paths; |
| 804 if (!FindMatchingFiles(root, build, | 772 if (!FindMatchingFiles(root, build, |
| 805 file_util::FileEnumerator::DIRECTORIES, &paths)) { | 773 file_util::FileEnumerator::DIRECTORIES, &paths)) { |
| 806 return false; | 774 return false; |
| 807 } | 775 } |
| 808 | 776 |
| 809 // Find full and diff installers; | 777 // Find full and diff installers; |
| 810 std::vector<FilePath>::const_iterator dir; | 778 std::vector<FilePath>::const_iterator dir; |
| 811 for (dir = paths.begin(); dir != paths.end(); ++dir) { | 779 for (dir = paths.begin(); dir != paths.end(); ++dir) { |
| 812 FilePath windir = dir->Append( | 780 FilePath windir = dir->Append( |
| 813 mini_installer_constants::kWinFolder); | 781 mini_installer_constants::kWinFolder); |
| 814 if (FindNewestMatchingFile(windir, full_installer_pattern, | 782 if (FindNewestMatchingFile(windir, full_installer_pattern, |
| 815 file_util::FileEnumerator::FILES, &full_installer_) && | 783 file_util::FileEnumerator::FILES, &full_installer_) && |
| 816 FindNewestMatchingFile(windir, diff_installer_pattern, | 784 FindNewestMatchingFile(windir, diff_installer_pattern, |
| 817 file_util::FileEnumerator::FILES, &diff_installer_)) { | 785 file_util::FileEnumerator::FILES, &diff_installer_) && |
| 786 FindNewestMatchingFile(windir, mini_installer_pattern, |
| 787 file_util::FileEnumerator::FILES, &mini_installer_)) { |
| 818 break; | 788 break; |
| 819 } | 789 } |
| 820 } | 790 } |
| 821 | 791 |
| 822 // Set current build directory. | |
| 823 if (full_installer_.empty() || diff_installer_.empty()) | 792 if (full_installer_.empty() || diff_installer_.empty()) |
| 824 return false; | 793 return false; |
| 825 | 794 |
| 826 current_build_ = | 795 current_build_ = |
| 827 full_installer_.DirName().DirName().BaseName().value(); | 796 full_installer_.DirName().DirName().BaseName().value(); |
| 828 | 797 |
| 829 // Find previous full installer. | 798 // Find previous full installer. |
| 830 std::vector<std::wstring> tokenized_name; | 799 std::vector<std::wstring> tokenized_name; |
| 831 Tokenize(diff_installer_.BaseName().value(), | 800 Tokenize(diff_installer_.BaseName().value(), |
| 832 L"_", &tokenized_name); | 801 L"_", &tokenized_name); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 858 L"%ls%ls_%ls.exe", mini_installer_constants::kUntaggedInstallerPattern, | 827 L"%ls%ls_%ls.exe", mini_installer_constants::kUntaggedInstallerPattern, |
| 859 tokenizedBuildNumber[2].c_str(), tokenizedBuildNumber[3].c_str()); | 828 tokenizedBuildNumber[2].c_str(), tokenizedBuildNumber[3].c_str()); |
| 860 standalone_installer = standalone_installer.Append(current_build_) | 829 standalone_installer = standalone_installer.Append(current_build_) |
| 861 .Append(mini_installer_constants::kWinFolder) | 830 .Append(mini_installer_constants::kWinFolder) |
| 862 .Append(standalone_installer_filename); | 831 .Append(standalone_installer_filename); |
| 863 | 832 |
| 864 standalone_installer_ = standalone_installer; | 833 standalone_installer_ = standalone_installer; |
| 865 | 834 |
| 866 return !standalone_installer_.empty(); | 835 return !standalone_installer_.empty(); |
| 867 } | 836 } |
| OLD | NEW |