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

Unified Diff: chrome/installer/setup/install.cc

Issue 11359013: Adding App Launcher shortcuts on install. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanups; adding DCHECK to ensure App Launcher-releated stuff are for user-level. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/install.cc
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index d9e2c18564e50eb41355fa45f528ba8e4ece30f5..6b23a994a11ff91b4cee8e8c572bffaea6a806e5 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -23,6 +23,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/install_worker.h"
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/util/auto_launch_util.h"
@@ -131,7 +132,7 @@ void AddChromeToMediaPlayerList() {
LOG(ERROR) << "Could not add Chrome to media player inclusion list.";
}
-// Copy master preferences file provided to installer, in the same folder
+// Copy master_preferences file provided to installer, in the same folder
// as chrome.exe so Chrome first run can find it. This function will be called
// only on the first install of Chrome.
void CopyPreferenceFileForFirstRun(const InstallerState& installer_state,
@@ -139,7 +140,7 @@ void CopyPreferenceFileForFirstRun(const InstallerState& installer_state,
FilePath prefs_dest_path(installer_state.target_path().AppendASCII(
installer::kDefaultMasterPrefs));
if (!file_util::CopyFile(prefs_source_path, prefs_dest_path)) {
- VLOG(1) << "Failed to copy master preferences from:"
+ VLOG(1) << "Failed to copy master_preferences from:"
<< prefs_source_path.value() << " gle: " << ::GetLastError();
}
}
@@ -284,6 +285,26 @@ void CleanupLegacyShortcuts(const InstallerState& installer_state,
}
}
+// Returns the appropriate shortcut operations for App Launcher,
+// based on state of installation and master_preferences.
+installer::InstallShortcutOperation GetAppLauncherShortcutOperation(
+ const InstallationState& original_state,
+ const InstallerState& installer_state) {
+ // Remove this check once we have system-level App Host.
+ DCHECK(!installer_state.system_install());
+
+ const installer::ProductState* original_app_host_state =
+ original_state.GetProductState(installer_state.system_install(),
+ BrowserDistribution::CHROME_APP_HOST);
+ bool app_launcher_exists = original_app_host_state &&
+ CommandLine(original_app_host_state->uninstall_command())
+ .HasSwitch(installer::switches::kChromeAppLauncher);
+ if (!app_launcher_exists)
+ return installer::INSTALL_SHORTCUT_CREATE_ALL;
+
+ return installer::INSTALL_SHORTCUT_REPLACE_EXISTING;
+}
+
} // end namespace
namespace installer {
@@ -356,13 +377,13 @@ bool CreateVisualElementsManifest(const FilePath& src_path,
}
void CreateOrUpdateShortcuts(
- const FilePath& chrome_exe,
+ const FilePath& target,
const Product& product,
const MasterPreferences& prefs,
InstallShortcutLevel install_level,
InstallShortcutOperation install_operation) {
// TODO(tommi): Change this function to use WorkItemList.
- DCHECK(product.is_chrome());
+ DCHECK(product.is_chrome() || product.is_chrome_app_host());
// Extract shortcut preferences from |prefs|.
bool do_not_create_desktop_shortcut = false;
@@ -376,9 +397,6 @@ void CreateOrUpdateShortcuts(
&alternate_desktop_shortcut);
BrowserDistribution* dist = product.distribution();
- // Shortcuts are always installed per-user unless specified.
- ShellUtil::ShellChange shortcut_level = (install_level == ALL_USERS ?
- ShellUtil::SYSTEM_LEVEL : ShellUtil::CURRENT_USER);
// The default operation on update is to overwrite shortcuts with the
// currently desired properties, but do so only for shortcuts that still
@@ -397,10 +415,25 @@ void CreateOrUpdateShortcuts(
break;
}
+ // Shortcuts are always installed per-user unless specified.
+ ShellUtil::ShellChange shortcut_level = (install_level == ALL_USERS ?
+ 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(shortcut_level);
- base_properties.set_chrome_exe(chrome_exe);
+ base_properties.set_chrome_exe(target);
+
+ if (product.is_chrome_app_host()) {
+ DCHECK(product.HasOption(kOptionAppHostIsLauncher));
+ // Adding command line arguments to app_host.exe.
+ // This is also done in AppListController::GetAppListCommandLine(),
+ // but we don't need the extra user data dir info appended.
+ CommandLine app_host_args(CommandLine::NO_PROGRAM);
+ app_host_args.AppendSwitch(::switches::kShowAppList);
+ // TODO(huangs): Add routine to CommandLine so we can do this directly.
+ base_properties.set_arguments(app_host_args.GetCommandLineString());
+ }
if (!do_not_create_desktop_shortcut ||
shortcut_operation == ShellUtil::SHORTCUT_REPLACE_EXISTING) {
@@ -527,14 +560,32 @@ 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.
- const Product* chrome_install =
+ const Product* app_launcher_product =
+ installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST);
+ const Product* chrome_product =
installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);
- if (chrome_install) {
+
+ bool process_app_launcher_shortcuts = (app_launcher_product != NULL) &&
+ app_launcher_product->HasOption(kOptionAppHostIsLauncher);
+ bool process_chrome_shortcuts = (chrome_product != NULL);
+
+ if (process_app_launcher_shortcuts || process_chrome_shortcuts) {
erikwright (departed) 2012/11/01 20:43:36 personally I would say don't bother with this 'if'
grt (UTC plus 2) 2012/11/02 19:55:30 +1
huangs 2012/11/02 21:05:10 Done.
installer_state.UpdateStage(installer::CREATING_SHORTCUTS);
+ }
+
+ if (process_app_launcher_shortcuts) {
+ const 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);
+ }
- BrowserDistribution* dist = chrome_install->distribution();
+ if (process_chrome_shortcuts) {
gab 2012/11/02 04:19:58 I don't like the name "process_chrome_shortcuts" a
huangs 2012/11/02 21:05:10 Got rid of the variable. The original comment was
+ BrowserDistribution* dist = chrome_product->distribution();
const FilePath chrome_exe(
installer_state.target_path().Append(kChromeExe));
CleanupLegacyShortcuts(installer_state, dist, chrome_exe);
@@ -548,12 +599,12 @@ InstallStatus InstallOrUpdateProduct(
if (installer_state.system_install()) {
// Update existing all-users shortcuts for legacy installs.
- CreateOrUpdateShortcuts(chrome_exe, *chrome_install, prefs, ALL_USERS,
+ CreateOrUpdateShortcuts(chrome_exe, *chrome_product, prefs, ALL_USERS,
INSTALL_SHORTCUT_REPLACE_EXISTING);
}
// Always install per-user shortcuts (even on system-level installs where
// we do so for the installing user instead of waiting for Active Setup).
- CreateOrUpdateShortcuts(chrome_exe, *chrome_install, prefs, CURRENT_USER,
+ CreateOrUpdateShortcuts(chrome_exe, *chrome_product, prefs, CURRENT_USER,
install_operation);
bool make_chrome_default = false;
@@ -573,13 +624,13 @@ InstallStatus InstallOrUpdateProduct(
installer_state.UpdateStage(installer::REGISTERING_CHROME);
- RegisterChromeOnMachine(installer_state, *chrome_install,
+ RegisterChromeOnMachine(installer_state, *chrome_product,
make_chrome_default || force_chrome_default_for_user);
if (result == FIRST_INSTALL_SUCCESS) {
installer_state.UpdateStage(installer::CONFIGURE_AUTO_LAUNCH);
- // Add auto-launch key if specified in master preferences.
+ // Add auto-launch key if specified in master_preferences.
bool auto_launch_chrome = false;
prefs.GetBool(
installer::master_preferences::kAutoLaunchChrome,

Powered by Google App Engine
This is Rietveld 408576698