Chromium Code Reviews| 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 = |