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

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: brand new shell_util shortcut API + TESTS :)! 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 ShellUtil::ChromeShortcutProperties properties;
289 product.distribution(), 278 // The per-user shortcut for this user, if present on a system-level install,
290 ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL); 279 // has already been deleted in chrome_browser_main_win.cc::DoUninstallTasks().
291 } else { 280 properties.set_system_level(installer_state.system_install());
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, properties)) {
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 ShellUtil::ChromeShortcutProperties alternate_properties(properties);
308 shortcut_path = shortcut_path.Append(product_name); 291 alternate_properties.set_shortcut_name(dist->GetAlternateApplicationName());
292 if (!ShellUtil::RemoveChromeShortcut(
293 ShellUtil::SHORTCUT_DESKTOP, dist, alternate_properties)) {
294 LOG(WARNING) << "Failed to delete alternate Desktop shortcut.";
295 }
309 296
310 FilePath shortcut_link(shortcut_path.Append(product_name + L".lnk")); 297 VLOG(1) << "Deleting Quick Launch shortcut.";
298 if (!ShellUtil::RemoveChromeShortcut(
299 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, properties)) {
300 LOG(WARNING) << "Failed to delete Quick Launch shortcut.";
301 }
311 302
312 VLOG(1) << "Unpinning shortcut at " << shortcut_link.value() 303 VLOG(1) << "Deleting Start Menu shortcuts.";
313 << " from taskbar"; 304 if (!ShellUtil::RemoveChromeShortcut(
314 // Ignore return value: keep uninstalling if the unpin fails. 305 ShellUtil::SHORTCUT_START_MENU, dist, properties)) {
315 base::win::TaskbarUnpinShortcutLink(shortcut_link.value().c_str()); 306 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 } 307 }
321 308
322 ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(), 309 ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(),
323 chrome_exe); 310 chrome_exe);
324 } 311 }
325 312
326 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) { 313 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) {
327 FilePath parent_dir = path.DirName(); 314 FilePath parent_dir = path.DirName();
328 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str()); 315 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str());
329 if (!ret) { 316 if (!ret) {
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 1262
1276 // Try and delete the preserved local state once the post-install 1263 // Try and delete the preserved local state once the post-install
1277 // operations are complete. 1264 // operations are complete.
1278 if (!backup_state_file.empty()) 1265 if (!backup_state_file.empty())
1279 file_util::Delete(backup_state_file, false); 1266 file_util::Delete(backup_state_file, false);
1280 1267
1281 return ret; 1268 return ret;
1282 } 1269 }
1283 1270
1284 } // namespace installer 1271 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698