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

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: 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
11 #include <string> 11 #include <string>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/numerics/safe_conversions.h" 17 #include "base/numerics/safe_conversions.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/win/shortcut.h" 21 #include "base/win/shortcut.h"
22 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
23 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/installer/setup/install_worker.h" 25 #include "chrome/installer/setup/install_worker.h"
26 #include "chrome/installer/setup/installer_crash_reporting.h" 26 #include "chrome/installer/setup/installer_crash_reporting.h"
27 #include "chrome/installer/setup/setup_constants.h" 27 #include "chrome/installer/setup/setup_constants.h"
28 #include "chrome/installer/setup/setup_util.h" 28 #include "chrome/installer/setup/setup_util.h"
29 #include "chrome/installer/setup/update_active_setup_version_work_item.h" 29 #include "chrome/installer/setup/update_active_setup_version_work_item.h"
30 #include "chrome/installer/setup/update_shortcuts.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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // Shortcuts are always installed per-user unless specified. 371 // Shortcuts are always installed per-user unless specified.
370 ShellUtil::ShellChange shortcut_level = (install_level == ALL_USERS ? 372 ShellUtil::ShellChange shortcut_level = (install_level == ALL_USERS ?
371 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER); 373 ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER);
372 374
373 // |base_properties|: The basic properties to set on every shortcut installed 375 // |base_properties|: The basic properties to set on every shortcut installed
374 // (to be refined on a per-shortcut basis). 376 // (to be refined on a per-shortcut basis).
375 ShellUtil::ShortcutProperties base_properties(shortcut_level); 377 ShellUtil::ShortcutProperties base_properties(shortcut_level);
376 product.AddDefaultShortcutProperties(target, &base_properties); 378 product.AddDefaultShortcutProperties(target, &base_properties);
377 379
378 if (!do_not_create_desktop_shortcut || 380 if (!do_not_create_desktop_shortcut ||
379 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { 381 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) {
gab 2016/03/09 20:10:44 I was initially going to say that these are redund
fdoray 2016/03/09 22:13:03 They are redundant. This code should be refactored
380 ExecuteAndLogShortcutOperation( 382 ExecuteAndLogShortcutOperation(
381 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, base_properties, 383 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, base_properties,
382 shortcut_operation); 384 shortcut_operation);
383 } 385 }
384 386
385 if (!do_not_create_quick_launch_shortcut || 387 if (!do_not_create_quick_launch_shortcut ||
386 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { 388 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) {
387 // There is no such thing as an all-users Quick Launch shortcut, always 389 // There is no such thing as an all-users Quick Launch shortcut, always
388 // install the per-user shortcut. 390 // install the per-user shortcut.
389 ShellUtil::ShortcutProperties quick_launch_properties(base_properties); 391 ShellUtil::ShortcutProperties quick_launch_properties(base_properties);
(...skipping 21 matching lines...) Expand all
411 if (base::PathExists(old_shortcut_path)) { 413 if (base::PathExists(old_shortcut_path)) {
412 ShellUtil::MoveExistingShortcut( 414 ShellUtil::MoveExistingShortcut(
413 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, 415 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED,
414 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, 416 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT,
415 dist, start_menu_properties); 417 dist, start_menu_properties);
416 } 418 }
417 419
418 ExecuteAndLogShortcutOperation( 420 ExecuteAndLogShortcutOperation(
419 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, 421 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist,
420 start_menu_properties, shortcut_operation); 422 start_menu_properties, shortcut_operation);
423
424 // Update the target path of existing shortcuts.
gab 2016/03/09 20:10:44 s/shortcuts/per-user shortcuts/
fdoray 2016/03/09 22:13:03 Done.
425 if (install_operation == INSTALL_SHORTCUT_REPLACE_EXISTING) {
426 const base::FilePath target_path_prefix = target.DirName();
gab 2016/03/09 20:10:44 If I'm not mistaken, |target_path| here will be so
gab 2016/03/09 20:10:44 How about: s/target_path_prefix/updated_prefix/ s
fdoray 2016/03/09 22:13:03 Done.
fdoray 2016/03/09 22:13:03 Done. I didn't use the path from the bug report to
427 const base::FilePath target_path_suffix = target.BaseName();
428
429 UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_DESKTOP, shortcut_level, dist,
gab 2016/03/09 20:10:44 s/shortcut_level/ShellUtil::CURRENT_USER/ here an
fdoray 2016/03/09 22:13:02 CURRENT_USER now hard-coded in UpdatePerUserShortc
430 target_path_prefix, target_path_suffix, target);
431 UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT,
gab 2016/03/09 20:10:43 Don't think we need to touch the Start Menu shortc
fdoray 2016/03/09 22:13:03 Done.
432 shortcut_level, dist, target_path_prefix,
433 target_path_suffix, target);
434
435 // Check that the quick launch directory is a parent of the taskbar pins
gab 2016/03/09 20:10:44 // The next update assumes that the quick launch d
fdoray 2016/03/09 22:13:03 I now have separate calls to UpdatePerUserShortcut
436 // directory.
437 if (DCHECK_IS_ON()) {
438 base::FilePath taskbar_pins_path;
439 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS,
440 dist, shortcut_level, &taskbar_pins_path);
441 base::FilePath quick_launch_path;
442 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
443 dist, shortcut_level, &quick_launch_path);
444 DCHECK(quick_launch_path.IsParent(taskbar_pins_path));
445 }
446 // This updates both quick launch and taskbar pins.
gab 2016/03/09 20:10:43 // Update quick launch and taskbar pins.
fdoray 2016/03/09 22:13:02 This comment is no longer applicable.
447 UpdateShortcuts(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH,
448 ShellUtil::CURRENT_USER, dist, target_path_prefix,
449 target_path_suffix, target);
450 }
421 } 451 }
422 452
423 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, 453 void RegisterChromeOnMachine(const installer::InstallerState& installer_state,
424 const installer::Product& product, 454 const installer::Product& product,
425 bool make_chrome_default) { 455 bool make_chrome_default) {
426 DCHECK(product.is_chrome()); 456 DCHECK(product.is_chrome());
427 457
428 // Try to add Chrome to Media Player shim inclusion list. We don't do any 458 // 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 459 // error checking here because this operation will fail if user doesn't
430 // have admin rights and we want to ignore the error. 460 // 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. 683 // Read master_preferences copied beside chrome.exe at install.
654 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 684 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
655 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 685 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
656 CreateOrUpdateShortcuts( 686 CreateOrUpdateShortcuts(
657 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 687 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
658 688
659 UpdateDefaultBrowserBeaconForPath(chrome_exe); 689 UpdateDefaultBrowserBeaconForPath(chrome_exe);
660 } 690 }
661 691
662 } // namespace installer 692 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698