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

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

Issue 1289333005: Change shortcut install location to non-subdir. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test improvements Created 5 years, 2 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.cc
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index a753f802a160ddf145e294d92f9ec2bf4aed136b..cd21044571a7bb435b7035f360e50c57f5686ca1 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1573,7 +1573,8 @@ bool RemoveShortcutFolderIfEmpty(ShellUtil::ShortcutLocation location,
BrowserDistribution* dist,
ShellUtil::ShellChange level) {
// Explicitly whitelist locations, since accidental calls can be very harmful.
- if (location != ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR &&
+ if (location !=
+ ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED &&
location != ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR &&
location != ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS) {
NOTREACHED();
@@ -1659,7 +1660,7 @@ bool ShellUtil::ShortcutLocationIsSupported(
case SHORTCUT_LOCATION_DESKTOP: // Falls through.
case SHORTCUT_LOCATION_QUICK_LAUNCH: // Falls through.
case SHORTCUT_LOCATION_START_MENU_ROOT: // Falls through.
- case SHORTCUT_LOCATION_START_MENU_CHROME_DIR: // Falls through.
+ case SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED: // Falls through.
case SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR:
return true;
case SHORTCUT_LOCATION_TASKBAR_PINS:
@@ -1693,7 +1694,7 @@ bool ShellUtil::GetShortcutPath(ShellUtil::ShortcutLocation location,
dir_key = (level == CURRENT_USER) ? base::DIR_START_MENU :
base::DIR_COMMON_START_MENU;
break;
- case SHORTCUT_LOCATION_START_MENU_CHROME_DIR:
+ case SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED:
dir_key = (level == CURRENT_USER) ? base::DIR_START_MENU :
base::DIR_COMMON_START_MENU;
folder_to_append = dist->GetStartMenuShortcutSubfolder(
@@ -1728,6 +1729,38 @@ bool ShellUtil::GetShortcutPath(ShellUtil::ShortcutLocation location,
return true;
}
+bool ShellUtil::MoveExistingShortcut(
+ ShellUtil::ShortcutLocation old_location,
grt (UTC plus 2) 2015/10/19 17:28:45 omit ShellUtil::
bcwhite 2015/10/20 16:02:13 Done.
+ ShellUtil::ShortcutLocation new_location,
+ BrowserDistribution* dist,
+ ShellUtil::ShellChange shortcut_level,
+ const ShellUtil::ShortcutProperties& properties) {
+ // Explicitly whitelist locations to which this is applicable.
+ if (old_location != SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED ||
+ new_location != SHORTCUT_LOCATION_START_MENU_ROOT) {
+ NOTREACHED();
+ return false;
+ }
+
+ base::string16 shortcut_name(
+ ExtractShortcutNameFromProperties(dist, properties));
+
+ base::FilePath old_shortcut_path;
+ base::FilePath new_shortcut_path;
+ ShellUtil::GetShortcutPath(
+ old_location, dist, shortcut_level, &old_shortcut_path);
+ ShellUtil::GetShortcutPath(
+ new_location, dist, shortcut_level, &new_shortcut_path);
+ old_shortcut_path = old_shortcut_path.Append(shortcut_name);
+ new_shortcut_path = new_shortcut_path.Append(shortcut_name);
+
+ bool result = !!::MoveFile(old_shortcut_path.value().c_str(),
grt (UTC plus 2) 2015/10/19 17:28:45 does base::Move (from base/files/file_util.h) work
bcwhite 2015/10/20 16:02:13 Done.
+ new_shortcut_path.value().c_str());
+
+ RemoveShortcutFolderIfEmpty(old_location, dist, shortcut_level);
+ return result;
+}
+
bool ShellUtil::CreateOrUpdateShortcut(
ShellUtil::ShortcutLocation location,
BrowserDistribution* dist,
@@ -1737,7 +1770,7 @@ bool ShellUtil::CreateOrUpdateShortcut(
if (location != SHORTCUT_LOCATION_DESKTOP &&
location != SHORTCUT_LOCATION_QUICK_LAUNCH &&
location != SHORTCUT_LOCATION_START_MENU_ROOT &&
- location != SHORTCUT_LOCATION_START_MENU_CHROME_DIR &&
+ location != SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED &&
location != SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR) {
NOTREACHED();
return false;
@@ -2406,7 +2439,7 @@ bool ShellUtil::RemoveShortcuts(ShellUtil::ShortcutLocation location,
NULL);
// Remove chrome-specific shortcut folders if they are now empty.
if (success &&
- (location == SHORTCUT_LOCATION_START_MENU_CHROME_DIR ||
+ (location == SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED ||
location == SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR ||
location == SHORTCUT_LOCATION_APP_SHORTCUTS)) {
success = RemoveShortcutFolderIfEmpty(location, dist, level);

Powered by Google App Engine
This is Rietveld 408576698