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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 WCHAR old_target_dir_full_path_buffer[MAX_PATH]; | |
| 282 if (::GetFullPathName(old_target_dir.value().c_str(), MAX_PATH, | |
| 283 old_target_dir_full_path_buffer, nullptr) == 0) { | |
|
gab
2016/03/18 20:07:11
::GetFullPathName() also returns the size of the b
| |
| 284 return; | |
| 285 } | |
| 286 const base::FilePath old_target_dir_full_path( | |
| 287 old_target_dir_full_path_buffer); | |
| 288 | |
| 281 base::FileEnumerator shortcuts_enum(shortcut_path, recursive, | 289 base::FileEnumerator shortcuts_enum(shortcut_path, recursive, |
| 282 base::FileEnumerator::FILES); | 290 base::FileEnumerator::FILES); |
| 283 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); | 291 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); |
| 284 shortcut = shortcuts_enum.Next()) { | 292 shortcut = shortcuts_enum.Next()) { |
| 285 base::FilePath existing_target_path; | 293 base::win::ShortcutProperties shortcut_properties; |
| 286 if (!base::win::ResolveShortcut(shortcut, &existing_target_path, nullptr) || | 294 if (!base::win::ResolveShortcutProperties( |
| 287 !base::StartsWith(existing_target_path.value(), | 295 shortcut, (base::win::ShortcutProperties::PROPERTIES_TARGET | |
| 288 old_target_dir.AsEndingWithSeparator().value(), | 296 base::win::ShortcutProperties::PROPERTIES_ICON), |
| 289 base::CompareCase::INSENSITIVE_ASCII) || | 297 &shortcut_properties)) { |
| 290 !base::EndsWith(existing_target_path.value(), | |
| 291 old_target_path_suffix.value(), | |
| 292 base::CompareCase::INSENSITIVE_ASCII)) { | |
| 293 continue; | 298 continue; |
| 294 } | 299 } |
| 295 | 300 |
| 301 WCHAR shortcut_target_full_path_buffer[MAX_PATH]; | |
| 302 WCHAR shortcut_icon_full_path_buffer[MAX_PATH]; | |
| 303 if (::GetFullPathName(shortcut_properties.target.value().c_str(), MAX_PATH, | |
| 304 shortcut_target_full_path_buffer, nullptr) == 0 || | |
| 305 ::GetFullPathName(shortcut_properties.icon.value().c_str(), MAX_PATH, | |
| 306 shortcut_icon_full_path_buffer, nullptr) == 0) { | |
| 307 return; | |
| 308 } | |
| 309 const base::FilePath shortcut_target_full_path( | |
| 310 shortcut_target_full_path_buffer); | |
| 311 const base::FilePath shortcut_icon_full_path( | |
| 312 shortcut_icon_full_path_buffer); | |
| 313 | |
| 314 // Skip shortcuts whose target isn't a file rooted at |old_target_dir| with | |
| 315 // a name ending in |old_target_name_suffix|. Except for shortcuts whose | |
| 316 // icon is rooted at |old_target_dir|. | |
| 317 // TODO(fdoray): The second condition is only intended to fix Canary | |
| 318 // shortcuts broken by crbug.com/595374, remove it in May 2016. | |
| 319 if (!(old_target_dir_full_path.IsParent(shortcut_target_full_path) && | |
| 320 base::EndsWith(shortcut_properties.target.BaseName().value(), | |
| 321 old_target_name_suffix.value(), | |
| 322 base::CompareCase::INSENSITIVE_ASCII)) && | |
| 323 !old_target_dir_full_path.IsParent(shortcut_icon_full_path)) { | |
| 324 continue; | |
| 325 } | |
| 326 | |
| 296 base::win::ShortcutProperties updated_properties; | 327 base::win::ShortcutProperties updated_properties; |
| 297 updated_properties.set_target(new_target_path); | 328 updated_properties.set_target(new_target_path); |
| 298 base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties, | 329 base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties, |
| 299 base::win::SHORTCUT_UPDATE_EXISTING); | 330 base::win::SHORTCUT_UPDATE_EXISTING); |
| 300 } | 331 } |
| 301 } | 332 } |
| 302 | 333 |
| 303 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { | 334 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { |
| 304 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), | 335 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), |
| 305 base::ASCIIToUTF16("&"), att_value); | 336 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. | 744 // Read master_preferences copied beside chrome.exe at install. |
| 714 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 745 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 715 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 746 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 716 CreateOrUpdateShortcuts( | 747 CreateOrUpdateShortcuts( |
| 717 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 748 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 718 | 749 |
| 719 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 750 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
| 720 } | 751 } |
| 721 | 752 |
| 722 } // namespace installer | 753 } // namespace installer |
| OLD | NEW |