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

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: fix some comments Created 8 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) 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // We try to remove the standard desktop shortcut but if that fails we try 249 // We try to remove the standard desktop shortcut but if that fails we try
250 // to remove the alternate desktop shortcut. Only one of them should be 250 // to remove the alternate desktop shortcut. Only one of them should be
251 // present in a given install but at this point we don't know which one. 251 // present in a given install but at this point we don't know which one.
252 void DeleteChromeShortcuts(const InstallerState& installer_state, 252 void DeleteChromeShortcuts(const InstallerState& installer_state,
253 const Product& product) { 253 const Product& product) {
254 if (!product.is_chrome()) { 254 if (!product.is_chrome()) {
255 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; 255 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution";
256 return; 256 return;
257 } 257 }
258 258
259 BrowserDistribution* dist = product.distribution();
260
261 uint32 options =
262 installer_state.system_install() ? ShellUtil::SHORTCUT_SYSTEM_LEVEL :
263 ShellUtil::SHORTCUT_NO_OPTIONS;
264
265 VLOG(1) << "Deleting Desktop shortcut.";
266 if (!ShellUtil::RemoveChromeShortcut(
267 ShellUtil::SHORTCUT_DESKTOP, dist, options) &&
268 !ShellUtil::RemoveChromeShortcut(
269 ShellUtil::SHORTCUT_DESKTOP, dist,
270 options | ShellUtil::SHORTCUT_ALTERNATE)) {
271 LOG(WARNING) << "Failed to delete Desktop shortcut.";
272 }
273
274 VLOG(1) << "Deleting Quick Launch shortcut.";
275 if (!ShellUtil::RemoveChromeShortcut(
276 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, options)) {
277 LOG(WARNING) << "Failed to delete Quick Launch shortcut.";
278 }
279
259 FilePath shortcut_path; 280 FilePath shortcut_path;
260 if (installer_state.system_install()) { 281 ShellUtil::GetShortcutPath(
261 PathService::Get(base::DIR_COMMON_START_MENU, &shortcut_path); 282 ShellUtil::SHORTCUT_START_MENU, installer_state.system_install(),
262 if (!ShellUtil::RemoveChromeDesktopShortcut( 283 &shortcut_path);
263 product.distribution(),
264 ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL,
265 ShellUtil::SHORTCUT_NO_OPTIONS)) {
266 ShellUtil::RemoveChromeDesktopShortcut(
267 product.distribution(),
268 ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL,
269 ShellUtil::SHORTCUT_ALTERNATE);
270 }
271 284
272 ShellUtil::RemoveChromeQuickLaunchShortcut(product.distribution(), 285 if (shortcut_path.empty()) {
273 ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL); 286 LOG(ERROR) << "Failed to get location for Start Menu shortcuts.";
274 } else { 287 } else {
275 PathService::Get(base::DIR_START_MENU, &shortcut_path); 288 const FilePath shortcut_link(
276 if (!ShellUtil::RemoveChromeDesktopShortcut(product.distribution(), 289 shortcut_path.Append(dist->GetAppShortCutName() + L".lnk"));
277 ShellUtil::CURRENT_USER, ShellUtil::SHORTCUT_NO_OPTIONS)) {
278 ShellUtil::RemoveChromeDesktopShortcut(product.distribution(),
279 ShellUtil::CURRENT_USER, ShellUtil::SHORTCUT_ALTERNATE);
280 }
281
282 ShellUtil::RemoveChromeQuickLaunchShortcut(product.distribution(),
283 ShellUtil::CURRENT_USER);
284 }
285 if (shortcut_path.empty()) {
286 LOG(ERROR) << "Failed to get location for shortcut.";
287 } else {
288 const string16 product_name(product.distribution()->GetAppShortCutName());
289 shortcut_path = shortcut_path.Append(product_name);
290
291 FilePath shortcut_link(shortcut_path.Append(product_name + L".lnk"));
292 290
293 VLOG(1) << "Unpinning shortcut at " << shortcut_link.value() 291 VLOG(1) << "Unpinning shortcut at " << shortcut_link.value()
294 << " from taskbar"; 292 << " from taskbar";
295 // Ignore return value: keep uninstalling if the unpin fails. 293 // Ignore return value: keep uninstalling if the unpin fails.
296 file_util::TaskbarUnpinShortcutLink(shortcut_link.value().c_str()); 294 file_util::TaskbarUnpinShortcutLink(shortcut_link.value().c_str());
297 295
298 VLOG(1) << "Deleting shortcut " << shortcut_path.value(); 296 VLOG(1) << "Deleting Start Menu shortcuts folder " << shortcut_path.value();
299 if (!file_util::Delete(shortcut_path, true)) 297 if (!file_util::Delete(shortcut_path, true))
300 LOG(ERROR) << "Failed to delete folder: " << shortcut_path.value(); 298 LOG(ERROR) << "Failed to delete folder: " << shortcut_path.value();
301 } 299 }
302 } 300 }
303 301
304 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) { 302 bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) {
305 FilePath parent_dir = path.DirName(); 303 FilePath parent_dir = path.DirName();
306 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str()); 304 bool ret = ScheduleFileSystemEntityForDeletion(parent_dir.value().c_str());
307 if (!ret) { 305 if (!ret) {
308 LOG(ERROR) << "Failed to schedule parent dir for deletion: " 306 LOG(ERROR) << "Failed to schedule parent dir for deletion: "
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1178
1181 // Try and delete the preserved local state once the post-install 1179 // Try and delete the preserved local state once the post-install
1182 // operations are complete. 1180 // operations are complete.
1183 if (!backup_state_file.empty()) 1181 if (!backup_state_file.empty())
1184 file_util::Delete(backup_state_file, false); 1182 file_util::Delete(backup_state_file, false);
1185 1183
1186 return ret; 1184 return ret;
1187 } 1185 }
1188 1186
1189 } // namespace installer 1187 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698