summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 21:33:31 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 21:33:31 +0000
commit996c3471f625e1626ed1479b84d38fb50fa2dee6 (patch)
tree057d26150203cb4bea17aee578561d41ed48ca79
parent2b09f53f4ff7ded78bebbe9d6c9a307489071284 (diff)
downloadchromium_src-996c3471f625e1626ed1479b84d38fb50fa2dee6.zip
chromium_src-996c3471f625e1626ed1479b84d38fb50fa2dee6.tar.gz
chromium_src-996c3471f625e1626ed1479b84d38fb50fa2dee6.tar.bz2
Introduce RemoveChromeTaskbarShortcuts() to delete all pinned-to-taskbar shortcuts owned by the uninstalled Chrome.
TBR=brettw@chromium.org BUG=158632 TEST=No user-level shortcut Chrome left behind in taskbar post user-level self-destruct. Review URL: https://chromiumcodereview.appspot.com/11361015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165505 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base_paths_win.cc6
-rw-r--r--base/base_paths_win.h2
-rw-r--r--chrome/browser/shell_integration_win.cc4
-rw-r--r--chrome/installer/setup/uninstall.cc7
-rw-r--r--chrome/installer/util/shell_util.cc28
-rw-r--r--chrome/installer/util/shell_util.h7
6 files changed, 52 insertions, 2 deletions
diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc
index 58c3ea5..a06d908 100644
--- a/base/base_paths_win.cc
+++ b/base/base_paths_win.cc
@@ -192,6 +192,12 @@ bool PathProviderWin(int key, FilePath* result) {
if (!GetQuickLaunchPath(true, &cur))
return false;
break;
+ case base::DIR_TASKBAR_PINS:
+ if (!PathService::Get(base::DIR_USER_QUICK_LAUNCH, &cur))
+ return false;
+ cur = cur.AppendASCII("User Pinned");
+ cur = cur.AppendASCII("TaskBar");
+ break;
default:
return false;
}
diff --git a/base/base_paths_win.h b/base/base_paths_win.h
index 6cbcb2c..11bc111 100644
--- a/base/base_paths_win.h
+++ b/base/base_paths_win.h
@@ -40,6 +40,8 @@ enum {
DIR_USER_QUICK_LAUNCH, // Directory for the quick launch shortcuts.
DIR_DEFAULT_USER_QUICK_LAUNCH, // Directory for the quick launch shortcuts
// of the Default user.
+ DIR_TASKBAR_PINS, // Directory for the shortcuts pinned to taskbar via
+ // base::win::TaskbarPinShortcutLink().
PATH_WIN_END
};
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 874faaa..b5e7d56 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -209,8 +209,8 @@ void MigrateChromiumShortcutsCallback() {
const wchar_t* sub_dir;
} kLocations[] = {
{
- base::DIR_APP_DATA,
- L"Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar"
+ base::DIR_TASKBAR_PINS,
+ NULL
}, {
base::DIR_USER_DESKTOP,
NULL
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 2fb193b..5c6e6c5 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -307,6 +307,13 @@ void DeleteChromeShortcuts(const InstallerState& installer_state,
LOG(WARNING) << "Failed to delete Start Menu shortcuts.";
}
+ // Although the shortcut removal calls above will unpin their shortcut if they
+ // result in a deletion (i.e. shortcut existed and pointed to |chrome_exe|),
+ // it is possible for shortcuts to remain pinned while their parent shortcut
+ // has been deleted or changed to point to another |chrome_exe|. Make sure all
+ // pinned-to-taskbar shortcuts that point to |chrome_exe| are unpinned.
+ ShellUtil::RemoveChromeTaskbarShortcuts(chrome_exe);
+
ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(),
chrome_exe);
}
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 6891fcd..943a07d 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1847,6 +1847,34 @@ bool ShellUtil::RemoveChromeShortcut(
return true;
}
+void ShellUtil::RemoveChromeTaskbarShortcuts(const string16& chrome_exe) {
+ FilePath taskbar_pins_path;
+ if (!PathService::Get(base::DIR_TASKBAR_PINS, &taskbar_pins_path) ||
+ !file_util::PathExists(taskbar_pins_path)) {
+ LOG(ERROR) << "Couldn't find path to taskbar pins.";
+ return;
+ }
+
+ file_util::FileEnumerator shortcuts_enum(
+ taskbar_pins_path, false,
+ file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk"));
+
+ FilePath chrome_path(chrome_exe);
+ InstallUtil::ProgramCompare chrome_compare(chrome_path);
+ for (FilePath shortcut_path = shortcuts_enum.Next(); !shortcut_path.empty();
+ shortcut_path = shortcuts_enum.Next()) {
+ FilePath read_target;
+ if (!base::win::ResolveShortcut(shortcut_path, &read_target, NULL)) {
+ NOTREACHED();
+ continue;
+ }
+ if (chrome_compare.Evaluate(read_target.value())) {
+ // Unpin this shortcut if it points to |chrome_exe|.
+ base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str());
+ }
+ }
+}
+
void ShellUtil::RemoveChromeStartScreenShortcuts(BrowserDistribution* dist,
const string16& chrome_exe) {
if (base::win::GetVersion() < base::win::VERSION_WIN8)
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index 4e121c5..5a4786c 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -515,6 +515,13 @@ class ShellUtil {
ShellChange level,
const string16* shortcut_name);
+ // Enumerates all shortcuts pinned to the taskbar and deletes those pointing
+ // to |chrome_exe|.
+ // base::win::TaskbarUnpinShortcutLink() should be prefered, but this is
+ // useful on uninstall as the parent shortcut of a pin might no longer exist
+ // (thus making it impossible to unpin it via that API).
+ static void RemoveChromeTaskbarShortcuts(const string16& chrome_exe);
+
// This will remove all secondary tiles from the start screen for |dist|.
static void RemoveChromeStartScreenShortcuts(BrowserDistribution* dist,
const string16& chrome_exe);