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

Side by Side Diff: chrome/installer/setup/install.cc

Issue 1780693002: Fix the path of Chrome shortcuts from the installer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include <string> 11 #include <string>
12 12
13 #include "base/files/file_enumerator.h"
13 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/numerics/safe_conversions.h" 18 #include "base/numerics/safe_conversions.h"
18 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/win/shortcut.h" 22 #include "base/win/shortcut.h"
22 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
23 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/installer/setup/install_worker.h" 26 #include "chrome/installer/setup/install_worker.h"
26 #include "chrome/installer/setup/installer_crash_reporting.h" 27 #include "chrome/installer/setup/installer_crash_reporting.h"
27 #include "chrome/installer/setup/setup_constants.h" 28 #include "chrome/installer/setup/setup_constants.h"
28 #include "chrome/installer/setup/setup_util.h" 29 #include "chrome/installer/setup/setup_util.h"
29 #include "chrome/installer/setup/update_active_setup_version_work_item.h" 30 #include "chrome/installer/setup/update_active_setup_version_work_item.h"
30 #include "chrome/installer/util/beacons.h" 31 #include "chrome/installer/util/beacons.h"
31 #include "chrome/installer/util/browser_distribution.h" 32 #include "chrome/installer/util/browser_distribution.h"
32 #include "chrome/installer/util/create_reg_key_work_item.h" 33 #include "chrome/installer/util/create_reg_key_work_item.h"
33 #include "chrome/installer/util/delete_after_reboot_helper.h" 34 #include "chrome/installer/util/delete_after_reboot_helper.h"
34 #include "chrome/installer/util/google_update_constants.h" 35 #include "chrome/installer/util/google_update_constants.h"
35 #include "chrome/installer/util/helper.h" 36 #include "chrome/installer/util/helper.h"
36 #include "chrome/installer/util/install_util.h" 37 #include "chrome/installer/util/install_util.h"
37 #include "chrome/installer/util/master_preferences.h" 38 #include "chrome/installer/util/master_preferences.h"
38 #include "chrome/installer/util/master_preferences_constants.h" 39 #include "chrome/installer/util/master_preferences_constants.h"
39 #include "chrome/installer/util/set_reg_value_work_item.h" 40 #include "chrome/installer/util/set_reg_value_work_item.h"
41 #include "chrome/installer/util/shell_util.h"
40 #include "chrome/installer/util/util_constants.h" 42 #include "chrome/installer/util/util_constants.h"
41 #include "chrome/installer/util/work_item.h" 43 #include "chrome/installer/util/work_item.h"
42 #include "chrome/installer/util/work_item_list.h" 44 #include "chrome/installer/util/work_item_list.h"
43 45
44 46
45 namespace { 47 namespace {
46 48
47 void LogShortcutOperation(ShellUtil::ShortcutLocation location, 49 void LogShortcutOperation(ShellUtil::ShortcutLocation location,
48 BrowserDistribution* dist, 50 BrowserDistribution* dist,
49 const ShellUtil::ShortcutProperties& properties, 51 const ShellUtil::ShortcutProperties& properties,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return installer::NEW_VERSION_UPDATED; 246 return installer::NEW_VERSION_UPDATED;
245 } 247 }
246 248
247 LOG(ERROR) << "Not sure how we got here while updating" 249 LOG(ERROR) << "Not sure how we got here while updating"
248 << ", new version: " << new_version 250 << ", new version: " << new_version
249 << ", old version: " << **current_version; 251 << ", old version: " << **current_version;
250 252
251 return installer::INSTALL_FAILED; 253 return installer::INSTALL_FAILED;
252 } 254 }
253 255
256 void UpdatePerUserShortcutsInLocation(
257 const ShellUtil::ShortcutLocation shortcut_location,
258 BrowserDistribution* dist,
259 const base::FilePath& old_target_path_prefix,
260 const base::FilePath& old_target_path_suffix,
261 const base::FilePath& new_target_path) {
262 base::FilePath shortcut_path;
263 const bool get_shortcut_path_return = ShellUtil::GetShortcutPath(
264 shortcut_location, dist, ShellUtil::CURRENT_USER, &shortcut_path);
265 DCHECK(get_shortcut_path_return);
266
267 bool recursive = false;
268
269 // TODO(fdoray): Modify GetShortcutPath such that it returns
270 // ...\Quick Launch\User Pinned instead of
271 // ...\Quick Launch\User Pinned\TaskBar for SHORTCUT_LOCATION_TASKBAR_PINS.
272 if (shortcut_location == ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS) {
273 shortcut_path = shortcut_path.DirName();
274 recursive = true;
275 }
276
277 base::FileEnumerator shortcuts_enum(shortcut_path, recursive,
278 base::FileEnumerator::FILES);
279 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty();
280 shortcut = shortcuts_enum.Next()) {
281 base::FilePath existing_target_path;
282 if (!base::win::ResolveShortcut(shortcut, &existing_target_path, nullptr) ||
283 !base::StartsWith(existing_target_path.value(),
284 old_target_path_prefix.value(),
285 base::CompareCase::INSENSITIVE_ASCII) ||
286 !base::EndsWith(existing_target_path.value(),
287 old_target_path_suffix.value(),
288 base::CompareCase::INSENSITIVE_ASCII)) {
289 continue;
290 }
291
292 base::win::ShortcutProperties updated_properties;
293 updated_properties.set_target(new_target_path);
294 base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties,
295 base::win::SHORTCUT_UPDATE_EXISTING);
296 }
297 }
298
254 } // end namespace 299 } // end namespace
255 300
256 namespace installer { 301 namespace installer {
257 302
258 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { 303 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) {
259 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"), 304 base::ReplaceChars(*att_value, base::ASCIIToUTF16("&"),
260 base::ASCIIToUTF16("&amp;"), att_value); 305 base::ASCIIToUTF16("&amp;"), att_value);
261 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"), 306 base::ReplaceChars(*att_value, base::ASCIIToUTF16("'"),
262 base::ASCIIToUTF16("&apos;"), att_value); 307 base::ASCIIToUTF16("&apos;"), att_value);
263 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"), 308 base::ReplaceChars(*att_value, base::ASCIIToUTF16("<"),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (base::PathExists(old_shortcut_path)) { 456 if (base::PathExists(old_shortcut_path)) {
412 ShellUtil::MoveExistingShortcut( 457 ShellUtil::MoveExistingShortcut(
413 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, 458 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED,
414 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, 459 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT,
415 dist, start_menu_properties); 460 dist, start_menu_properties);
416 } 461 }
417 462
418 ExecuteAndLogShortcutOperation( 463 ExecuteAndLogShortcutOperation(
419 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, 464 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist,
420 start_menu_properties, shortcut_operation); 465 start_menu_properties, shortcut_operation);
466
467 // Update the target path of existing per-user shortcuts.
468 if (install_operation == INSTALL_SHORTCUT_REPLACE_EXISTING) {
469 const base::FilePath updated_prefix = target.DirName().DirName();
470 const base::FilePath updated_suffix = target.BaseName();
471
472 UpdatePerUserShortcutsInLocation(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist,
473 updated_prefix, updated_suffix, target);
474 UpdatePerUserShortcutsInLocation(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
475 dist, updated_prefix, updated_suffix,
476 target);
477 UpdatePerUserShortcutsInLocation(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS,
478 dist, updated_prefix, updated_suffix,
479 target);
480 }
421 } 481 }
422 482
423 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, 483 void RegisterChromeOnMachine(const installer::InstallerState& installer_state,
424 const installer::Product& product, 484 const installer::Product& product,
425 bool make_chrome_default) { 485 bool make_chrome_default) {
426 DCHECK(product.is_chrome()); 486 DCHECK(product.is_chrome());
427 487
428 // Try to add Chrome to Media Player shim inclusion list. We don't do any 488 // Try to add Chrome to Media Player shim inclusion list. We don't do any
429 // error checking here because this operation will fail if user doesn't 489 // error checking here because this operation will fail if user doesn't
430 // have admin rights and we want to ignore the error. 490 // have admin rights and we want to ignore the error.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // Read master_preferences copied beside chrome.exe at install. 713 // Read master_preferences copied beside chrome.exe at install.
654 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 714 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
655 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 715 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
656 CreateOrUpdateShortcuts( 716 CreateOrUpdateShortcuts(
657 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 717 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
658 718
659 UpdateDefaultBrowserBeaconForPath(chrome_exe); 719 UpdateDefaultBrowserBeaconForPath(chrome_exe);
660 } 720 }
661 721
662 } // namespace installer 722 } // namespace installer
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698