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

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: Created 8 years, 2 months 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..52c5b24fef6234f308b5f65f7c6bdbd586210f39 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"
@@ -284,6 +285,23 @@ void CleanupLegacyShortcuts(const InstallerState& installer_state,
}
}
+// Returns the appropriate shortcut operations for App Launcher,
+// based on state of installation and master preference.
gab 2012/11/01 04:46:19 s/master preference/master_preferences
huangs 2012/11/01 19:20:38 Done. Also s/master preference/master_preferences
+installer::InstallShortcutOperation GetAppLauncherShortcutOperation(
+ const InstallationState& original_state,
+ const InstallerState& installer_state) {
+ 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()).
gab 2012/11/01 04:46:19 nit: '.' on the next line to make it more obvious
huangs 2012/11/01 19:20:38 Done.
+ HasSwitch(installer::switches::kChromeAppLauncher);
gab 2012/11/01 04:46:19 I feel like checking the presence of a flag on the
huangs 2012/11/01 19:20:38 I followed grt@'s recommendation regarding using u
erikwright (departed) 2012/11/01 20:02:20 This is standard practice. The uninstall string is
gab 2012/11/02 04:19:58 Ok, sgtm.
+ if (!app_launcher_exists)
+ return installer::INSTALL_SHORTCUT_CREATE_ALL;
+
+ return installer::INSTALL_SHORTCUT_REPLACE_EXISTING;
+}
+
} // end namespace
namespace installer {
@@ -356,13 +374,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 +394,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 +412,24 @@ void CreateOrUpdateShortcuts(
break;
}
+ // Shortcuts are always installed per-user unless specified.
erikwright (departed) 2012/11/01 01:21:50 any reason for this moving from above?
huangs 2012/11/01 19:20:38 shortcut_level exists solely to initialize base_pr
gab 2012/11/02 04:19:58 Ah right, it used to be used for other stuff that
+ 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);
gab 2012/11/01 04:46:19 The reason the ShellUtil::ChromeShortcutProperties
huangs 2012/11/01 19:20:38 I went through the flow, and found app_id is assig
erikwright (departed) 2012/11/01 20:02:20 We agreed F2F on the following: We will rename Sh
gab 2012/11/02 04:19:58 sgtm, though there are more methods than this that
+
+ if (product.is_chrome_app_host()) {
grt (UTC plus 2) 2012/11/01 01:50:04 consider if it makes sense to add to Product and P
huangs 2012/11/01 19:20:38 Eventually App Host and App Launcher will be the s
erikwright (departed) 2012/11/01 20:02:20 Based on the above response to gab@, I suppose we
erikwright (departed) 2012/11/01 20:43:36 What grt meant was all the stuff inside the if ()
gab 2012/11/02 04:19:58 sgtm
grt (UTC plus 2) 2012/11/02 19:55:30 sure
+ DCHECK(product.HasOption(kOptionAppHostIsLauncher));
+ // Should consult AppListController::GetAppListCommandLine().
erikwright (departed) 2012/11/01 01:21:50 Can you provide some context to this comment?
huangs 2012/11/01 19:20:38 In AppListController::GetAppListCommandLine(), a s
+ CommandLine app_host_args(CommandLine::NO_PROGRAM);
+ // This is cleaner than appending strings, but as a result we'll get
erikwright (departed) 2012/11/01 01:21:50 An extra space in the command line does not merit
huangs 2012/11/01 19:20:38 The extra space is really annoying. Can I add an
erikwright (departed) 2012/11/01 20:43:36 Does it require code changes somewhere? If not, wh
gab 2012/11/02 04:19:58 This is probably just a tiny bug in GetCommandLine
+ // 2 spaces: "app_host.exe --show-app-list".
+ app_host_args.AppendSwitch(::switches::kShowAppList);
huangs 2012/10/31 22:09:03 Note the insertion of 2 spaces!
+ base_properties.set_arguments(app_host_args.GetCommandLineString());
gab 2012/11/01 04:46:19 Things like this that are meant as a property for
huangs 2012/11/01 19:20:38 The command line to run the App Launcher is app_h
+ }
if (!do_not_create_desktop_shortcut ||
shortcut_operation == ShellUtil::SHORTCUT_REPLACE_EXISTING) {
@@ -527,8 +556,24 @@ 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.
+ // Creates shortcuts for App Launcher.
+ const Product* app_launcher_product =
+ installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST);
+ if (app_launcher_product &&
+ app_launcher_product->HasOption(kOptionAppHostIsLauncher)) {
+ installer_state.UpdateStage(installer::CREATING_SHORTCUTS);
gab 2012/11/01 04:46:19 Should we introduce a new stage constant? I think
huangs 2012/11/01 19:20:38 Yeah, it's weird to have UpdateState((installer::C
erikwright (departed) 2012/11/01 20:02:20 Let's just set this on line 558. It will encompass
gab 2012/11/02 04:19:58 SGTM, although it might be cleaner if we split the
+
+ 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);
+ }
+
+ // Creates shortcuts for Chrome.
const Product* chrome_install =
installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);
if (chrome_install) {

Powered by Google App Engine
This is Rietveld 408576698