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

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

Issue 108193019: Installer: adding ResolveShortcutProperties(); updating shortcut icons during shortcut migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Using ValidatePathsAreEqual() to fix tests; removing test code. Created 6 years, 11 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
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/shell_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/shell_util.cc
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index a2c55af66a05a4a630127ff95e958a50522c2bae..f5e38515bc4ec5e63bfcd6d7521c940b1b129704 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1267,12 +1267,29 @@ bool ShortcutOpDelete(const base::FilePath& shortcut_path) {
return ret;
}
-bool ShortcutOpUpdate(const base::win::ShortcutProperties& shortcut_properties,
- const base::FilePath& shortcut_path) {
- bool ret = base::win::CreateOrUpdateShortcutLink(
- shortcut_path, shortcut_properties, base::win::SHORTCUT_UPDATE_EXISTING);
- LOG_IF(ERROR, !ret) << "Failed to update " << shortcut_path.value();
- return ret;
+bool ShortcutOpRetarget(const base::FilePath& old_target,
+ const base::FilePath& new_target,
+ const base::FilePath& shortcut_path) {
+ base::win::ShortcutProperties new_prop;
+ new_prop.set_target(new_target);
+
+ // If the old icon matches old target, then update icon while keeping the old
+ // icon index. Non-fatal if we fail to get the old icon.
+ base::win::ShortcutProperties old_prop;
+ if (base::win::ResolveShortcutProperties(
+ shortcut_path,
+ base::win::ShortcutProperties::PROPERTIES_ICON,
+ &old_prop)) {
+ if (InstallUtil::ProgramCompare(old_target).EvaluatePath(old_prop.icon))
+ new_prop.set_icon(new_target, old_prop.icon_index);
+ } else {
+ LOG(ERROR) << "Failed to resolve " << shortcut_path.value();
+ }
+
+ bool result = base::win::CreateOrUpdateShortcutLink(
+ shortcut_path, new_prop, base::win::SHORTCUT_UPDATE_EXISTING);
+ LOG_IF(ERROR, !result) << "Failed to retarget " << shortcut_path.value();
+ return result;
}
// {|location|, |dist|, |level|} determine |shortcut_folder|.
@@ -2104,18 +2121,18 @@ bool ShellUtil::RemoveShortcuts(ShellUtil::ShortcutLocation location,
}
// static
-bool ShellUtil::UpdateShortcutsWithArgs(
+bool ShellUtil::RetargetShortcutsWithArgs(
ShellUtil::ShortcutLocation location,
BrowserDistribution* dist,
ShellChange level,
- const base::FilePath& target_exe,
- const ShellUtil::ShortcutProperties& properties) {
+ const base::FilePath& old_target_exe,
+ const base::FilePath& new_target_exe) {
if (!ShellUtil::ShortcutLocationIsSupported(location))
return true; // Vacuous success.
- FilterTargetEq shortcut_filter(target_exe, true);
+ FilterTargetEq shortcut_filter(old_target_exe, true);
ShortcutOperationCallback shortcut_operation(
- base::Bind(&ShortcutOpUpdate, TranslateShortcutProperties(properties)));
+ base::Bind(&ShortcutOpRetarget, old_target_exe, new_target_exe));
return BatchShortcutAction(shortcut_filter.AsShortcutFilterCallback(),
shortcut_operation, location, dist, level);
}
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/shell_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698