| 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 // This file declares utility functions for the installer. The original reason | 5 // This file declares utility functions for the installer. The original reason |
| 6 // for putting these functions in installer\util library is so that we can | 6 // for putting these functions in installer\util library is so that we can |
| 7 // separate out the critical logic and write unit tests for it. | 7 // separate out the critical logic and write unit tests for it. |
| 8 | 8 |
| 9 #ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__ | 9 #ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__ |
| 10 #define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__ | 10 #define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__ |
| 11 #pragma once | 11 #pragma once |
| 12 | 12 |
| 13 #include <tchar.h> | 13 #include <tchar.h> |
| 14 #include <windows.h> | 14 #include <windows.h> |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/command_line.h" |
| 19 #include "chrome/installer/util/browser_distribution.h" |
| 18 #include "chrome/installer/util/util_constants.h" | 20 #include "chrome/installer/util/util_constants.h" |
| 19 | 21 |
| 20 class BrowserDistribution; | |
| 21 class CommandLine; | |
| 22 class Version; | 22 class Version; |
| 23 class WorkItemList; | 23 class WorkItemList; |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 namespace win { | 26 namespace win { |
| 27 class RegKey; | 27 class RegKey; |
| 28 } // namespace win | 28 } // namespace win |
| 29 } // namespace base | 29 } // namespace base |
| 30 | 30 |
| 31 // This is a utility class that provides common installation related | 31 // This is a utility class that provides common installation related |
| 32 // utility methods that can be used by installer and also unit tested | 32 // utility methods that can be used by installer and also unit tested |
| 33 // independently. | 33 // independently. |
| 34 class InstallUtil { | 34 class InstallUtil { |
| 35 public: | 35 public: |
| 36 // Launches given exe as admin on Vista. | 36 // Launches given exe as admin on Vista. |
| 37 static bool ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code); | 37 static bool ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code); |
| 38 | 38 |
| 39 // Reads the uninstall command for Chromium from registry and returns it. | 39 // Reads the uninstall command for Chromium from registry and returns it. |
| 40 // If system_install is true the command is read from HKLM, otherwise | 40 // If system_install is true the command is read from HKLM, otherwise |
| 41 // from HKCU. | 41 // from HKCU. |
| 42 static std::wstring GetChromeUninstallCmd(bool system_install, | 42 static CommandLine GetChromeUninstallCmd( |
| 43 BrowserDistribution* dist); | 43 bool system_install, |
| 44 BrowserDistribution::Type distribution_type); |
| 44 | 45 |
| 45 // Find the version of Chrome installed on the system by checking the | 46 // Find the version of Chrome installed on the system by checking the |
| 46 // Google Update registry key. Returns the version or NULL if no version is | 47 // Google Update registry key. Returns the version or NULL if no version is |
| 47 // found. | 48 // found. |
| 48 // system_install: if true, looks for version number under the HKLM root, | 49 // system_install: if true, looks for version number under the HKLM root, |
| 49 // otherwise looks under the HKCU. | 50 // otherwise looks under the HKCU. |
| 50 static Version* GetChromeVersion(BrowserDistribution* dist, | 51 static Version* GetChromeVersion(BrowserDistribution* dist, |
| 51 bool system_install); | 52 bool system_install); |
| 52 | 53 |
| 53 // This function checks if the current OS is supported for Chromium. | 54 // This function checks if the current OS is supported for Chromium. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 static void MakeUninstallCommand(const std::wstring& exe_path, | 111 static void MakeUninstallCommand(const std::wstring& exe_path, |
| 111 const std::wstring& arguments, | 112 const std::wstring& arguments, |
| 112 CommandLine* command_line); | 113 CommandLine* command_line); |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 DISALLOW_COPY_AND_ASSIGN(InstallUtil); | 116 DISALLOW_COPY_AND_ASSIGN(InstallUtil); |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 | 119 |
| 119 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__ | 120 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H__ |
| OLD | NEW |