summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-30 09:16:55 +0000
committerbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-30 09:16:55 +0000
commitb2721b0739bae858df9758e0c2046b267c8e7112 (patch)
tree7741e204bbb40a20570a8276d9823b2bc121c137
parent35601c5500d4e69dfdcefb091cb72a8f55cb8b98 (diff)
downloadchromium_src-b2721b0739bae858df9758e0c2046b267c8e7112.zip
chromium_src-b2721b0739bae858df9758e0c2046b267c8e7112.tar.gz
chromium_src-b2721b0739bae858df9758e0c2046b267c8e7112.tar.bz2
Delete Chrome's secondary tiles on Windows 8 when uninstalling.
The Windows secondary tiles deletion functions are only available to Chrome itself when running in metro mode. To get around this, the folder containing the installation's secondarty tiles is removed entirely. BUG=140559 Review URL: https://chromiumcodereview.appspot.com/10876057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154103 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base_paths_win.cc13
-rw-r--r--base/base_paths_win.h4
-rw-r--r--base/path_service_unittest.cc30
-rw-r--r--chrome/installer/setup/uninstall.cc10
-rw-r--r--chrome/installer/util/shell_util.cc27
-rw-r--r--chrome/installer/util/shell_util.h4
6 files changed, 76 insertions, 12 deletions
diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc
index 0b24833..48238a4 100644
--- a/base/base_paths_win.cc
+++ b/base/base_paths_win.cc
@@ -10,6 +10,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/win/scoped_co_mem.h"
#include "base/win/windows_version.h"
// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
@@ -125,6 +126,18 @@ bool PathProviderWin(int key, FilePath* result) {
cur = executableDir.DirName().DirName();
break;
}
+ case base::DIR_APP_SHORTCUTS: {
+ if (win::GetVersion() < win::VERSION_WIN8)
+ return false;
+
+ base::win::ScopedCoMem<wchar_t> path_buf;
+ if (FAILED(SHGetKnownFolderPath(FOLDERID_ApplicationShortcuts, 0, NULL,
+ &path_buf)))
+ return false;
+
+ cur = FilePath(string16(path_buf));
+ break;
+ }
default:
return false;
}
diff --git a/base/base_paths_win.h b/base/base_paths_win.h
index 0f1a5a5..707a6a6 100644
--- a/base/base_paths_win.h
+++ b/base/base_paths_win.h
@@ -32,7 +32,9 @@ enum {
DIR_COMMON_APP_DATA, // W2K, XP, W2K3: "C:\Documents and Settings\
// All Users\Application Data".
// Vista, W2K8 and above: "C:\ProgramData".
-
+ DIR_APP_SHORTCUTS, // Where tiles on the start screen are stored, only
+ // for Windows 8. Maps to "Local\AppData\Microsoft\
+ // Windows\Application Shortcuts\".
PATH_WIN_END
};
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index 294f8d8..81d1fef 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -32,10 +32,12 @@ bool ReturnsValidPath(int dir_type) {
}
#if defined(OS_WIN)
-// Function to test DIR_LOCAL_APP_DATA_LOW on Windows XP. Make sure it fails.
+// Function to test any directory keys that are not supported on some versions
+// of Windows. Checks that the function fails and that the returned path is
+// empty.
bool ReturnsInvalidPath(int dir_type) {
FilePath path;
- bool result = PathService::Get(base::DIR_LOCAL_APP_DATA_LOW, &path);
+ bool result = PathService::Get(dir_type, &path);
return !result && path.empty();
}
#endif
@@ -60,14 +62,24 @@ TEST_F(PathServiceTest, Get) {
}
#if defined(OS_WIN)
for (int key = base::PATH_WIN_START + 1; key < base::PATH_WIN_END; ++key) {
- if (key == base::DIR_LOCAL_APP_DATA_LOW &&
- base::win::GetVersion() < base::win::VERSION_VISTA) {
- // DIR_LOCAL_APP_DATA_LOW is not supported prior Vista and is expected to
- // fail.
- EXPECT_TRUE(ReturnsInvalidPath(key)) << key;
- } else {
- EXPECT_TRUE(ReturnsValidPath(key)) << key;
+ bool valid = true;
+ switch(key) {
+ case base::DIR_LOCAL_APP_DATA_LOW:
+ // DIR_LOCAL_APP_DATA_LOW is not supported prior Vista and is expected
+ // to fail.
+ valid = base::win::GetVersion() >= base::win::VERSION_VISTA;
+ break;
+ case base::DIR_APP_SHORTCUTS:
+ // DIR_APP_SHORTCUTS is not supported prior Windows 8 and is expected to
+ // fail.
+ valid = base::win::GetVersion() >= base::win::VERSION_WIN8;
+ break;
}
+
+ if (valid)
+ EXPECT_TRUE(ReturnsValidPath(key)) << key;
+ else
+ EXPECT_TRUE(ReturnsInvalidPath(key)) << key;
}
#elif defined(OS_MACOSX)
for (int key = base::PATH_MAC_START + 1; key < base::PATH_MAC_END; ++key) {
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 3e34d57..ac64258 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -249,8 +249,11 @@ void CloseChromeFrameHelperProcess() {
// We try to remove the standard desktop shortcut but if that fails we try
// to remove the alternate desktop shortcut. Only one of them should be
// present in a given install but at this point we don't know which one.
+// We remove all start screen secondary tiles by removing the folder Windows
+// uses to store this installation's tiles.
void DeleteChromeShortcuts(const InstallerState& installer_state,
- const Product& product) {
+ const Product& product,
+ const string16& chrome_exe) {
if (!product.is_chrome()) {
VLOG(1) << __FUNCTION__ " called for non-CHROME distribution";
return;
@@ -299,6 +302,9 @@ void DeleteChromeShortcuts(const InstallerState& installer_state,
if (!file_util::Delete(shortcut_path, true))
LOG(ERROR) << "Failed to delete folder: " << shortcut_path.value();
}
+
+ ShellUtil::RemoveChromeStartScreenShortcuts(product.distribution(),
+ chrome_exe);
}
bool ScheduleParentAndGrandparentForDeletion(const FilePath& path) {
@@ -984,7 +990,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
ASCIIToUTF16(chrome::kInitialProfile));
// First delete shortcuts from Start->Programs, Desktop & Quick Launch.
- DeleteChromeShortcuts(installer_state, product);
+ DeleteChromeShortcuts(installer_state, product, chrome_exe);
}
// Delete the registry keys (Uninstall key and Version key).
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 37ed8c2..69fd7aa 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1626,6 +1626,33 @@ bool ShellUtil::RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist,
return ret;
}
+void ShellUtil::RemoveChromeStartScreenShortcuts(BrowserDistribution* dist,
+ const string16& chrome_exe) {
+ if (base::win::GetVersion() < base::win::VERSION_WIN8)
+ return;
+
+ FilePath app_shortcuts_path;
+ if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) {
+ LOG(ERROR) << "Could not get application shortcuts location to delete"
+ << " start screen shortcuts.";
+ return;
+ }
+
+ app_shortcuts_path = app_shortcuts_path.Append(
+ GetBrowserModelId(dist, chrome_exe));
+ if (!file_util::DirectoryExists(app_shortcuts_path)) {
+ VLOG(1) << "No start screen shortcuts to delete.";
+ return;
+ }
+
+ VLOG(1) << "Removing start screen shortcuts from "
+ << app_shortcuts_path.value();
+ if (!file_util::Delete(app_shortcuts_path, true)) {
+ LOG(ERROR) << "Failed to remove start screen shortcuts from "
+ << app_shortcuts_path.value();
+ }
+}
+
bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist,
const string16& chrome_exe,
const string16& shortcut,
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index 1f8cab8..bc3bf8a 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -391,6 +391,10 @@ class ShellUtil {
static bool RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist,
int shell_change);
+ // This will remove all secondary tiles from the start screen for |dist|.
+ static void RemoveChromeStartScreenShortcuts(BrowserDistribution* dist,
+ const string16& chrome_exe);
+
enum ChromeShortcutOptions {
SHORTCUT_NO_OPTIONS = 0,
// Set DualMode property for Windows 8 Metro-enabled shortcuts.