diff --git a/chrome/browser/web_applications/os_integration/web_app_shortcut_win.cc b/chrome/browser/web_applications/os_integration/web_app_shortcut_win.cc --- a/chrome/browser/web_applications/os_integration/web_app_shortcut_win.cc +++ b/chrome/browser/web_applications/os_integration/web_app_shortcut_win.cc @@ -345,10 +345,18 @@ Result UpdateShortcuts(const base::FilePath& web_app_path, const bool title_change = old_app_title != shortcut_info.title; Result result = Result::kOk; for (const auto& shortcut : all_shortcuts) { - const base::FilePath new_shortcut = + base::FilePath new_shortcut = shortcut.DirName() .Append(GetSanitizedFileName(shortcut_info.title)) .AddExtension(installer::kLnkExt); + // Do not overwrite an unrelated shortcut that already has the new name. + if (new_shortcut != shortcut) { + new_shortcut = base::GetUniquePath(new_shortcut); + if (new_shortcut.empty()) { + result = Result::kError; + continue; + } + } if (title_change) { // When the title changes, it is not enough to rename the shortcut file, // because it still points to the old icon. Update the icon file before @@ -411,10 +419,18 @@ Result UpdateShortcuts(const base::FilePath& web_app_path, // like PKEY_ItemName on the shortcut does not seem to change the shortcut's // properties, as determined by shortcut_properties.py. for (const auto& shortcut : pinned_shortcuts) { - const base::FilePath new_shortcut = + base::FilePath new_shortcut = shortcut.DirName() .Append(GetSanitizedFileName(shortcut_info.title)) .AddExtension(installer::kLnkExt); + // Do not overwrite an unrelated pinned shortcut that already has the new + // name. + if (new_shortcut != shortcut) { + new_shortcut = base::GetUniquePath(new_shortcut); + if (new_shortcut.empty()) { + result = Result::kError; + continue; + } + } if (title_change) { UpdateIconFileForShortcut(web_app_path, shortcut, shortcut_info.title);