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

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

Issue 10836247: Refactor ShellUtil shortcut code -- single multi-purpose methods as opposed to many slighlty diffe… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: robert is the king of pool Created 8 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <windows.h> 9 #include <windows.h>
10 10
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // We remove all start screen secondary tiles by removing the folder Windows 265 // We remove all start screen secondary tiles by removing the folder Windows
266 // uses to store this installation's tiles. 266 // uses to store this installation's tiles.
267 void DeleteChromeShortcuts(const InstallerState& installer_state, 267 void DeleteChromeShortcuts(const InstallerState& installer_state,
268 const Product& product, 268 const Product& product,
269 const string16& chrome_exe) { 269 const string16& chrome_exe) {
270 if (!product.is_chrome()) { 270 if (!product.is_chrome()) {
271 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; 271 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution";
272 return; 272 return;
273 } 273 }
274 274
275 FilePath shortcut_path; 275 BrowserDistribution* dist = product.distribution();
276 if (installer_state.system_install()) {
277 PathService::Get(base::DIR_COMMON_START_MENU, &shortcut_path);
278 if (!ShellUtil::RemoveChromeDesktopShortcut(
279 product.distribution(),
280 ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL,
281 ShellUtil::SHORTCUT_NO_OPTIONS)) {
282 ShellUtil::RemoveChromeDesktopShortcut(
283 product.distribution(),
284 ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL,
285 ShellUtil::SHORTCUT_ALTERNATE);
286 }
287 276
288 ShellUtil::RemoveChromeQuickLaunchShortcut( 277 // The per-user shortcut for this user, if present on a system-level install,
289 product.distribution(), 278 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks().
290 ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL); 279 ShellUtil::ShellChange install_level = installer_state.system_install() ?
291 } else { 280 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER;
292 PathService::Get(base::DIR_START_MENU, &shortcut_path);
293 if (!ShellUtil::RemoveChromeDesktopShortcut(
294 product.distribution(),
295 ShellUtil::CURRENT_USER, ShellUtil::SHORTCUT_NO_OPTIONS)) {
296 ShellUtil::RemoveChromeDesktopShortcut(
297 product.distribution(),
298 ShellUtil::CURRENT_USER, ShellUtil::SHORTCUT_ALTERNATE);
299 }
300 281
301 ShellUtil::RemoveChromeQuickLaunchShortcut( 282 VLOG(1) << "Deleting Desktop shortcut.";
302 product.distribution(), ShellUtil::CURRENT_USER); 283 if (!ShellUtil::RemoveChromeShortcut(
284 ShellUtil::SHORTCUT_DESKTOP, dist, install_level, NULL)) {
285 LOG(WARNING) << "Failed to delete Desktop shortcut.";
303 } 286 }
304 if (shortcut_path.empty()) { 287 // Also try to delete the alternate desktop shortcut. It is not sufficient
305 LOG(ERROR) << "Failed to get location for shortcut."; 288 // to do so upon failure of the above call as ERROR_FILE_NOT_FOUND on
306 } else { 289 // delete is considered success.
307 const string16 product_name(product.distribution()->GetAppShortCutName()); 290 if (!ShellUtil::RemoveChromeShortcut(
308 shortcut_path = shortcut_path.Append(product_name); 291 ShellUtil::SHORTCUT_DESKTOP, dist, install_level,
292 &dist->GetAlternateApplicationName())) {
293 LOG(WARNING) << "Failed to delete alternate Desktop shortcut.";
294 }
309 295
310 FilePath shortcut_link(shortcut_path.Append(product_name + L".lnk")); 296 VLOG(1) << "Deleting Quick Launch shortcut.";
297 if (!ShellUtil::RemoveChromeShortcut(
298 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, install_level, NULL)) {
299 LOG(WARNING) << "Failed to delete Quick Launch shortcut.";
300 }
311 301
312 VLOG(1) << "Unpinning shortcut at " << shortcut_link.value() 302 VLOG(1) << "Deleting Start Menu shortcuts.";
313 << " from taskbar"; 303 if (!ShellUtil::RemoveChromeShortcut(
314 // Ignore return value: keep uninstalling if the unpin fails. 304 ShellUtil::SHORTCUT_START_MENU, dist, install_level, NULL)) {
315 base::win::TaskbarUnpinShortcutLink(shortcut_link.value().c_str()); 305 LOG(WARNING) << "Failed to delete Start Menu shortcuts.";
316
317 VLOG(1) << "Deleting shortcut " << shortcut_path.value();
318 if (!file_util::Delete(shortcut_path, true))
319 LOG(ERROR) << "Failed to delete folder: " << shortcut_path.value();
320 } 306 }
321 307
322 ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(), 308 ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(),
323 chrome_exe); 309 chrome_exe);
324 } 310 }
325 311
326 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) { 312 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) {
327 FilePath parent_dir = path.DirName(); 313 FilePath parent_dir = path.DirName();
328 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str()); 314 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str());
329 if (!ret) { 315 if (!ret) {
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 1261
1276 // Try and delete the preserved local state once the post-install 1262 // Try and delete the preserved local state once the post-install
1277 // operations are complete. 1263 // operations are complete.
1278 if (!backup_state_file.empty()) 1264 if (!backup_state_file.empty())
1279 file_util::Delete(backup_state_file, false); 1265 file_util::Delete(backup_state_file, false);
1280 1266
1281 return ret; 1267 return ret;
1282 } 1268 }
1283 1269
1284 } // namespace installer 1270 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698