Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // TODO(fdoray): Stop using the icon to identify shortcuts that need to be | |
| 294 // updated in May 2016. This is just intended to fix shortcuts broken by | |
| 295 // crbug.com/595374. | |
| 296 if (!(base::StartsWith(shortcut_properties.target.value(), | |
| 297 old_target_dir.AsEndingWithSeparator().value(), | |
| 298 base::CompareCase::INSENSITIVE_ASCII) && | |
| 299 base::EndsWith(shortcut_properties.target.value(), | |
| 300 old_target_path_suffix.value(), | |
| 301 base::CompareCase::INSENSITIVE_ASCII)) && | |
| 302 !old_target_dir.IsParent(shortcut_properties.icon)) { | |
|
gab
2016/03/17 20:14:23
I had a hard time reading this logic, I'd say add
gab
2016/03/17 20:14:23
How about we do path comparison everywhere instead
fdoray
2016/03/18 14:08:59
Done.
fdoray
2016/03/18 14:08:59
Done.
| |
| 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("&"), att_value); | 315 base::ASCIIToUTF16("&"), att_value); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| OLD | NEW |