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

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: move shortcut instead of delete/create 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_ROOT:
74 message.append("Start menu ");
75 break;
73 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR: 76 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR:
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)) +
(...skipping 26 matching lines...) Expand all
109 } 112 }
110 113
111 message.push_back('.'); 114 message.push_back('.');
112 115
113 if (failed) 116 if (failed)
114 LOG(WARNING) << message; 117 LOG(WARNING) << message;
115 else 118 else
116 VLOG(1) << message; 119 VLOG(1) << message;
117 } 120 }
118 121
119 void ExecuteAndLogShortcutOperation( 122 bool ExecuteAndLogShortcutOperation(
120 ShellUtil::ShortcutLocation location, 123 ShellUtil::ShortcutLocation location,
121 BrowserDistribution* dist, 124 BrowserDistribution* dist,
122 const ShellUtil::ShortcutProperties& properties, 125 const ShellUtil::ShortcutProperties& properties,
123 ShellUtil::ShortcutOperation operation) { 126 ShellUtil::ShortcutOperation operation) {
124 LogShortcutOperation(location, dist, properties, operation, false); 127 LogShortcutOperation(location, dist, properties, operation, false);
125 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties, 128 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties,
126 operation)) { 129 operation)) {
127 LogShortcutOperation(location, dist, properties, operation, true); 130 LogShortcutOperation(location, dist, properties, operation, true);
131 return false;
128 } 132 }
133 return true;
129 } 134 }
130 135
131 void AddChromeToMediaPlayerList() { 136 void AddChromeToMediaPlayerList() {
132 base::string16 reg_path(installer::kMediaPlayerRegPath); 137 base::string16 reg_path(installer::kMediaPlayerRegPath);
133 // registry paths can also be appended like file system path 138 // registry paths can also be appended like file system path
134 reg_path.push_back(base::FilePath::kSeparators[0]); 139 reg_path.push_back(base::FilePath::kSeparators[0]);
135 reg_path.append(installer::kChromeExe); 140 reg_path.append(installer::kChromeExe);
136 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; 141 VLOG(1) << "Adding Chrome to Media player list at " << reg_path;
137 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( 142 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem(
138 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); 143 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default));
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (InstallUtil::ShouldInstallMetroProperties()) 432 if (InstallUtil::ShouldInstallMetroProperties())
428 start_menu_properties.set_dual_mode(true); 433 start_menu_properties.set_dual_mode(true);
429 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS || 434 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS ||
430 shortcut_operation == 435 shortcut_operation ==
431 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) { 436 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) {
432 start_menu_properties.set_pin_to_taskbar(!do_not_create_taskbar_shortcut); 437 start_menu_properties.set_pin_to_taskbar(!do_not_create_taskbar_shortcut);
433 // Disabled for now. TODO(gab): Remove this and the associated code if it 438 // Disabled for now. TODO(gab): Remove this and the associated code if it
434 // remains disabled long term. 439 // remains disabled long term.
435 start_menu_properties.set_pin_to_start(false); 440 start_menu_properties.set_pin_to_start(false);
436 } 441 }
442
443 // We're migrating from shortcuts in a subdirectory to being directly in
444 // the list of "All Programs" which means the update may fail because it's
445 // not currently in the location we want it to go. In this case, we have
446 // to explicitly remove the old one and force-create the new one.
gab 2015/10/13 19:35:09 Suggest changing this whole paragraph with somethi
bcwhite 2015/10/15 18:29:35 Done.
447 base::FilePath old_shortcut_path;
448 ShellUtil::GetShortcutPath(
449 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, dist,
450 shortcut_level, &old_shortcut_path);
451 if (base::PathExists(old_shortcut_path)) {
452 ShellUtil::MoveExistingShortcut(
453 shortcut_level, dist, start_menu_properties,
454 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR,
gab 2015/10/13 19:35:09 Rename SHORTCUT_LOCATION_START_MENU_CHROME_DIR to
bcwhite 2015/10/15 18:29:35 Done.
455 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT);
456 }
gab 2015/10/13 19:35:09 Also need to delete the subfolder on success. I s
bcwhite 2015/10/15 18:29:35 Generally there is only the one but should there b
gab 2015/10/15 18:55:06 I really think we should aim to delete the subfold
grt (UTC plus 2) 2015/10/19 17:28:44 Hmm. I think leaving old custom shortcuts in the d
457
437 ExecuteAndLogShortcutOperation( 458 ExecuteAndLogShortcutOperation(
438 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, dist, 459 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist,
439 start_menu_properties, shortcut_operation); 460 start_menu_properties, shortcut_operation);
440 } 461 }
441 462
442 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, 463 void RegisterChromeOnMachine(const installer::InstallerState& installer_state,
443 const installer::Product& product, 464 const installer::Product& product,
444 bool make_chrome_default) { 465 bool make_chrome_default) {
445 DCHECK(product.is_chrome()); 466 DCHECK(product.is_chrome());
446 467
447 // Try to add Chrome to Media Player shim inclusion list. We don't do any 468 // Try to add Chrome to Media Player shim inclusion list. We don't do any
448 // error checking here because this operation will fail if user doesn't 469 // error checking here because this operation will fail if user doesn't
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // Read master_preferences copied beside chrome.exe at install. 704 // Read master_preferences copied beside chrome.exe at install.
684 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); 705 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs));
685 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); 706 base::FilePath chrome_exe(installation_root.Append(kChromeExe));
686 CreateOrUpdateShortcuts( 707 CreateOrUpdateShortcuts(
687 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); 708 chrome_exe, chrome, prefs, CURRENT_USER, install_operation);
688 709
689 UpdateDefaultBrowserBeaconForPath(chrome_exe); 710 UpdateDefaultBrowserBeaconForPath(chrome_exe);
690 } 711 }
691 712
692 } // namespace installer 713 } // namespace installer
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/setup/install_unittest.cc » ('j') | chrome/installer/setup/install_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698