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

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: Adding ResolveShortcutProperties() to read thumbnails; requiring old target to matchs icon to for i… Created 7 years 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
« chrome/installer/util/shell_util.h ('K') | « chrome/installer/util/shell_util.h ('k') | no next file » | 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 4284e67f13f9fe4f51d6ef42acbc833b76c8a127..2ccc957bd3a9d77a8f28ce02251e5e66f0694e7b 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1271,6 +1271,25 @@ bool ShortcutOpUpdate(const base::win::ShortcutProperties& shortcut_properties,
return ret;
}
+bool ShortcutOpRetarget(const base::FilePath& old_target_path,
+ const base::FilePath& new_target_path,
+ const base::FilePath& shortcut_path) {
+ base::win::ShortcutProperties old_prop;
+ if (base::win::ResolveShortcutProperties(shortcut_path,
gab 2013/12/23 14:25:01 Wrap |shortcut_path| as well.
gab 2013/12/23 14:25:01 Unless you strongly oppose, I don't think we shoul
huangs 2013/12/30 20:15:10 Done, but |old_prop| now gets wrapped, too, so now
huangs 2013/12/30 20:15:10 Makes sense. Restructured code a bit.
+ base::win::ShortcutProperties::PROPERTIES_ICON, &old_prop)) {
gab 2013/12/23 14:25:01 Both the ShortcutFilter and this action will end u
huangs 2013/12/30 20:15:10 Yeah I felt a bit dirty about this. :) I think we
+ base::win::ShortcutProperties new_prop;
+ new_prop.set_target(new_target_path);
+ if (old_prop.icon == old_target_path)
gab 2013/12/23 14:25:01 tl;dr; use InstallUtil::ProgramCompare here. Stri
huangs 2013/12/30 20:15:10 Ah yes. Done.
+ new_prop.set_icon(new_target_path, old_prop.icon_index);
+ if (base::win::CreateOrUpdateShortcutLink(
+ shortcut_path, new_prop, base::win::SHORTCUT_UPDATE_EXISTING)) {
+ return true;
+ }
+ }
+ LOG(ERROR) << "Failed to retarget " << shortcut_path.value();
gab 2013/12/23 14:25:01 Rather than putting a generic ERROR at the bottom,
huangs 2013/12/30 20:15:10 There is only 1 error now, though I'm adding warni
+ return false;
+}
+
// {|location|, |dist|, |level|} determine |shortcut_folder|.
// For each shortcut in |shortcut_folder| that match |shortcut_filter|, apply
// |shortcut_operation|. Returns true if all operations are successful.
@@ -2107,6 +2126,23 @@ bool ShellUtil::UpdateShortcutsWithArgs(
shortcut_operation, location, dist, level);
}
+// static
+bool ShellUtil::RetargetShortcutsWithArgs(
+ ShellUtil::ShortcutLocation location,
+ BrowserDistribution* dist,
+ ShellChange level,
+ const base::FilePath& old_target_exe,
+ const base::FilePath& new_target_exe) {
+ if (!ShellUtil::ShortcutLocationIsSupported(location))
+ return true; // Vacuous success.
+
+ FilterTargetEq shortcut_filter(old_target_exe, true);
+ ShortcutOperationCallback shortcut_operation(
+ base::Bind(&ShortcutOpRetarget, old_target_exe, new_target_exe));
+ return BatchShortcutAction(shortcut_filter.AsShortcutFilterCallback(),
+ shortcut_operation, location, dist, level);
+}
+
bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) {
// Use a thread-safe cache for the user's suffix.
static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance =
« chrome/installer/util/shell_util.h ('K') | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698