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

Unified Diff: chrome/installer/util/shell_util.h

Issue 14287008: Refactoring installer shortcut deletion; adding dedicated shortcut update feature. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Generaling 'Retarget' to 'Update' via base::win::ShortcutProperties. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/util/shell_util.h
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index bfdb9b953ecfeec05bd2c918e40e8096246a7b16..e970e3a0c22dffbc4510f1bd2b993f4cff2b64be 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -22,6 +22,12 @@
class BrowserDistribution;
+namespace base {
+ namespace win {
+ struct ShortcutProperties;
+ } // namespace win
+} // namespace base
+
// This is a utility class that provides common shell integration methods
// that can be used by installer as well as Chrome.
class ShellUtil {
@@ -40,10 +46,13 @@ class ShellUtil {
};
// Typical shortcut directories. Resolved in GetShortcutPath().
+ // Also used in ShortcutLocationIsSupported().
enum ShortcutLocation {
SHORTCUT_LOCATION_DESKTOP,
SHORTCUT_LOCATION_QUICK_LAUNCH,
SHORTCUT_LOCATION_START_MENU,
+ SHORTCUT_LOCATION_TASKBAR_PINS, // base::win::VERSION_WIN7 +
+ SHORTCUT_LOCATION_APP_SHORTCUTS, // base::win::VERSION_WIN8 +
};
enum ShortcutOperation {
@@ -294,6 +303,10 @@ class ShellUtil {
const string16& chrome_exe,
const string16& suffix);
+ // Returns true if the current Windows version supports the presence of
+ // shortcuts at |location|.
+ static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location);
+
// Sets |path| to the path for a shortcut at the |location| desired for the
// given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
// all-users path).
@@ -308,6 +321,8 @@ class ShellUtil {
// |dist| gives the type of browser distribution currently in use.
// |properties| and |operation| affect this method as described on their
// invidividual definitions above.
+ // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
+ // SHORTCUT_LOCATION_QUICK_LAUNCH, or SHORTCUT_LOCATION_START_MENU.
static bool CreateOrUpdateShortcut(
ShellUtil::ShortcutLocation location,
BrowserDistribution* dist,
@@ -498,33 +513,30 @@ class ShellUtil {
bool elevate_if_not_admin);
// Removes installed shortcut(s) at |location|.
+ // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
+ // remove all-users shortcuts.
// |target_exe|: Shortcut target exe; shortcuts will only be deleted when
// their target is |target_exe|.
- // |level|: CURRENT_USER to remove the per-user shortcut and SYSTEM_LEVEL to
- // remove the all-users shortcut.
- // |shortcut_name|: If non-null, remove the shortcut named |shortcut_name| at
- // location; otherwise remove all shortcuts to |target_exe| at |location|.
// If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific
// to |dist| is deleted.
// Also attempts to unpin the removed shortcut(s) from the taskbar.
gab 2013/05/02 19:20:50 This part is no longer true.
huangs 2013/05/02 20:48:02 Deleted.
- // Returns true if the shortcut(s) were successfully deleted (or there were
- // none at |location| pointing to |target_exe|).
- static bool RemoveShortcut(ShellUtil::ShortcutLocation location,
- BrowserDistribution* dist,
- const base::FilePath& target_exe,
- ShellChange level,
- const string16* shortcut_name);
-
- // Enumerates all shortcuts pinned to the taskbar and deletes those pointing
- // to |target_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 RemoveTaskbarShortcuts(const string16& target_exe);
-
- // This will remove all secondary tiles from the start screen for |dist|.
- static void RemoveStartScreenShortcuts(BrowserDistribution* dist,
- const string16& target_exe);
+ // Returns true if all shortcuts are successfully deleted, including the
+ // vacuous case no shortcuts are found.
gab 2013/05/02 19:20:50 // Returns true if all shortcuts pointing to |targ
huangs 2013/05/02 20:48:02 Done.
+ static bool RemoveShortcuts(ShellUtil::ShortcutLocation location,
+ BrowserDistribution* dist,
+ ShellChange level,
+ const base::FilePath& target_exe);
+
+ // Iterates over all shortcuts at |location| that targets |target_exe|,
+ // and applies update via |shortcut_properties|.
+ // Returns true if all shortcuts are successfully updated, including the
+ // vacuous case no shortcuts are found.
gab 2013/05/02 19:20:50 I'd suggest: // Returns true if all shortcuts poin
huangs 2013/05/02 20:48:02 Done.
+ static bool UpdateShortcuts(
+ ShellUtil::ShortcutLocation location,
+ BrowserDistribution* dist,
+ ShellChange level,
+ const base::FilePath& target_exe,
+ const base::win::ShortcutProperties& shortcut_properties);
gab 2013/05/02 19:20:50 Use a ShellUtil::ShortcutProperties and use Transl
huangs 2013/05/02 20:48:02 Done. Doing translation only once in UpdateShortc
gab 2013/05/02 21:23:59 Indeed :)!
// Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
// preceded by a dot.

Powered by Google App Engine
This is Rietveld 408576698