Chromium Code Reviews| Index: chrome/installer/setup/install.cc |
| diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc |
| index 2f4029c64e99a52944df42e07fec087eb199eb6c..8e2831476c8fef2c2fae8da73c8ca2fdd8cee50a 100644 |
| --- a/chrome/installer/setup/install.cc |
| +++ b/chrome/installer/setup/install.cc |
| @@ -22,6 +22,7 @@ |
| #include "base/win/shortcut.h" |
| #include "base/win/windows_version.h" |
| #include "chrome/common/chrome_constants.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/installer/setup/setup_constants.h" |
| #include "chrome/installer/setup/install_worker.h" |
| #include "chrome/installer/util/auto_launch_util.h" |
| @@ -31,6 +32,7 @@ |
| #include "chrome/installer/util/google_update_constants.h" |
| #include "chrome/installer/util/helper.h" |
| #include "chrome/installer/util/install_util.h" |
| +#include "chrome/installer/util/installation_state.h" |
| #include "chrome/installer/util/master_preferences.h" |
| #include "chrome/installer/util/master_preferences_constants.h" |
| #include "chrome/installer/util/set_reg_value_work_item.h" |
| @@ -270,6 +272,28 @@ void CleanupLegacyShortcuts(const InstallerState& installer_state, |
| file_util::Delete(uninstall_shortcut_path, false); |
| } |
| +// Returns the appropriate shortcut operations for App Launcher, |
| +// based on state of installation and master preference. |
| +installer::InstallShortcutOperation GetAppLauncherShortcutOperation( |
| + const InstallationState& original_state, |
| + const InstallerState& installer_state, |
| + int version_compare) { |
| + const installer::ProductState* original_app_host_state = |
| + original_state.GetProductState(installer_state.system_install(), |
| + BrowserDistribution::CHROME_APP_HOST); |
| + bool already_had_app_launcher = original_app_host_state && |
| + original_app_host_state->channel().IsAppLauncher(); |
|
grt (UTC plus 2)
2012/10/25 14:46:53
using the channel id like this will lead to proble
huangs
2012/10/29 21:15:16
Done.
|
| + |
| + if (!already_had_app_launcher) |
| + return installer::INSTALL_SHORTCUT_CREATE_ALL; |
| + |
| + if (version_compare >= 0) |
| + return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; |
| + |
| + LOG(ERROR) << "Not sure how we got here"; |
| + return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; |
| +} |
| + |
| } // end namespace |
| namespace installer { |
| @@ -347,26 +371,30 @@ void CreateOrUpdateShortcuts(const InstallerState& installer_state, |
| InstallShortcutOperation install_operation, |
| bool alternate_desktop_shortcut) { |
| // TODO(tommi): Change this function to use WorkItemList. |
| - DCHECK(product.is_chrome()); |
| + DCHECK(product.is_chrome() || product.is_chrome_app_host()); |
| BrowserDistribution* dist = product.distribution(); |
| - const FilePath chrome_exe( |
| - installer_state.target_path().Append(installer::kChromeExe)); |
| ShellUtil::ShellChange install_level = |
| installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : |
| ShellUtil::CURRENT_USER; |
| + // |base_properties|: The basic properties to set on every shortcut installed |
| + // (to be refined on a per-shortcut basis). |
| + ShellUtil::ChromeShortcutProperties base_properties(install_level); |
| + |
| + base_properties.set_chrome_exe( |
| + installer_state.target_path().Append(installer::kChromeExe)); |
| + if (product.is_chrome_app_host()) { |
|
erikwright (departed)
2012/10/25 02:23:03
needs to be app_host.exe, not chrome.exe
huangs
2012/10/29 21:15:16
Done. (Deferring to different CL).
|
| + // Should consult AppListController::GetAppListCommandLine(). |
| + // TODO(huangs): Append switches::kUserDataDir, perhaps? |
|
benwells
2012/10/25 04:50:51
I don't think you can put kUserDataDir here as you
huangs
2012/10/29 21:15:16
Nope. I was looking at
AppListController::GetAppL
|
| + base_properties.set_arguments( |
| + string16(L"--").append(ASCIIToUTF16(::switches::kShowAppList))); |
|
grt (UTC plus 2)
2012/10/25 14:46:53
i don't like this hacky prepend. please use Comma
huangs
2012/10/29 21:15:16
Done. However, note that this leads to 2 spaces,
grt (UTC plus 2)
2012/10/30 13:02:55
If the spaces cause no harm, just do the simple th
|
| + } |
| // The default operation on update is to overwrite shortcuts with the |
| // currently desired properties, but do so only for shortcuts that still |
| // exist. |
| ShellUtil::ChromeShortcutOperation shortcut_operation = |
| ShellUtil::SHORTCUT_REPLACE_EXISTING; |
| - |
| - // |base_properties|: The basic properties to set on every shortcut installed |
| - // (to be refined on a per-shortcut basis). |
| - ShellUtil::ChromeShortcutProperties base_properties(install_level); |
| - base_properties.set_chrome_exe(chrome_exe); |
| - |
| // If |install_operation| is INSTALL_SHORTCUT_CREATE_ALL, create optional |
| // shortcuts (Desktop and Quick Launch) immediately; otherwise delay their |
| // creation until first run. |
| @@ -401,7 +429,7 @@ void CreateOrUpdateShortcuts(const InstallerState& installer_state, |
| ShellUtil::ChromeShortcutProperties start_menu_properties(base_properties); |
| // IMPORTANT: Only the default (no arguments and default browserappid) browser |
| - // shortcut in the Start menu (Start screen on Win8+) should be made dual |
| + // shortcut in the Start menu (Start screen on Win8+) should be made dual |
| // mode. |
| start_menu_properties.set_dual_mode(true); |
| if (shortcut_operation == ShellUtil::SHORTCUT_CREATE_ALWAYS) |
| @@ -497,8 +525,28 @@ InstallStatus InstallOrUpdateProduct( |
| if (result == FIRST_INSTALL_SUCCESS && !prefs_path.empty()) |
| CopyPreferenceFileForFirstRun(installer_state, prefs_path); |
| - // Currently this only creates shortcuts for Chrome, but for other products |
| - // we might want to create shortcuts. |
| + FilePath setup_exe(installer_state.GetInstallerDirectory(new_version) |
| + .Append(setup_path.BaseName())); |
| + |
| + // Creates shortcuts for App Launcher. |
| + const Product* app_host_install = |
| + installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); |
| + if (app_host_install && app_host_install->HasOption(kOptionAppLauncher)) { |
| + installer_state.UpdateStage(installer::CREATING_SHORTCUTS); |
| + |
| + InstallShortcutOperation app_launcher_shortcut_operation = |
| + GetAppLauncherShortcutOperation( |
| + original_state, installer_state, |
| + new_version.CompareTo(*existing_version)); |
| + |
| + bool alt_shortcut = false; |
| + prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); |
| + |
| + CreateOrUpdateShortcuts(installer_state, setup_exe, *app_host_install, |
| + app_launcher_shortcut_operation, alt_shortcut); |
| + } |
| + |
| + // Creates shortcuts for Chrome. |
| const Product* chrome_install = |
| installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| if (chrome_install) { |