Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Side by Side Diff: chrome/installer/setup/uninstall.cc

Issue 164537: Renames the function CreateTemporaryFilename to CreateTemporaryFile and track... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: CommandLine fix Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 defines the methods useful for uninstalling Chrome. 5 // This file defines the methods useful for uninstalling Chrome.
6 6
7 #include "chrome/installer/setup/uninstall.h" 7 #include "chrome/installer/setup/uninstall.h"
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return false; // Nothing else we can do for uninstall, so we return. 151 return false; // Nothing else we can do for uninstall, so we return.
152 } else { 152 } else {
153 LOG(INFO) << "install destination path: " << install_path; 153 LOG(INFO) << "install destination path: " << install_path;
154 } 154 }
155 155
156 // Move setup.exe to the temp path. 156 // Move setup.exe to the temp path.
157 std::wstring setup_exe(installer::GetInstallerPathUnderChrome( 157 std::wstring setup_exe(installer::GetInstallerPathUnderChrome(
158 install_path, installed_version.GetString())); 158 install_path, installed_version.GetString()));
159 file_util::AppendToPath(&setup_exe, file_util::GetFilenameFromPath(exe_path)); 159 file_util::AppendToPath(&setup_exe, file_util::GetFilenameFromPath(exe_path));
160 160
161 std::wstring temp_file; 161 FilePath temp_file;
162 if (!file_util::CreateTemporaryFileName(&temp_file)) 162 if (!file_util::CreateTemporaryFile(&temp_file)) {
163 LOG(ERROR) << "Failed to create temporary file for setup.exe."; 163 LOG(ERROR) << "Failed to create temporary file for setup.exe.";
164 else 164 } else {
165 file_util::Move(setup_exe, temp_file); 165 FilePath setup_exe_path = FilePath::FromWStringHack(setup_exe);
166 file_util::Move(setup_exe_path, temp_file);
167 }
166 168
167 // Move the browser's persisted local state 169 // Move the browser's persisted local state
168 FilePath user_local_state; 170 FilePath user_local_state;
169 if (chrome::GetDefaultUserDataDirectory(&user_local_state)) { 171 if (chrome::GetDefaultUserDataDirectory(&user_local_state)) {
170 std::wstring user_local_file( 172 FilePath user_local_file(
171 user_local_state.Append(chrome::kLocalStateFilename).value()); 173 user_local_state.Append(chrome::kLocalStateFilename));
172 174
173 if (!file_util::CreateTemporaryFileName(local_state_path)) 175 FilePath path = FilePath::FromWStringHack(*local_state_path);
176 if (!file_util::CreateTemporaryFile(&path))
174 LOG(ERROR) << "Failed to create temporary file for Local State."; 177 LOG(ERROR) << "Failed to create temporary file for Local State.";
175 else 178 else
176 file_util::CopyFile(user_local_file, *local_state_path); 179 file_util::CopyFile(user_local_file, path);
177 } 180 }
178 181
179 LOG(INFO) << "Deleting install path " << install_path; 182 LOG(INFO) << "Deleting install path " << install_path;
180 if (!file_util::Delete(install_path, true)) { 183 if (!file_util::Delete(install_path, true)) {
181 LOG(ERROR) << "Failed to delete folder (1st try): " << install_path; 184 LOG(ERROR) << "Failed to delete folder (1st try): " << install_path;
182 // Try closing any running chrome processes and deleting files once again. 185 // Try closing any running chrome processes and deleting files once again.
183 CloseAllChromeProcesses(); 186 CloseAllChromeProcesses();
184 if (!file_util::Delete(install_path, true)) 187 if (!file_util::Delete(install_path, true))
185 LOG(ERROR) << "Failed to delete folder (2nd try): " << install_path; 188 LOG(ERROR) << "Failed to delete folder (2nd try): " << install_path;
186 } 189 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 std::wstring app_key(ShellUtil::kRegClasses); 313 std::wstring app_key(ShellUtil::kRegClasses);
311 file_util::AppendToPath(&app_key, L"Applications"); 314 file_util::AppendToPath(&app_key, L"Applications");
312 file_util::AppendToPath(&app_key, installer_util::kChromeExe); 315 file_util::AppendToPath(&app_key, installer_util::kChromeExe);
313 DeleteRegistryKey(key, app_key); 316 DeleteRegistryKey(key, app_key);
314 317
315 // Delete the App Paths key that lets explorer find Chrome. 318 // Delete the App Paths key that lets explorer find Chrome.
316 std::wstring app_path_key(ShellUtil::kAppPathsRegistryKey); 319 std::wstring app_path_key(ShellUtil::kAppPathsRegistryKey);
317 file_util::AppendToPath(&app_path_key, installer_util::kChromeExe); 320 file_util::AppendToPath(&app_path_key, installer_util::kChromeExe);
318 DeleteRegistryKey(key, app_path_key); 321 DeleteRegistryKey(key, app_path_key);
319 322
320 //Cleanup OpenWithList 323 // Cleanup OpenWithList
321 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 324 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
322 std::wstring open_with_key(ShellUtil::kRegClasses); 325 std::wstring open_with_key(ShellUtil::kRegClasses);
323 file_util::AppendToPath(&open_with_key, ShellUtil::kFileAssociations[i]); 326 file_util::AppendToPath(&open_with_key, ShellUtil::kFileAssociations[i]);
324 file_util::AppendToPath(&open_with_key, L"OpenWithList"); 327 file_util::AppendToPath(&open_with_key, L"OpenWithList");
325 file_util::AppendToPath(&open_with_key, installer_util::kChromeExe); 328 file_util::AppendToPath(&open_with_key, installer_util::kChromeExe);
326 DeleteRegistryKey(key, open_with_key); 329 DeleteRegistryKey(key, open_with_key);
327 } 330 }
328 331
329 key.Close(); 332 key.Close();
330 exit_code = installer_util::UNINSTALL_SUCCESSFUL; 333 exit_code = installer_util::UNINSTALL_SUCCESSFUL;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 distribution_data); 457 distribution_data);
455 } 458 }
456 459
457 // Try and delete the preserved local state once the post-install 460 // Try and delete the preserved local state once the post-install
458 // operations are complete. 461 // operations are complete.
459 if (!local_state_path.empty()) 462 if (!local_state_path.empty())
460 file_util::Delete(local_state_path, false); 463 file_util::Delete(local_state_path, false);
461 464
462 return ret; 465 return ret;
463 } 466 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_util_unittest.cc ('k') | chrome/installer/util/master_preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698