Index: chrome/installer/util/shell_util.cc |
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc |
index 273c7f0324170eda2e0fbd7b474fd1c4ac6dc724..af18176cba976d853c544bc50c9b8259ec5dc460 100644 |
--- a/chrome/installer/util/shell_util.cc |
+++ b/chrome/installer/util/shell_util.cc |
@@ -1207,21 +1207,23 @@ bool ShortcutOpDelete(const base::FilePath& shortcut_path) { |
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_REPLACE_EXISTING); |
+ shortcut_path, shortcut_properties, base::win::SHORTCUT_UPDATE_EXISTING); |
LOG_IF(ERROR, !ret) << "Failed to update " << shortcut_path.value(); |
return ret; |
} |
// {|location|, |dist|, |level|} determine |shortcut_folder|. |
-// Applies |shortcut_operation| to each shortcut in |shortcut_folder| that |
-// targets |target_exe|. |
+// Applies |shortcut_operation| to shortcuts in |shortcut_folder| that |
+// targets |target_exe|, and have filenames matching |filename_filter|. |
// Returns true if all operations are successful. All intended operations are |
// attempted even if failures occur. |
-bool BatchShortcutAction(const FileOperationCallback& shortcut_operation, |
- ShellUtil::ShortcutLocation location, |
- BrowserDistribution* dist, |
- ShellUtil::ShellChange level, |
- const base::FilePath& target_exe) { |
+bool BatchShortcutActionFilteredByName( |
+ const FileOperationCallback& shortcut_operation, |
+ ShellUtil::ShortcutLocation location, |
+ BrowserDistribution* dist, |
+ ShellUtil::ShellChange level, |
+ const base::FilePath& target_exe, |
+ const string16& filename_filter) { |
DCHECK(!shortcut_operation.is_null()); |
base::FilePath shortcut_folder; |
if (!ShellUtil::GetShortcutPath(location, dist, level, &shortcut_folder)) { |
@@ -1233,24 +1235,35 @@ bool BatchShortcutAction(const FileOperationCallback& shortcut_operation, |
InstallUtil::ProgramCompare target_compare(target_exe); |
file_util::FileEnumerator enumerator( |
shortcut_folder, false, file_util::FileEnumerator::FILES, |
- string16(L"*") + installer::kLnkExt); |
- base::FilePath target_path; |
- for (base::FilePath shortcut_path = enumerator.Next(); |
- !shortcut_path.empty(); |
- shortcut_path = enumerator.Next()) { |
- if (base::win::ResolveShortcut(shortcut_path, &target_path, NULL)) { |
- if (target_compare.EvaluatePath(target_path) && |
- !shortcut_operation.Run(shortcut_path)) { |
+ filename_filter); |
+ base::FilePath original_target_exe; |
+ for (base::FilePath shortcut_file = enumerator.Next(); |
+ !shortcut_file.empty(); |
+ shortcut_file = enumerator.Next()) { |
+ if (base::win::ResolveShortcut(shortcut_file, &original_target_exe, NULL)) { |
+ if (target_compare.EvaluatePath(original_target_exe) && |
+ !shortcut_operation.Run(shortcut_file)) { |
success = false; |
} |
} else { |
- LOG(ERROR) << "Cannot resolve shortcut at " << shortcut_path.value(); |
+ LOG(ERROR) << "Cannot resolve shortcut at " << shortcut_file.value(); |
success = false; |
} |
} |
return success; |
} |
+// Adaptor to FilteredBatchShortcutAction() to process all files. |
+bool BatchShortcutAction(const FileOperationCallback& shortcut_operation, |
+ ShellUtil::ShortcutLocation location, |
+ BrowserDistribution* dist, |
+ ShellUtil::ShellChange level, |
+ const base::FilePath& target_exe) { |
+ return BatchShortcutActionFilteredByName( |
+ shortcut_operation, location, dist, level, target_exe, |
+ string16(L"*") + installer::kLnkExt); |
+} |
+ |
// Removes folder spsecified by {|location|, |dist|, |level|}. |
bool RemoveShortcutFolder(ShellUtil::ShortcutLocation location, |
BrowserDistribution* dist, |
@@ -1397,7 +1410,7 @@ bool ShellUtil::GetShortcutPath(ShellUtil::ShortcutLocation location, |
} |
if (add_folder_for_dist) |
- *path = path->Append(dist->GetAppShortCutName()); |
+ *path = path->Append(dist->GetAppShortCutFolderName()); |
return true; |
} |
@@ -2020,6 +2033,26 @@ bool ShellUtil::UpdateShortcuts( |
location, dist, level, target_exe); |
} |
+// static |
+bool ShellUtil::UpdateShortcutsFilteredByName( |
+ ShellUtil::ShortcutLocation location, |
+ BrowserDistribution* dist, |
+ ShellChange level, |
+ const string16& name_filter, |
+ const base::FilePath& target_exe, |
+ const ShellUtil::ShortcutProperties& properties) { |
+ DCHECK(EndsWith(name_filter, installer::kLnkExt, false)); |
+ |
+ if (!ShellUtil::ShortcutLocationIsSupported(location)) |
+ return true; // Vacuous success. |
+ |
+ base::win::ShortcutProperties shortcut_properties( |
+ TranslateShortcutProperties(properties)); |
+ return BatchShortcutActionFilteredByName( |
+ base::Bind(&ShortcutOpUpdate, shortcut_properties), |
+ location, dist, level, target_exe, name_filter); |
+} |
+ |
bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { |
// Use a thread-safe cache for the user's suffix. |
static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = |