OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cloud_print/common/win/install_utils.h" | 5 #include "cloud_print/common/win/install_utils.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_version_info_win.h" | 10 #include "base/file_version_info_win.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (key.Create(HKEY_LOCAL_MACHINE, | 137 if (key.Create(HKEY_LOCAL_MACHINE, |
138 (cloud_print::kUninstallKey + uninstall_id).c_str(), | 138 (cloud_print::kUninstallKey + uninstall_id).c_str(), |
139 KEY_SET_VALUE) != ERROR_SUCCESS) { | 139 KEY_SET_VALUE) != ERROR_SUCCESS) { |
140 LOG(ERROR) << "Unable to open key"; | 140 LOG(ERROR) << "Unable to open key"; |
141 return; | 141 return; |
142 } | 142 } |
143 | 143 |
144 base::FilePath unstall_binary; | 144 base::FilePath unstall_binary; |
145 CHECK(PathService::Get(base::FILE_EXE, &unstall_binary)); | 145 CHECK(PathService::Get(base::FILE_EXE, &unstall_binary)); |
146 | 146 |
147 CommandLine uninstall_command(unstall_binary); | 147 base::CommandLine uninstall_command(unstall_binary); |
148 uninstall_command.AppendSwitch(uninstall_switch); | 148 uninstall_command.AppendSwitch(uninstall_switch); |
149 key.WriteValue(kUninstallString, | 149 key.WriteValue(kUninstallString, |
150 uninstall_command.GetCommandLineString().c_str()); | 150 uninstall_command.GetCommandLineString().c_str()); |
151 key.WriteValue(kInstallLocation, | 151 key.WriteValue(kInstallLocation, |
152 unstall_binary.DirName().value().c_str()); | 152 unstall_binary.DirName().value().c_str()); |
153 | 153 |
154 // Get the version resource. | 154 // Get the version resource. |
155 scoped_ptr<FileVersionInfo> version_info( | 155 scoped_ptr<FileVersionInfo> version_info( |
156 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 156 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
157 | 157 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (!PathService::Get(base::FILE_EXE, &installer_source)) | 193 if (!PathService::Get(base::FILE_EXE, &installer_source)) |
194 return; | 194 return; |
195 // Deletes only subdirs of program files. | 195 // Deletes only subdirs of program files. |
196 if (!IsProgramsFilesParent(installer_source)) | 196 if (!IsProgramsFilesParent(installer_source)) |
197 return; | 197 return; |
198 base::FilePath temp_path; | 198 base::FilePath temp_path; |
199 if (!base::CreateTemporaryFile(&temp_path)) | 199 if (!base::CreateTemporaryFile(&temp_path)) |
200 return; | 200 return; |
201 base::CopyFile(installer_source, temp_path); | 201 base::CopyFile(installer_source, temp_path); |
202 base::DeleteFileAfterReboot(temp_path); | 202 base::DeleteFileAfterReboot(temp_path); |
203 CommandLine command_line(temp_path); | 203 base::CommandLine command_line(temp_path); |
204 command_line.AppendSwitchPath(delete_switch, installer_source.DirName()); | 204 command_line.AppendSwitchPath(delete_switch, installer_source.DirName()); |
205 base::LaunchOptions options; | 205 base::LaunchOptions options; |
206 base::ProcessHandle process_handle; | 206 base::ProcessHandle process_handle; |
207 if (!base::LaunchProcess(command_line, options, &process_handle)) { | 207 if (!base::LaunchProcess(command_line, options, &process_handle)) { |
208 LOG(ERROR) << "Unable to launch child uninstall."; | 208 LOG(ERROR) << "Unable to launch child uninstall."; |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 bool IsProgramsFilesParent(const base::FilePath& path) { | 212 bool IsProgramsFilesParent(const base::FilePath& path) { |
213 base::FilePath program_files; | 213 base::FilePath program_files; |
214 if (!PathService::Get(base::DIR_PROGRAM_FILESX86, &program_files)) | 214 if (!PathService::Get(base::DIR_PROGRAM_FILESX86, &program_files)) |
215 return false; | 215 return false; |
216 return program_files.IsParent(path); | 216 return program_files.IsParent(path); |
217 } | 217 } |
218 | 218 |
219 } // namespace cloud_print | 219 } // namespace cloud_print |
220 | 220 |
OLD | NEW |