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

Unified Diff: chrome/installer/setup/install.cc

Issue 1800303006: Fix the path of shortcuts with an icon in the current install dir. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix buildbot error Created 4 years, 9 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/setup/install.h ('k') | chrome/installer/setup/install_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/install.cc
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 744af926972ec5fa5d07687713591f568cb17cd1..b05b5cf142e05692aff259c4244535dbe321dd53 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -261,7 +261,7 @@ void UpdatePerUserShortcutsInLocation(
const ShellUtil::ShortcutLocation shortcut_location,
BrowserDistribution* dist,
const base::FilePath& old_target_dir,
- const base::FilePath& old_target_path_suffix,
+ const base::FilePath& old_target_name_suffix,
const base::FilePath& new_target_path) {
base::FilePath shortcut_path;
const bool get_shortcut_path_return = ShellUtil::GetShortcutPath(
@@ -278,18 +278,49 @@ void UpdatePerUserShortcutsInLocation(
recursive = true;
}
+ WCHAR old_target_dir_full_path_buffer[MAX_PATH];
+ if (::GetFullPathName(old_target_dir.value().c_str(), MAX_PATH,
+ old_target_dir_full_path_buffer, nullptr) == 0) {
gab 2016/03/18 20:07:11 ::GetFullPathName() also returns the size of the b
+ return;
+ }
+ const base::FilePath old_target_dir_full_path(
+ old_target_dir_full_path_buffer);
+
base::FileEnumerator shortcuts_enum(shortcut_path, recursive,
base::FileEnumerator::FILES);
for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty();
shortcut = shortcuts_enum.Next()) {
- base::FilePath existing_target_path;
- if (!base::win::ResolveShortcut(shortcut, &existing_target_path, nullptr) ||
- !base::StartsWith(existing_target_path.value(),
- old_target_dir.AsEndingWithSeparator().value(),
- base::CompareCase::INSENSITIVE_ASCII) ||
- !base::EndsWith(existing_target_path.value(),
- old_target_path_suffix.value(),
- base::CompareCase::INSENSITIVE_ASCII)) {
+ base::win::ShortcutProperties shortcut_properties;
+ if (!base::win::ResolveShortcutProperties(
+ shortcut, (base::win::ShortcutProperties::PROPERTIES_TARGET |
+ base::win::ShortcutProperties::PROPERTIES_ICON),
+ &shortcut_properties)) {
+ continue;
+ }
+
+ WCHAR shortcut_target_full_path_buffer[MAX_PATH];
+ WCHAR shortcut_icon_full_path_buffer[MAX_PATH];
+ if (::GetFullPathName(shortcut_properties.target.value().c_str(), MAX_PATH,
+ shortcut_target_full_path_buffer, nullptr) == 0 ||
+ ::GetFullPathName(shortcut_properties.icon.value().c_str(), MAX_PATH,
+ shortcut_icon_full_path_buffer, nullptr) == 0) {
+ return;
+ }
+ const base::FilePath shortcut_target_full_path(
+ shortcut_target_full_path_buffer);
+ const base::FilePath shortcut_icon_full_path(
+ shortcut_icon_full_path_buffer);
+
+ // Skip shortcuts whose target isn't a file rooted at |old_target_dir| with
+ // a name ending in |old_target_name_suffix|. Except for shortcuts whose
+ // icon is rooted at |old_target_dir|.
+ // TODO(fdoray): The second condition is only intended to fix Canary
+ // shortcuts broken by crbug.com/595374, remove it in May 2016.
+ if (!(old_target_dir_full_path.IsParent(shortcut_target_full_path) &&
+ base::EndsWith(shortcut_properties.target.BaseName().value(),
+ old_target_name_suffix.value(),
+ base::CompareCase::INSENSITIVE_ASCII)) &&
+ !old_target_dir_full_path.IsParent(shortcut_icon_full_path)) {
continue;
}
« no previous file with comments | « chrome/installer/setup/install.h ('k') | chrome/installer/setup/install_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698