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

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: added menu_root to cleanup code 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 7f2eb148021f97297cf5ed24472266da6b5e75ea..9140da77251ec813eff9cebc5bddf974133b6694 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1576,7 +1576,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();
@@ -1661,7 +1662,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:
@@ -1695,7 +1696,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(
@@ -1730,6 +1731,36 @@ bool ShellUtil::GetShortcutPath(ShellUtil::ShortcutLocation location,
return true;
}
+bool ShellUtil::MoveExistingShortcut(
grt (UTC plus 2) 2015/10/20 18:10:30 formatting nit: bool ShellUtil::MoveExistingShortc
bcwhite 2015/10/20 18:25:43 Done.
+ ShortcutLocation old_location,
+ ShortcutLocation new_location,
+ BrowserDistribution* dist,
+ const 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(
gab 2015/10/20 18:25:59 const
+ ExtractShortcutNameFromProperties(dist, properties));
+
+ base::FilePath old_shortcut_path;
+ base::FilePath new_shortcut_path;
+ GetShortcutPath(
grt (UTC plus 2) 2015/10/20 18:10:30 nit: GetShortcutPath(old_location, dist, propert
bcwhite 2015/10/20 18:25:43 Done.
+ old_location, dist, properties.level, &old_shortcut_path);
+ GetShortcutPath(
+ new_location, dist, properties.level, &new_shortcut_path);
+ old_shortcut_path = old_shortcut_path.Append(shortcut_name);
+ new_shortcut_path = new_shortcut_path.Append(shortcut_name);
+
+ bool result = base::Move(old_shortcut_path, new_shortcut_path);
+
gab 2015/10/20 18:25:59 I'd say rm this empty line. (or otherwise add an
bcwhite 2015/10/20 19:03:12 Done.
+ RemoveShortcutFolderIfEmpty(old_location, dist, properties.level);
+ return result;
+}
+
bool ShellUtil::CreateOrUpdateShortcut(
ShellUtil::ShortcutLocation location,
gab 2015/10/20 18:25:59 Seems like you're cleaning up those extra namespac
bcwhite 2015/10/20 19:03:12 I was a little hesitant about that. Done.
BrowserDistribution* dist,
@@ -1739,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;
@@ -2400,7 +2431,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