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

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

Issue 1289333005: Change shortcut install location to non-subdir. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added menu_root to cleanup code Created 5 years, 2 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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 message.append("(maybe the shortcut doesn't exist?) "); 63 message.append("(maybe the shortcut doesn't exist?) ");
64 message.append((properties.level == ShellUtil::CURRENT_USER) ? "per-user " : 64 message.append((properties.level == ShellUtil::CURRENT_USER) ? "per-user " :
65 "all-users "); 65 "all-users ");
66 switch (location) { 66 switch (location) {
67 case ShellUtil::SHORTCUT_LOCATION_DESKTOP: 67 case ShellUtil::SHORTCUT_LOCATION_DESKTOP:
68 message.append("Desktop "); 68 message.append("Desktop ");
69 break; 69 break;
70 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH: 70 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH:
71 message.append("Quick Launch "); 71 message.append("Quick Launch ");
72 break; 72 break;
73 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR: 73 case ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT:
74 message.append("Start menu ");
75 break;
76 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED:
74 message.append("Start menu/" + 77 message.append("Start menu/" +
75 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder( 78 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder(
76 BrowserDistribution::SUBFOLDER_CHROME)) + 79 BrowserDistribution::SUBFOLDER_CHROME)) +
77 " "); 80 " ");
78 break; 81 break;
79 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR: 82 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR:
80 message.append("Start menu/" + 83 message.append("Start menu/" +
81 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder( 84 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder(
82 BrowserDistribution::SUBFOLDER_APPS)) + 85 BrowserDistribution::SUBFOLDER_APPS)) +
83 " "); 86 " ");
(...skipping 20 matching lines...) Expand all
104 } 107 }
105 108
106 message.push_back('.'); 109 message.push_back('.');
107 110
108 if (failed) 111 if (failed)
109 LOG(WARNING) << message; 112 LOG(WARNING) << message;
110 else 113 else
111 VLOG(1) << message; 114 VLOG(1) << message;
112 } 115 }
113 116
114 void ExecuteAndLogShortcutOperation( 117 bool ExecuteAndLogShortcutOperation(
gab 2015/10/20 18:25:59 grt pinged about this already I think, but adding
bcwhite 2015/10/20 19:03:12 It was used in a previous incarnation of the patch
115 ShellUtil::ShortcutLocation location, 118 ShellUtil::ShortcutLocation location,
116 BrowserDistribution* dist, 119 BrowserDistribution* dist,
117 const ShellUtil::ShortcutProperties& properties, 120 const ShellUtil::ShortcutProperties& properties,
118 ShellUtil::ShortcutOperation operation) { 121 ShellUtil::ShortcutOperation operation) {
119 LogShortcutOperation(location, dist, properties, operation, false); 122 LogShortcutOperation(location, dist, properties, operation, false);
120 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties, 123 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties,
121 operation)) { 124 operation)) {
122 LogShortcutOperation(location, dist, properties, operation, true); 125 LogShortcutOperation(location, dist, properties, operation, true);
126 return false;
123 } 127 }
128 return true;
124 } 129 }
125 130
126 void AddChromeToMediaPlayerList() { 131 void AddChromeToMediaPlayerList() {
127 base::string16 reg_path(installer::kMediaPlayerRegPath); 132 base::string16 reg_path(installer::kMediaPlayerRegPath);
128 // registry paths can also be appended like file system path 133 // registry paths can also be appended like file system path
129 reg_path.push_back(base::FilePath::kSeparators[0]); 134 reg_path.push_back(base::FilePath::kSeparators[0]);
130 reg_path.append(installer::kChromeExe); 135 reg_path.append(installer::kChromeExe);
131 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; 136 VLOG(1) << "Adding Chrome to Media player list at " << reg_path;
132 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( 137 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem(
133 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); 138 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default));
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // IMPORTANT: Only the default (no arguments and default browserappid) browser 421 // IMPORTANT: Only the default (no arguments and default browserappid) browser
417 // shortcut in the Start menu (Start screen on Win8+) should be made dual 422 // shortcut in the Start menu (Start screen on Win8+) should be made dual
418 // mode and that prior to Windows 10 only. 423 // mode and that prior to Windows 10 only.
419 if (InstallUtil::ShouldInstallMetroProperties()) 424 if (InstallUtil::ShouldInstallMetroProperties())
420 start_menu_properties.set_dual_mode(true); 425 start_menu_properties.set_dual_mode(true);
421 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS || 426 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS ||
422 shortcut_operation == 427 shortcut_operation ==
423 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) { 428 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) {
424 start_menu_properties.set_pin_to_taskbar(!do_not_create_taskbar_shortcut); 429 start_menu_properties.set_pin_to_taskbar(!do_not_create_taskbar_shortcut);
425 } 430 }
431
432 // Move start-menu shortcut out of the deprecated Chrome specific subfolder.
433 // This needs to happen before the shortcut update below or the latter will
434 // fail due to the existing shortcut not being in the same location as the
435 // new one.
436 base::FilePath old_shortcut_path;
437 ShellUtil::GetShortcutPath(
438 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, dist,
439 shortcut_level, &old_shortcut_path);
440 if (base::PathExists(old_shortcut_path)) {
441 ShellUtil::MoveExistingShortcut(
442 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED,
443 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT,
444 dist, start_menu_properties);
445 }
446
426 ExecuteAndLogShortcutOperation( 447 ExecuteAndLogShortcutOperation(
427 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, dist, 448 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist,
428 start_menu_properties, shortcut_operation); 449 start_menu_properties, shortcut_operation);
429 } 450 }
430 451
431 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, 452 void RegisterChromeOnMachine(const installer::InstallerState& installer_state,
432 const installer::Product& product, 453 const installer::Product& product,
433 bool make_chrome_default) { 454 bool make_chrome_default) {
434 DCHECK(product.is_chrome()); 455 DCHECK(product.is_chrome());
435 456
436 // Try to add Chrome to Media Player shim inclusion list. We don't do any 457 // Try to add Chrome to Media Player shim inclusion list. We don't do any
437 // error checking here because this operation will fail if user doesn't 458 // error checking here because this operation will fail if user doesn't
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 // Read master_preferences copied beside chrome.exe at install. 693 // Read master_preferences copied beside chrome.exe at install.
673 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 694 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
674 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 695 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
675 CreateOrUpdateShortcuts( 696 CreateOrUpdateShortcuts(
676 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 697 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
677 698
678 UpdateDefaultBrowserBeaconForPath(chrome_exe); 699 UpdateDefaultBrowserBeaconForPath(chrome_exe);
679 } 700 }
680 701
681 } // namespace installer 702 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698