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

Side by Side 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: self review 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/installer/setup/install.h" 5 #include "chrome/installer/setup/install.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 } // namespace 256 } // namespace
257 257
258 namespace installer { 258 namespace installer {
259 259
260 void UpdatePerUserShortcutsInLocation( 260 void UpdatePerUserShortcutsInLocation(
261 const ShellUtil::ShortcutLocation shortcut_location, 261 const ShellUtil::ShortcutLocation shortcut_location,
262 BrowserDistribution* dist, 262 BrowserDistribution* dist,
263 const base::FilePath& old_target_dir, 263 const base::FilePath& old_target_dir,
264 const base::FilePath& old_target_path_suffix, 264 const base::FilePath& old_target_name_suffix,
265 const base::FilePath& new_target_path) { 265 const base::FilePath& new_target_path) {
266 base::FilePath shortcut_path; 266 base::FilePath shortcut_path;
267 const bool get_shortcut_path_return = ShellUtil::GetShortcutPath( 267 const bool get_shortcut_path_return = ShellUtil::GetShortcutPath(
268 shortcut_location, dist, ShellUtil::CURRENT_USER, &shortcut_path); 268 shortcut_location, dist, ShellUtil::CURRENT_USER, &shortcut_path);
269 DCHECK(get_shortcut_path_return); 269 DCHECK(get_shortcut_path_return);
270 270
271 bool recursive = false; 271 bool recursive = false;
272 272
273 // TODO(fdoray): Modify GetShortcutPath such that it returns 273 // TODO(fdoray): Modify GetShortcutPath such that it returns
274 // ...\Quick Launch\User Pinned instead of 274 // ...\Quick Launch\User Pinned instead of
275 // ...\Quick Launch\User Pinned\TaskBar for SHORTCUT_LOCATION_TASKBAR_PINS. 275 // ...\Quick Launch\User Pinned\TaskBar for SHORTCUT_LOCATION_TASKBAR_PINS.
276 if (shortcut_location == ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS) { 276 if (shortcut_location == ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS) {
277 shortcut_path = shortcut_path.DirName(); 277 shortcut_path = shortcut_path.DirName();
278 recursive = true; 278 recursive = true;
279 } 279 }
280 280
281 base::FileEnumerator shortcuts_enum(shortcut_path, recursive, 281 base::FileEnumerator shortcuts_enum(shortcut_path, recursive,
282 base::FileEnumerator::FILES); 282 base::FileEnumerator::FILES);
283 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); 283 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty();
284 shortcut = shortcuts_enum.Next()) { 284 shortcut = shortcuts_enum.Next()) {
285 base::FilePath existing_target_path; 285 base::win::ShortcutProperties shortcut_properties;
286 if (!base::win::ResolveShortcut(shortcut, &existing_target_path, nullptr) || 286 if (!base::win::ResolveShortcutProperties(
287 !base::StartsWith(existing_target_path.value(), 287 shortcut, (base::win::ShortcutProperties::PROPERTIES_TARGET |
288 old_target_dir.AsEndingWithSeparator().value(), 288 base::win::ShortcutProperties::PROPERTIES_ICON),
289 base::CompareCase::INSENSITIVE_ASCII) || 289 &shortcut_properties)) {
290 !base::EndsWith(existing_target_path.value(),
291 old_target_path_suffix.value(),
292 base::CompareCase::INSENSITIVE_ASCII)) {
293 continue; 290 continue;
294 } 291 }
295 292
293 // Skip shortcuts whose target isn't a file rooted at |old_target_dir| with
294 // a name ending in |old_target_name_suffix|. Except for shortcuts whose
295 // icon is rooted at |old_target_dir|.
296 // TODO(fdoray): The second condition is only intended to fix Canary
297 // shortcuts broken by crbug.com/595374, remove it in May 2016.
298 if (!(old_target_dir.IsParent(shortcut_properties.target) &&
299 base::EndsWith(shortcut_properties.target.BaseName().value(),
300 old_target_name_suffix.value(),
301 base::CompareCase::INSENSITIVE_ASCII)) &&
302 !old_target_dir.IsParent(shortcut_properties.icon)) {
303 continue;
304 }
305
296 base::win::ShortcutProperties updated_properties; 306 base::win::ShortcutProperties updated_properties;
297 updated_properties.set_target(new_target_path); 307 updated_properties.set_target(new_target_path);
298 base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties, 308 base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties,
299 base::win::SHORTCUT_UPDATE_EXISTING); 309 base::win::SHORTCUT_UPDATE_EXISTING);
300 } 310 }
301 } 311 }
302 312
303 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { 313 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) {
304 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), 314 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"),
305 base::ASCIIToUTF16("&amp;"), att_value); 315 base::ASCIIToUTF16("&amp;"), att_value);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // Read master_preferences copied beside chrome.exe at install. 723 // Read master_preferences copied beside chrome.exe at install.
714 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 724 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
715 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 725 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
716 CreateOrUpdateShortcuts( 726 CreateOrUpdateShortcuts(
717 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 727 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
718 728
719 UpdateDefaultBrowserBeaconForPath(chrome_exe); 729 UpdateDefaultBrowserBeaconForPath(chrome_exe);
720 } 730 }
721 731
722 } // namespace installer 732 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698