Index: chrome/installer/setup/install.cc |
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc |
index ffd0f2b055db97a726f85846a1b7f13a0c8d5437..f9d4f2a133c3154a6833a3c31fd512fec5fc9265 100644 |
--- a/chrome/installer/setup/install.cc |
+++ b/chrome/installer/setup/install.cc |
@@ -265,9 +265,8 @@ void CreateOrUpdateStartMenuAndTaskbarShortcuts( |
DCHECK(product.is_chrome()); |
// Information used for all shortcut types |
- BrowserDistribution* browser_dist = product.distribution(); |
- const string16 product_name(browser_dist->GetAppShortCutName()); |
- const string16 product_desc(browser_dist->GetAppDescription()); |
+ BrowserDistribution* dist = product.distribution(); |
+ const string16 product_desc(dist->GetAppDescription()); |
// Chrome link target |
FilePath chrome_exe( |
installer_state.target_path().Append(installer::kChromeExe)); |
@@ -275,44 +274,15 @@ void CreateOrUpdateStartMenuAndTaskbarShortcuts( |
bool create_always = ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); |
const char* operation = create_always ? "Creating" : "Updating"; |
- // Create Start Menu shortcuts. |
- // The location of Start->Programs->Google Chrome folder |
- FilePath start_menu_folder_path; |
- int dir_enum = installer_state.system_install() ? |
- base::DIR_COMMON_START_MENU : base::DIR_START_MENU; |
- if (!PathService::Get(dir_enum, &start_menu_folder_path)) { |
- LOG(ERROR) << "Failed to get start menu path."; |
- return; |
- } |
- |
- start_menu_folder_path = start_menu_folder_path.Append(product_name); |
- |
- // Create/update Chrome link (points to chrome.exe) & Uninstall Chrome link |
- // (which points to setup.exe) under |start_menu_folder_path|. |
- |
- // Chrome link (launches Chrome) |
- FilePath chrome_link(start_menu_folder_path.Append(product_name + L".lnk")); |
- |
- if (create_always && !file_util::PathExists(start_menu_folder_path)) |
- file_util::CreateDirectoryW(start_menu_folder_path); |
- |
- VLOG(1) << operation << " shortcut to " << chrome_exe.value() << " at " |
- << chrome_link.value(); |
- if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), |
- chrome_link.value(), string16(), product_desc, chrome_exe.value(), |
- browser_dist->GetIconIndex(), options)) { |
- LOG(WARNING) << operation << " shortcut at " << chrome_link.value() |
- << " failed."; |
- } else if (create_always && |
- base::win::GetVersion() >= base::win::VERSION_WIN7) { |
- // If the Start Menu shortcut was successfully created and |create_always|, |
- // proceed to pin the Start Menu shortcut to the taskbar on Win7+. |
- VLOG(1) << "Pinning new shortcut at " << chrome_link.value() |
- << " to taskbar"; |
- if (!file_util::TaskbarPinShortcutLink(chrome_link.value().c_str())) { |
- LOG(ERROR) << "Failed to pin shortcut to taskbar: " |
- << chrome_link.value(); |
- } |
+ VLOG(1) << operation << " Start Menu shortcut for " << chrome_exe.value() |
+ << ((create_always && |
+ base::win::GetVersion() >= base::win::VERSION_WIN7) ? |
+ " and pinning it to the taskbar." : "."); |
+ if (!ShellUtil::CreateOrUpdateChromeShortcut( |
+ ShellUtil::SHORTCUT_START_MENU, dist, chrome_exe.value(), |
+ product_desc, string16(), string16(), chrome_exe.value(), |
+ dist->GetIconIndex(), options | ShellUtil::SHORTCUT_PIN_TO_TASKBAR)) { |
+ LOG(WARNING) << operation << " Start Menu shortcut (or pinning it) failed."; |
} |
// Create/update uninstall link if we are not an MSI install. MSI |
@@ -321,20 +291,16 @@ void CreateOrUpdateStartMenuAndTaskbarShortcuts( |
// TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. |
if (!installer_state.is_msi()) { |
// Uninstall Chrome link |
- FilePath uninstall_link(start_menu_folder_path.Append( |
- browser_dist->GetUninstallLinkName() + L".lnk")); |
- |
CommandLine arguments(CommandLine::NO_PROGRAM); |
AppendUninstallCommandLineFlags(installer_state, product, &arguments); |
- VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); |
- if (!file_util::CreateOrUpdateShortcutLink(setup_exe.value().c_str(), |
- uninstall_link.value().c_str(), NULL, |
- arguments.GetCommandLineString().c_str(), NULL, |
- setup_exe.value().c_str(), 0, NULL, |
- create_always ? file_util::SHORTCUT_CREATE_ALWAYS : |
- file_util::SHORTCUT_NO_OPTIONS)) { |
- LOG(WARNING) << operation << " uninstall link at " |
- << uninstall_link.value() << " failed."; |
+ VLOG(1) << operation << " uninstall link to " << setup_exe.value() |
+ << arguments.GetCommandLineString(); |
+ if (!ShellUtil::CreateOrUpdateChromeShortcut( |
+ ShellUtil::SHORTCUT_START_MENU_UNINSTALL, dist, |
+ setup_exe.value().c_str(), string16(), string16(), |
+ arguments.GetCommandLineString().c_str(), setup_exe.value().c_str(), |
+ 0, options)) { |
+ LOG(WARNING) << operation << " uninstall link failed."; |
} |
} |
} |
@@ -347,9 +313,8 @@ void CreateOrUpdateDesktopAndQuickLaunchShortcuts( |
DCHECK(product.is_chrome()); |
// Information used for all shortcut types |
- BrowserDistribution* browser_dist = product.distribution(); |
- const string16 product_name(browser_dist->GetAppShortCutName()); |
- const string16 product_desc(browser_dist->GetAppDescription()); |
+ BrowserDistribution* dist = product.distribution(); |
+ const string16 product_desc(dist->GetAppDescription()); |
// Chrome link target |
FilePath chrome_exe( |
installer_state.target_path().Append(installer::kChromeExe)); |
@@ -357,28 +322,40 @@ void CreateOrUpdateDesktopAndQuickLaunchShortcuts( |
bool create_always = ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); |
const char* operation = create_always ? "Creating" : "Updating"; |
- ShellUtil::ShellChange desktop_level = ShellUtil::CURRENT_USER; |
- int quick_launch_levels = ShellUtil::CURRENT_USER; |
- if (installer_state.system_install()) { |
- desktop_level = ShellUtil::SYSTEM_LEVEL; |
- quick_launch_levels |= ShellUtil::SYSTEM_LEVEL; |
- } |
- |
VLOG(1) << operation << " desktop shortcut for " << chrome_exe.value(); |
- if (!ShellUtil::CreateChromeDesktopShortcut( |
- browser_dist, chrome_exe.value(), product_desc, string16(), |
- string16(), chrome_exe.value(), browser_dist->GetIconIndex(), |
- desktop_level, options)) { |
+ if (!ShellUtil::CreateOrUpdateChromeShortcut( |
+ ShellUtil::SHORTCUT_DESKTOP, |
+ dist, chrome_exe.value(), product_desc, string16(), |
+ string16(), chrome_exe.value(), dist->GetIconIndex(), options)) { |
LOG(WARNING) << operation << " desktop shortcut for " << chrome_exe.value() |
<< " failed."; |
} |
VLOG(1) << operation << " quick launch shortcut for " << chrome_exe.value(); |
- if (!ShellUtil::CreateChromeQuickLaunchShortcut( |
- browser_dist, chrome_exe.value(), quick_launch_levels, options)) { |
+ if (!ShellUtil::CreateOrUpdateChromeShortcut( |
+ ShellUtil::SHORTCUT_QUICK_LAUNCH, |
+ dist, chrome_exe.value(), product_desc, string16(), |
+ string16(), chrome_exe.value(), dist->GetIconIndex(), options)) { |
LOG(WARNING) << operation << " quick launch shortcut for " |
<< chrome_exe.value() << " failed."; |
} |
+ |
+ if (installer_state.system_install() && |
+ (options & ShellUtil::SHORTCUT_CREATE_ALWAYS)) { |
+ // On system-level installs, also create the user-level quick launch |
+ // shortcut for the user running the install. |
+ uint32 user_options = options & !ShellUtil::SHORTCUT_SYSTEM_LEVEL; |
+ VLOG(1) << operation << " user-level quick launch shortcut for " |
+ << chrome_exe.value(); |
+ if (!ShellUtil::CreateOrUpdateChromeShortcut( |
+ ShellUtil::SHORTCUT_QUICK_LAUNCH, |
+ dist, chrome_exe.value(), product_desc, string16(), |
+ string16(), chrome_exe.value(), dist->GetIconIndex(), |
+ user_options)) { |
+ LOG(WARNING) << operation << " user-level quick launch shortcut for " |
+ << chrome_exe.value() << " failed."; |
+ } |
+ } |
} |
void RegisterChromeOnMachine(const InstallerState& installer_state, |
@@ -500,6 +477,10 @@ InstallStatus InstallOrUpdateProduct( |
// the user). |
shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; |
} |
+ |
+ if (installer_state.system_install()) |
+ shortcut_options |= ShellUtil::SHORTCUT_SYSTEM_LEVEL; |
+ |
FilePath setup_exe(installer_state.GetInstallerDirectory(new_version) |
.Append(setup_path.BaseName())); |
CreateOrUpdateStartMenuAndTaskbarShortcuts( |