diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-24 16:18:27 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-24 16:18:27 +0000 |
commit | 67da235a1f65da29dc578af28ce043af6be0fa74 (patch) | |
tree | 6c619b18d88420c9cc8e0684983e17a47bf34731 /chrome/installer/setup/setup.cc | |
parent | 046009ed359d28f4d51360b9edd57dbd94cec979 (diff) | |
download | chromium_src-67da235a1f65da29dc578af28ce043af6be0fa74.zip chromium_src-67da235a1f65da29dc578af28ce043af6be0fa74.tar.gz chromium_src-67da235a1f65da29dc578af28ce043af6be0fa74.tar.bz2 |
Add installer command line option to create shortcuts (desktop and quick
launch).
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3913 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/setup/setup.cc')
-rw-r--r-- | chrome/installer/setup/setup.cc | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/chrome/installer/setup/setup.cc b/chrome/installer/setup/setup.cc index 8a301da..9b375be 100644 --- a/chrome/installer/setup/setup.cc +++ b/chrome/installer/setup/setup.cc @@ -6,6 +6,7 @@ #include "chrome/installer/setup/setup.h" +#include "base/command_line.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/registry.h" @@ -39,22 +40,6 @@ void AddChromeToMediaPlayerList() { } -// Update shortcuts that are created by chrome.exe during first run, but -// we take care of updating them in case the location of chrome.exe changes. -void UpdateChromeExeShortcuts(const std::wstring& chrome_exe) { - std::wstring desktop_shortcut, ql_shortcut, shortcut_name; - if (!ShellUtil::GetQuickLaunchPath(&ql_shortcut) || - !ShellUtil::GetDesktopPath(&desktop_shortcut) || - !ShellUtil::GetChromeShortcutName(&shortcut_name)) - return; - file_util::AppendToPath(&ql_shortcut, shortcut_name); - file_util::AppendToPath(&desktop_shortcut, shortcut_name); - - // Go ahead and update the shortcuts if they exist. - ShellUtil::UpdateChromeShortcut(chrome_exe, ql_shortcut, false); - ShellUtil::UpdateChromeShortcut(chrome_exe, desktop_shortcut, false); -} - // This method creates Chrome shortcuts in Start->Programs for all users or // only for current user depending on whether it is system wide install or // user only install. @@ -94,7 +79,7 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, // - The shortcut already exists in case of updates (user may have deleted // shortcuts since our install. So on updates we only update if shortcut // already exists) - bool ret1 = true; + bool ret = true; std::wstring chrome_link(shortcut_path); // Chrome link (launches Chrome) file_util::AppendToPath(&chrome_link, product_name + L".lnk"); std::wstring chrome_exe(install_path); // Chrome link target @@ -106,15 +91,16 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, file_util::CreateDirectoryW(shortcut_path); LOG(INFO) << "Creating shortcut to " << chrome_exe << " at " << chrome_link; - ShellUtil::UpdateChromeShortcut(chrome_exe, chrome_link, true); + ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, chrome_link, true); } else if (file_util::PathExists(chrome_link)) { LOG(INFO) << "Updating shortcut at " << chrome_link << " to point to " << chrome_exe; - ShellUtil::UpdateChromeShortcut(chrome_exe, chrome_link, false); + ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, + chrome_link, + false); // do not create new } // Create/update uninstall link - bool ret2 = true; std::wstring uninstall_link(shortcut_path); // Uninstall Chrome link file_util::AppendToPath(&uninstall_link, dist->GetUninstallLinkName() + L".lnk"); @@ -136,19 +122,33 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, LOG(INFO) << "Creating/updating uninstall link at " << uninstall_link; std::wstring target_folder = file_util::GetDirectoryFromPath(install_path); - ret2 = file_util::CreateShortcutLink(setup_exe.c_str(), - uninstall_link.c_str(), - target_folder.c_str(), - arguments.c_str(), - NULL, - setup_exe.c_str(), - 0); + ret = ret && file_util::CreateShortcutLink(setup_exe.c_str(), + uninstall_link.c_str(), + target_folder.c_str(), + arguments.c_str(), + NULL, setup_exe.c_str(), 0); } - // Update Desktop and Quick Launch shortcuts (only if they already exist) - UpdateChromeExeShortcuts(chrome_exe); + // Update Desktop and Quick Launch shortcuts. If --create-new-shortcuts + // is specified we want to create them, otherwise we update them only if + // they exist. + bool create = false; // Only update; do not create, if they do not exist + CommandLine cmd_line; + if (cmd_line.HasSwitch(installer_util::switches::kCreateAllShortcuts)) + create = true; + if (system_install) { + ret = ret && ShellUtil::CreateChromeDesktopShortcut(chrome_exe, + ShellUtil::SYSTEM_LEVEL, create); + ret = ret && ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe, + ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL, create); + } else { + ret = ret && ShellUtil::CreateChromeDesktopShortcut(chrome_exe, + ShellUtil::CURRENT_USER, create); + ret = ret && ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe, + ShellUtil::CURRENT_USER, create); + } - return ret1 && ret2; + return ret; } } // namespace |