Index: chrome/installer/setup/install.cc |
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc |
index b8ebe94fd372897dac60815ae6fae078910fd018..32e7cc922daa83cb8a34a526bc3e438f081d399a 100644 |
--- a/chrome/installer/setup/install.cc |
+++ b/chrome/installer/setup/install.cc |
@@ -29,6 +29,7 @@ |
#include "chrome/installer/setup/setup_constants.h" |
#include "chrome/installer/util/auto_launch_util.h" |
#include "chrome/installer/util/browser_distribution.h" |
+#include "chrome/installer/util/chrome_app_host_distribution.h" |
#include "chrome/installer/util/create_reg_key_work_item.h" |
#include "chrome/installer/util/delete_after_reboot_helper.h" |
#include "chrome/installer/util/google_update_constants.h" |
@@ -79,6 +80,9 @@ void LogShortcutOperation(ShellUtil::ShortcutLocation location, |
case ShellUtil::SHORTCUT_LOCATION_START_MENU: |
message.append("Start menu "); |
break; |
+ case ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT: |
gab
2013/05/15 22:42:20
We will never create Chrome shortcuts at the root,
huangs
2013/05/17 20:59:24
Removing.
|
+ message.append("Start menu root "); |
+ break; |
default: |
NOTREACHED(); |
} |
@@ -247,9 +251,9 @@ installer::InstallStatus InstallNewVersion( |
// Launch shortcut. Both of these were created prior to Chrome 24; in Chrome 24, |
// the uninstall shortcut was removed and the Default user Quick Launch shortcut |
// was replaced by per-user shortcuts created via Active Setup. |
-void CleanupLegacyShortcuts(const InstallerState& installer_state, |
- BrowserDistribution* dist, |
- const base::FilePath& chrome_exe) { |
+void CleanupLegacyChromeShortcuts(const InstallerState& installer_state, |
+ BrowserDistribution* dist, |
+ const base::FilePath& chrome_exe) { |
ShellUtil::ShellChange shortcut_level = installer_state.system_install() ? |
ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER; |
base::FilePath uninstall_shortcut_path; |
@@ -274,6 +278,10 @@ installer::InstallShortcutOperation GetAppLauncherShortcutOperation( |
const installer::ProductState* original_app_host_state = |
original_state.GetProductState(installer_state.system_install(), |
BrowserDistribution::CHROME_APP_HOST); |
+ if (installer_state.need_to_migrate_legacy_app_launcher() || |
+ installer_state.create_app_launcher_shortcuts()) |
+ return installer::INSTALL_SHORTCUT_CREATE_ALL; |
gab
2013/05/15 22:42:20
nit: wrap in {}
huangs
2013/05/17 20:59:24
Done.
|
+ |
bool app_launcher_exists = original_app_host_state && |
original_app_host_state->uninstall_command() |
.HasSwitch(installer::switches::kChromeAppLauncher); |
@@ -283,6 +291,61 @@ installer::InstallShortcutOperation GetAppLauncherShortcutOperation( |
return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; |
} |
+// As of M29, App Launcher is unified with Chrome. app_host.exe is deleted, and |
+// all shortcuts that target app_host.exe must now target chrome.exe. |
+// Shortcuts to the App Launcher also require icons update. |
+void MigrateLegacyAppLauncherShortcuts(const InstallerState& installer_state) { |
+ LegacyChromeAppHostDistribution legacy_dist; |
+ BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
+ BrowserDistribution::CHROME_APP_HOST); |
+ base::FilePath app_host_exe( |
+ installer_state.target_path().Append(installer::kChromeAppHostExe)); |
+ base::FilePath chrome_exe( |
+ installer_state.target_path().Append(installer::kChromeExe)); |
+ |
+ // Remove deprecated start menu folder "Google Chrome App Launcher". |
+ ShellUtil::RemoveShortcuts( |
+ ShellUtil::SHORTCUT_LOCATION_START_MENU, &legacy_dist, |
+ ShellUtil::CURRENT_USER, app_host_exe); |
+ |
+ VLOG(1) << "Migrating legacy App Launcher shortcuts."; |
+ ShellUtil::ShortcutLocation update_location_list[] = { |
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, |
+ ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, |
+ ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, |
+ ShellUtil::SHORTCUT_LOCATION_TASKBAR_PINS, |
+ ShellUtil::SHORTCUT_LOCATION_APP_SHORTCUTS |
+ }; |
+ |
+ // Using wild card in case duplicate shortcuts exist. |
+ string16 name_filter_main(dist->GetAppShortCutName() + L"*" + |
+ installer::kLnkExt); |
+ |
+ ShellUtil::ShortcutProperties updated_properties_app_host_exe( |
+ installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : |
+ ShellUtil::CURRENT_USER); |
+ updated_properties_app_host_exe.set_target(chrome_exe); |
+ updated_properties_app_host_exe.set_icon( |
+ installer_state.target_path().Append(dist->GetIconFilename()), |
+ dist->GetIconIndex()); |
+ |
+ ShellUtil::ShortcutProperties updated_properties_user_generated( |
+ installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : |
+ ShellUtil::CURRENT_USER); |
+ updated_properties_user_generated.set_target(chrome_exe); |
+ |
+ for (int i = 0; i < arraysize(update_location_list); ++i) { |
+ // Migrate App Launcher shortcuts (executable and icon changes). |
+ ShellUtil::UpdateShortcutsFilteredByName( |
+ update_location_list[i], dist, ShellUtil::CURRENT_USER, |
+ name_filter_main, app_host_exe, updated_properties_app_host_exe); |
+ // Migrate user-generated shortcuts (executable changes only). |
+ ShellUtil::UpdateShortcuts( |
+ update_location_list[i], dist, ShellUtil::CURRENT_USER, |
+ app_host_exe, updated_properties_user_generated); |
+ } |
+} |
+ |
} // end namespace |
namespace installer { |
@@ -532,20 +595,24 @@ InstallStatus InstallOrUpdateProduct( |
installer_state.UpdateStage(installer::CREATING_SHORTCUTS); |
+ InstallShortcutLevel install_level = installer_state.system_install() ? |
+ ALL_USERS : CURRENT_USER; |
+ const base::FilePath chrome_exe( |
+ installer_state.target_path().Append(kChromeExe)); |
+ |
const Product* app_launcher_product = |
installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST); |
// Creates shortcuts for App Launcher. |
if (app_launcher_product) { |
- // TODO(huangs): Remove this check once we have system-level App Host. |
- DCHECK(!installer_state.system_install()); |
- const base::FilePath app_host_exe( |
- installer_state.target_path().Append(kChromeAppHostExe)); |
- InstallShortcutOperation app_launcher_shortcut_operation = |
- GetAppLauncherShortcutOperation(original_state, installer_state); |
- |
- // Always install per-user shortcuts for App Launcher. |
- CreateOrUpdateShortcuts(app_host_exe, *app_launcher_product, prefs, |
- CURRENT_USER, app_launcher_shortcut_operation); |
+ if (installer_state.need_to_migrate_legacy_app_launcher()) { |
+ MigrateLegacyAppLauncherShortcuts(installer_state); |
grt (UTC plus 2)
2013/05/16 14:55:52
Are legacy shortcuts only per-user shortcuts?
huangs
2013/05/17 20:59:24
Yes for the installer, I think so, also for user-c
|
+ } |
+ if (installer_state.create_app_launcher_shortcuts()) { |
+ InstallShortcutOperation app_launcher_shortcut_operation = |
+ GetAppLauncherShortcutOperation(original_state, installer_state); |
+ CreateOrUpdateShortcuts(chrome_exe, *app_launcher_product, prefs, |
+ install_level, app_launcher_shortcut_operation); |
gab
2013/05/15 22:42:20
I would prefer that we keep installing App Launche
huangs
2013/05/17 20:59:24
"per-user shortcuts" doesn't mean what I thought i
|
+ } |
} |
const Product* chrome_product = |
@@ -553,18 +620,13 @@ InstallStatus InstallOrUpdateProduct( |
// Creates shortcuts for Chrome. |
if (chrome_product) { |
BrowserDistribution* chrome_dist = chrome_product->distribution(); |
- const base::FilePath chrome_exe( |
- installer_state.target_path().Append(kChromeExe)); |
- CleanupLegacyShortcuts(installer_state, chrome_dist, chrome_exe); |
+ CleanupLegacyChromeShortcuts(installer_state, chrome_dist, chrome_exe); |
// Install per-user shortcuts on user-level installs and all-users |
// shortcuts on system-level installs. Note that Active Setup will take |
// care of installing missing per-user shortcuts on system-level install |
// (i.e., quick launch, taskbar pin, and possibly deleted all-users |
// shortcuts). |
- InstallShortcutLevel install_level = installer_state.system_install() ? |
- ALL_USERS : CURRENT_USER; |
- |
InstallShortcutOperation install_operation = |
INSTALL_SHORTCUT_REPLACE_EXISTING; |
if (result == installer::FIRST_INSTALL_SUCCESS || |
@@ -685,11 +747,11 @@ void HandleActiveSetupForBrowser(const base::FilePath& installation_root, |
} |
bool InstallFromWebstore(const std::string& app_code) { |
gab
2013/05/15 22:42:20
I can't find any callers of this in codesearch...
grt (UTC plus 2)
2013/05/16 14:55:52
It's called by setup_main.cc, which may not be ind
huangs
2013/05/17 20:59:24
No-op.
huangs
2013/05/17 20:59:24
No-op.
|
- base::FilePath app_host_path(chrome_launcher_support::GetAnyAppHostPath()); |
- if (app_host_path.empty()) |
+ base::FilePath chrome_path(chrome_launcher_support::GetAnyChromePath()); |
+ if (chrome_path.empty()) |
return false; |
- CommandLine cmd(app_host_path); |
+ CommandLine cmd(chrome_path); |
cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); |
VLOG(1) << "App install command: " << cmd.GetCommandLineString(); |
return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |