| 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 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
| 6 // file. | 6 // file. |
| 7 | 7 |
| 8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
| 9 | 9 |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
| 23 #include "chrome/common/json_value_serializer.h" | 23 #include "chrome/common/json_value_serializer.h" |
| 24 #include "chrome/installer/util/browser_distribution.h" | 24 #include "chrome/installer/util/browser_distribution.h" |
| 25 #include "chrome/installer/util/google_update_constants.h" | 25 #include "chrome/installer/util/google_update_constants.h" |
| 26 #include "chrome/installer/util/l10n_string_util.h" | 26 #include "chrome/installer/util/l10n_string_util.h" |
| 27 #include "chrome/installer/util/master_preferences_constants.h" | 27 #include "chrome/installer/util/master_preferences_constants.h" |
| 28 #include "chrome/installer/util/util_constants.h" | 28 #include "chrome/installer/util/util_constants.h" |
| 29 #include "chrome/installer/util/work_item_list.h" | 29 #include "chrome/installer/util/work_item_list.h" |
| 30 | 30 |
| 31 using base::win::RegKey; | 31 using base::win::RegKey; |
| 32 using installer_util::MasterPreferences; | 32 using installer::MasterPreferences; |
| 33 | 33 |
| 34 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { | 34 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { |
| 35 FilePath::StringType program(cmd.GetProgram().value()); | 35 FilePath::StringType program(cmd.GetProgram().value()); |
| 36 DCHECK(!program.empty()); | 36 DCHECK(!program.empty()); |
| 37 DCHECK(program[0] != '\"'); | 37 DCHECK(program[0] != '\"'); |
| 38 | 38 |
| 39 CommandLine::StringType params(cmd.command_line_string()); | 39 CommandLine::StringType params(cmd.command_line_string()); |
| 40 if (params[0] == '"') { | 40 if (params[0] == '"') { |
| 41 DCHECK_EQ('"', params[program.length() + 1]); | 41 DCHECK_EQ('"', params[program.length() + 1]); |
| 42 DCHECK_EQ(program, params.substr(1, program.length())); | 42 DCHECK_EQ(program, params.substr(1, program.length())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 67 *exit_code = ret_val; | 67 *exit_code = ret_val; |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install, | 71 std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install, |
| 72 BrowserDistribution* dist) { | 72 BrowserDistribution* dist) { |
| 73 DCHECK(dist); | 73 DCHECK(dist); |
| 74 HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 74 HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 75 RegKey key(root, dist->GetUninstallRegPath().c_str(), KEY_READ); | 75 RegKey key(root, dist->GetUninstallRegPath().c_str(), KEY_READ); |
| 76 std::wstring uninstall_cmd; | 76 std::wstring uninstall_cmd; |
| 77 key.ReadValue(installer_util::kUninstallStringField, &uninstall_cmd); | 77 key.ReadValue(installer::kUninstallStringField, &uninstall_cmd); |
| 78 return uninstall_cmd; | 78 return uninstall_cmd; |
| 79 } | 79 } |
| 80 | 80 |
| 81 installer::Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, | 81 installer::Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, |
| 82 bool system_install) { | 82 bool system_install) { |
| 83 DCHECK(dist); | 83 DCHECK(dist); |
| 84 RegKey key; | 84 RegKey key; |
| 85 std::wstring version_str; | 85 std::wstring version_str; |
| 86 | 86 |
| 87 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 87 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 114 SHGFP_TYPE_CURRENT, program_files_path))) { | 114 SHGFP_TYPE_CURRENT, program_files_path))) { |
| 115 return !StartsWith(exe_path, program_files_path, false); | 115 return !StartsWith(exe_path, program_files_path, false); |
| 116 } else { | 116 } else { |
| 117 NOTREACHED(); | 117 NOTREACHED(); |
| 118 } | 118 } |
| 119 return true; | 119 return true; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool InstallUtil::IsChromeFrameProcess() { | 122 bool InstallUtil::IsChromeFrameProcess() { |
| 123 const MasterPreferences& prefs = | 123 const MasterPreferences& prefs = |
| 124 installer_util::MasterPreferences::ForCurrentProcess(); | 124 installer::MasterPreferences::ForCurrentProcess(); |
| 125 return prefs.install_chrome_frame(); | 125 return prefs.install_chrome_frame(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool CheckIsChromeSxSProcess() { | 128 bool CheckIsChromeSxSProcess() { |
| 129 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 129 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 130 CHECK(command_line); | 130 CHECK(command_line); |
| 131 | 131 |
| 132 if (command_line->HasSwitch(installer_util::switches::kChromeSxS)) | 132 if (command_line->HasSwitch(installer::switches::kChromeSxS)) |
| 133 return true; | 133 return true; |
| 134 | 134 |
| 135 // Also return true if we are running from Chrome SxS installed path. | 135 // Also return true if we are running from Chrome SxS installed path. |
| 136 FilePath exe_dir; | 136 FilePath exe_dir; |
| 137 PathService::Get(base::DIR_EXE, &exe_dir); | 137 PathService::Get(base::DIR_EXE, &exe_dir); |
| 138 std::wstring chrome_sxs_dir(installer_util::kGoogleChromeInstallSubDir2); | 138 std::wstring chrome_sxs_dir(installer::kGoogleChromeInstallSubDir2); |
| 139 chrome_sxs_dir.append(installer_util::kSxSSuffix); | 139 chrome_sxs_dir.append(installer::kSxSSuffix); |
| 140 return FilePath::CompareEqualIgnoreCase(exe_dir.BaseName().value(), | 140 return FilePath::CompareEqualIgnoreCase(exe_dir.BaseName().value(), |
| 141 installer_util::kInstallBinaryDir) && | 141 installer::kInstallBinaryDir) && |
| 142 FilePath::CompareEqualIgnoreCase(exe_dir.DirName().BaseName().value(), | 142 FilePath::CompareEqualIgnoreCase(exe_dir.DirName().BaseName().value(), |
| 143 chrome_sxs_dir); | 143 chrome_sxs_dir); |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool InstallUtil::IsChromeSxSProcess() { | 146 bool InstallUtil::IsChromeSxSProcess() { |
| 147 static bool sxs = CheckIsChromeSxSProcess(); | 147 static bool sxs = CheckIsChromeSxSProcess(); |
| 148 return sxs; | 148 return sxs; |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path, | 151 bool InstallUtil::BuildDLLRegistrationList(const std::wstring& install_path, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 const std::wstring& value_name) { | 187 const std::wstring& value_name) { |
| 188 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS); | 188 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS); |
| 189 VLOG(1) << "Deleting registry value " << value_name; | 189 VLOG(1) << "Deleting registry value " << value_name; |
| 190 if (key.ValueExists(value_name.c_str()) && | 190 if (key.ValueExists(value_name.c_str()) && |
| 191 !key.DeleteValue(value_name.c_str())) { | 191 !key.DeleteValue(value_name.c_str())) { |
| 192 LOG(ERROR) << "Failed to delete registry value: " << value_name; | 192 LOG(ERROR) << "Failed to delete registry value: " << value_name; |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| 195 return true; | 195 return true; |
| 196 } | 196 } |
| OLD | NEW |