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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return installer::NEW_VERSION_UPDATED; | 246 return installer::NEW_VERSION_UPDATED; |
247 } | 247 } |
248 | 248 |
249 LOG(ERROR) << "Not sure how we got here while updating" | 249 LOG(ERROR) << "Not sure how we got here while updating" |
250 << ", new version: " << new_version | 250 << ", new version: " << new_version |
251 << ", old version: " << **current_version; | 251 << ", old version: " << **current_version; |
252 | 252 |
253 return installer::INSTALL_FAILED; | 253 return installer::INSTALL_FAILED; |
254 } | 254 } |
255 | 255 |
| 256 } // namespace |
| 257 |
| 258 namespace installer { |
| 259 |
256 void UpdatePerUserShortcutsInLocation( | 260 void UpdatePerUserShortcutsInLocation( |
257 const ShellUtil::ShortcutLocation shortcut_location, | 261 const ShellUtil::ShortcutLocation shortcut_location, |
258 BrowserDistribution* dist, | 262 BrowserDistribution* dist, |
259 const base::FilePath& old_target_path_prefix, | 263 const base::FilePath& old_target_dir, |
260 const base::FilePath& old_target_path_suffix, | 264 const base::FilePath& old_target_path_suffix, |
261 const base::FilePath& new_target_path) { | 265 const base::FilePath& new_target_path) { |
262 base::FilePath shortcut_path; | 266 base::FilePath shortcut_path; |
263 const bool get_shortcut_path_return = ShellUtil::GetShortcutPath( | 267 const bool get_shortcut_path_return = ShellUtil::GetShortcutPath( |
264 shortcut_location, dist, ShellUtil::CURRENT_USER, &shortcut_path); | 268 shortcut_location, dist, ShellUtil::CURRENT_USER, &shortcut_path); |
265 DCHECK(get_shortcut_path_return); | 269 DCHECK(get_shortcut_path_return); |
266 | 270 |
267 bool recursive = false; | 271 bool recursive = false; |
268 | 272 |
269 // TODO(fdoray): Modify GetShortcutPath such that it returns | 273 // TODO(fdoray): Modify GetShortcutPath such that it returns |
270 // ...\Quick Launch\User Pinned instead of | 274 // ...\Quick Launch\User Pinned instead of |
271 // ...\Quick Launch\User Pinned\TaskBar for SHORTCUT_LOCATION_TASKBAR_PINS. | 275 // ...\Quick Launch\User Pinned\TaskBar for SHORTCUT_LOCATION_TASKBAR_PINS. |
272 if (shortcut_location == ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS) { | 276 if (shortcut_location == ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS) { |
273 shortcut_path = shortcut_path.DirName(); | 277 shortcut_path = shortcut_path.DirName(); |
274 recursive = true; | 278 recursive = true; |
275 } | 279 } |
276 | 280 |
277 base::FileEnumerator shortcuts_enum(shortcut_path, recursive, | 281 base::FileEnumerator shortcuts_enum(shortcut_path, recursive, |
278 base::FileEnumerator::FILES); | 282 base::FileEnumerator::FILES); |
279 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); | 283 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); |
280 shortcut = shortcuts_enum.Next()) { | 284 shortcut = shortcuts_enum.Next()) { |
281 base::FilePath existing_target_path; | 285 base::FilePath existing_target_path; |
282 if (!base::win::ResolveShortcut(shortcut, &existing_target_path, nullptr) || | 286 if (!base::win::ResolveShortcut(shortcut, &existing_target_path, nullptr) || |
283 !base::StartsWith(existing_target_path.value(), | 287 !base::StartsWith(existing_target_path.value(), |
284 old_target_path_prefix.value(), | 288 old_target_dir.AsEndingWithSeparator().value(), |
285 base::CompareCase::INSENSITIVE_ASCII) || | 289 base::CompareCase::INSENSITIVE_ASCII) || |
286 !base::EndsWith(existing_target_path.value(), | 290 !base::EndsWith(existing_target_path.value(), |
287 old_target_path_suffix.value(), | 291 old_target_path_suffix.value(), |
288 base::CompareCase::INSENSITIVE_ASCII)) { | 292 base::CompareCase::INSENSITIVE_ASCII)) { |
289 continue; | 293 continue; |
290 } | 294 } |
291 | 295 |
292 base::win::ShortcutProperties updated_properties; | 296 base::win::ShortcutProperties updated_properties; |
293 updated_properties.set_target(new_target_path); | 297 updated_properties.set_target(new_target_path); |
294 base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties, | 298 base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties, |
295 base::win::SHORTCUT_UPDATE_EXISTING); | 299 base::win::SHORTCUT_UPDATE_EXISTING); |
296 } | 300 } |
297 } | 301 } |
298 | 302 |
299 } // end namespace | |
300 | |
301 namespace installer { | |
302 | |
303 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { | 303 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { |
304 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), | 304 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), |
305 base::ASCIIToUTF16("&"), att_value); | 305 base::ASCIIToUTF16("&"), att_value); |
306 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"), | 306 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"), |
307 base::ASCIIToUTF16("'"), att_value); | 307 base::ASCIIToUTF16("'"), att_value); |
308 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"), | 308 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"), |
309 base::ASCIIToUTF16("<"), att_value); | 309 base::ASCIIToUTF16("<"), att_value); |
310 } | 310 } |
311 | 311 |
312 bool CreateVisualElementsManifest(const base::FilePath& src_path, | 312 bool CreateVisualElementsManifest(const base::FilePath& src_path, |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 // Read master_preferences copied beside chrome.exe at install. | 713 // Read master_preferences copied beside chrome.exe at install. |
714 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 714 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
715 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 715 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
716 CreateOrUpdateShortcuts( | 716 CreateOrUpdateShortcuts( |
717 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 717 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
718 | 718 |
719 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 719 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
720 } | 720 } |
721 | 721 |
722 } // namespace installer | 722 } // namespace installer |
OLD | NEW |