Index: chrome/installer/util/shell_util.h |
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h |
index 1f8cab8a44145dc48d5829dcb370d29c3daea289..27a0785cf8ef1acb9e707a039ba361e92ce2e176 100644 |
--- a/chrome/installer/util/shell_util.h |
+++ b/chrome/installer/util/shell_util.h |
@@ -35,6 +35,31 @@ class ShellUtil { |
SYSTEM_LEVEL = 0x2 // Make any shell changes only at the system level |
}; |
+ enum ChromeShortcutOptions { |
+ SHORTCUT_NO_OPTIONS = 0, |
+ // Set DualMode property for Windows 8 Metro-enabled shortcuts. |
+ SHORTCUT_DUAL_MODE = 1 << 0, |
+ // Create a new shortcut (overwriting if necessary). |
+ SHORTCUT_CREATE_ALWAYS = 1 << 1, |
+ // Use an alternate application name for the shortcut (e.g. "The Internet"). |
+ // This option is only applied to the Desktop shortcut. |
+ SHORTCUT_ALTERNATE = 1 << 2, |
+ // Operate on the system-level variant of this shortcut (e.g. for Desktop |
+ // shortcut C:\Users\Public\Desktop). |
+ SHORTCUT_SYSTEM_LEVEL = 1 << 3, |
+ // Pin this shortcut to the Win7+ taskbar. This option is only applied if |
+ // SHORTCUT_CREATE_ALWAYS is also set and the shortcut is successfully |
+ // created. |
+ SHORTCUT_PIN_TO_TASKBAR = 1 << 4, |
+ }; |
+ |
+ enum ShortcutLocation { |
+ SHORTCUT_DESKTOP = 0, |
+ SHORTCUT_QUICK_LAUNCH, |
+ SHORTCUT_START_MENU, |
+ SHORTCUT_START_MENU_UNINSTALL, |
+ }; |
+ |
enum VerifyShortcutStatus { |
VERIFY_SHORTCUT_SUCCESS = 0, |
VERIFY_SHORTCUT_FAILURE_UNEXPECTED, |
@@ -142,43 +167,38 @@ class ShellUtil { |
const string16& chrome_exe, |
const string16& suffix); |
- // Creates Chrome shortcut on the Desktop. |
+ // Sets |path| to the path for a shortcut at the |location| desired at |
+ // |system_level| or not. |
+ static bool GetShortcutPath(ShellUtil::ShortcutLocation location, |
+ bool system_level, |
+ FilePath* path); |
+ |
+ // Updates Chrome shortcut in |location| (or creates it if |options| specify |
+ // SHORTCUT_CREATE_ALWAYS). |
// |dist| gives the type of browser distribution currently in use. |
- // |chrome_exe| provides the target path information. |
+ // |exe_path| provides the target path information. |
// |description| provides the shortcut's "comment" property. |
- // |appended_name| provides a string to be appended to the distribution name, |
+ // |appended_name| provides a string to be appended to the distribution name |
// and can be the empty string. |
// |arguments| gives a set of arguments to be passed to the executable. |
// |icon_path| provides the path to the icon file to use. |
// |icon_index| provides the index of the icon within the provided icon file. |
- // If |shell_change| is CURRENT_USER, the shortcut is created in the |
- // Desktop folder of current user's profile. |
- // If |shell_change| is SYSTEM_LEVEL, the shortcut is created in the |
- // Desktop folder of the "All Users" profile. |
+ // If |icon_path| is |exe_path| and |exe_path| points to chrome.exe: |
+ // |icon_index is overriden with the master preferences value. |
// |options|: bitfield for which the options come from ChromeShortcutOptions. |
+ // If SHORTCUT_CREATE_ALWAYS is not set in |options|, only specified (non- |
+ // empty) properties on an existing shortcut will be modified. If the shortcut |
+ // does not exist, this method is a no-op and returns false. |
// Returns true iff the method causes a shortcut to be created / updated. |
- static bool CreateChromeDesktopShortcut(BrowserDistribution* dist, |
- const string16& chrome_exe, |
- const string16& description, |
- const string16& appended_name, |
- const string16& arguments, |
- const string16& icon_path, |
- int icon_index, |
- ShellChange shell_change, |
- uint32 options); |
- |
- // Create Chrome shortcut on Quick Launch Bar. |
- // If shell_change is CURRENT_USER, the shortcut is created in the |
- // Quick Launch folder of current user's profile. |
- // If shell_change is SYSTEM_LEVEL, the shortcut is created in the |
- // Quick Launch folder of "Default User" profile. This will make sure |
- // that this shortcut will be seen by all the new users logging into the |
- // system. |
- // |options|: bitfield for which the options come from ChromeShortcutOptions. |
- static bool CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, |
- const string16& chrome_exe, |
- int shell_change, |
- uint32 options); |
+ static bool CreateOrUpdateChromeShortcut(ShortcutLocation location, |
+ BrowserDistribution* dist, |
+ const string16& chrome_exe, |
+ const string16& description, |
+ const string16& appended_name, |
robertshield
2012/08/22 21:39:07
almost all callers of this pass string16() as the
|
+ const string16& arguments, |
+ const string16& icon_path, |
+ int icon_index, |
+ uint32 options); |
// This method appends the Chrome icon index inside chrome.exe to the |
// chrome.exe path passed in as input, to generate the full path for |
@@ -198,27 +218,17 @@ class ShellUtil { |
// |chrome_exe|: the full path to chrome.exe |
static string16 GetChromeDelegateCommand(const string16& chrome_exe); |
- // Returns the localized name of Chrome shortcut in |shortcut|. If |
- // |appended_name| is not empty, it is included in the shortcut name. If |
+ // Sets |shortcut| to the localized name of the Chrome shortcut at |location|. |
+ // If |appended_name| is not empty, it is included in the shortcut name. If |
// |alternate| is true, a second localized text that is better suited for |
- // certain scenarios is used. |
- static bool GetChromeShortcutName(BrowserDistribution* dist, |
+ // certain scenarios is used (this only applies if |location| is |
+ // SHORTCUT_DESKTOP). |
+ static bool GetChromeShortcutName(ShellUtil::ShortcutLocation location, |
+ BrowserDistribution* dist, |
bool alternate, |
const string16& appended_name, |
string16* shortcut); |
- // Gets the desktop path for the current user or all users (if system_level |
- // is true) and returns it in 'path' argument. Return true if successful, |
- // otherwise returns false. |
- static bool GetDesktopPath(bool system_level, FilePath* path); |
- |
- // Gets the Quick Launch shortcuts path for the current user and |
- // returns it in 'path' argument. Return true if successful, otherwise |
- // returns false. If system_level is true this function returns the path |
- // to Default Users Quick Launch shortcuts path. Adding a shortcut to Default |
- // User's profile only affects any new user profiles (not existing ones). |
- static bool GetQuickLaunchPath(bool system_level, FilePath* path); |
- |
// Gets a mapping of all registered browser names (excluding browsers in the |
// |dist| distribution) and their reinstall command (which usually sets |
// browser as default). |
@@ -366,16 +376,14 @@ class ShellUtil { |
const string16& protocol, |
bool elevate_if_not_admin); |
- // Remove Chrome shortcut from Desktop. |
- // If |shell_change| is CURRENT_USER, the shortcut is removed from the |
- // Desktop folder of current user's profile. |
- // If |shell_change| is SYSTEM_LEVEL, the shortcut is removed from the |
- // Desktop folder of "All Users" profile. |
+ // Remove Chrome user-level shortcut from |location|. If SHORTCUT_SYSTEM_LEVEL |
+ // is specified in |options|, also remove the system-level shortcut for |
+ // |location|. |
// |options|: bitfield for which the options come from ChromeShortcutOptions. |
- // Only SHORTCUT_ALTERNATE is a valid option for this function. |
- static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, |
- int shell_change, |
- uint32 options); |
+ // Returns true if the specified shortcut is successfully deleted. |
+ static bool RemoveChromeShortcut(ShortcutLocation location, |
+ BrowserDistribution* dist, |
+ uint32 options); |
// Removes a set of existing Chrome desktop shortcuts. |appended_names| is a |
// list of shortcut file names as obtained from |
@@ -383,43 +391,6 @@ class ShellUtil { |
static bool RemoveChromeDesktopShortcutsWithAppendedNames( |
const std::vector<string16>& appended_names); |
- // Remove Chrome shortcut from Quick Launch Bar. |
- // If shell_change is CURRENT_USER, the shortcut is removed from |
- // the Quick Launch folder of current user's profile. |
- // If shell_change is SYSTEM_LEVEL, the shortcut is removed from |
- // the Quick Launch folder of "Default User" profile. |
- static bool RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist, |
- int shell_change); |
- |
- enum ChromeShortcutOptions { |
- SHORTCUT_NO_OPTIONS = 0, |
- // Set DualMode property for Windows 8 Metro-enabled shortcuts. |
- SHORTCUT_DUAL_MODE = 1 << 0, |
- // Create a new shortcut (overwriting if necessary). |
- SHORTCUT_CREATE_ALWAYS = 1 << 1, |
- // Use an alternate application name for the shortcut (e.g. "The Internet"). |
- // This option is only applied to the Desktop shortcut. |
- SHORTCUT_ALTERNATE = 1 << 2, |
- }; |
- |
- // Updates shortcut (or creates a new shortcut) at destination given by |
- // shortcut to a target given by chrome_exe. The arguments are given by |
- // |arguments| for the target and icon is set based on |icon_path| and |
- // |icon_index|. If create_new is set to true, the function will create a new |
- // shortcut if it doesn't exist. |
- // |options|: bitfield for which the options come from ChromeShortcutOptions. |
- // If SHORTCUT_CREATE_ALWAYS is not set in |options|, only specified (non- |
- // null) properties on an existing shortcut will be modified. If the shortcut |
- // does not exist, this method is a no-op and returns false. |
- static bool UpdateChromeShortcut(BrowserDistribution* dist, |
- const string16& chrome_exe, |
- const string16& shortcut, |
- const string16& arguments, |
- const string16& description, |
- const string16& icon_path, |
- int icon_index, |
- uint32 options); |
- |
// Verify that a shortcut exists with the expected information. |
// |exe_path| The shortcut's exe. |
// |shortcut| The path to the shortcut. |