| Index: chrome/installer/util/auto_launch_util.cc
|
| ===================================================================
|
| --- chrome/installer/util/auto_launch_util.cc (revision 132169)
|
| +++ chrome/installer/util/auto_launch_util.cc (working copy)
|
| @@ -52,8 +52,9 @@
|
| ASCIIToWide("_") + ASCIIToWide(hash_string);
|
| }
|
|
|
| -bool WillLaunchAtLogin(const FilePath& application_path,
|
| - const string16& profile_directory) {
|
| +bool WillLaunchAtLoginWithSwitch(const FilePath& application_path,
|
| + const string16& profile_directory,
|
| + const std::string& command_line_switch) {
|
| string16 key_name(ProfileToKeyName(profile_directory));
|
| string16 autolaunch;
|
| if (!base::win::ReadCommandFromAutoRun(
|
| @@ -70,16 +71,35 @@
|
| }
|
| chrome_exe = chrome_exe.Append(installer::kChromeExe);
|
|
|
| - return autolaunch.find(chrome_exe.value()) != string16::npos;
|
| + if (autolaunch.find(chrome_exe.value()) == string16::npos)
|
| + return false;
|
| +
|
| + return command_line_switch.empty() ||
|
| + autolaunch.find(ASCIIToUTF16(command_line_switch)) != string16::npos;
|
| }
|
|
|
| -void SetWillLaunchAtLogin(bool auto_launch,
|
| - const FilePath& application_path,
|
| - const string16& profile_directory) {
|
| +void SetWillLaunchAtLogin(const FilePath& application_path,
|
| + const string16& profile_directory,
|
| + FlagSetting auto_start_feature,
|
| + FlagSetting background_mode) {
|
| string16 key_name(ProfileToKeyName(profile_directory));
|
|
|
| + // Check which feature should be enabled.
|
| + bool auto_start =
|
| + auto_start_feature == FLAG_ENABLE ||
|
| + (auto_start_feature == FLAG_PRESERVE &&
|
| + WillLaunchAtLoginWithSwitch(application_path,
|
| + profile_directory,
|
| + switches::kAutoLaunchAtStartup));
|
| + bool in_background =
|
| + background_mode == FLAG_ENABLE ||
|
| + (background_mode == FLAG_PRESERVE &&
|
| + WillLaunchAtLoginWithSwitch(application_path,
|
| + profile_directory,
|
| + switches::kNoStartupWindow));
|
| +
|
| // TODO(finnur): Convert this into a shortcut, instead of using the Run key.
|
| - if (auto_launch) {
|
| + if (auto_start || in_background) {
|
| FilePath path(application_path);
|
| if (path.empty()) {
|
| if (!PathService::Get(base::DIR_EXE, &path)) {
|
| @@ -91,25 +111,33 @@
|
| cmd_line += path.value();
|
| cmd_line += ASCIIToUTF16("\\");
|
| cmd_line += installer::kChromeExe;
|
| - cmd_line += ASCIIToUTF16("\" --");
|
| - cmd_line += ASCIIToUTF16(switches::kAutoLaunchAtStartup);
|
| + cmd_line += ASCIIToUTF16("\"");
|
|
|
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
| - if (command_line.HasSwitch(switches::kUserDataDir)) {
|
| + if (in_background) {
|
| cmd_line += ASCIIToUTF16(" --");
|
| - cmd_line += ASCIIToUTF16(switches::kUserDataDir);
|
| + cmd_line += ASCIIToUTF16(switches::kNoStartupWindow);
|
| + }
|
| + if (auto_start) {
|
| + cmd_line += ASCIIToUTF16(" --");
|
| + cmd_line += ASCIIToUTF16(switches::kAutoLaunchAtStartup);
|
| +
|
| + const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
| + if (command_line.HasSwitch(switches::kUserDataDir)) {
|
| + cmd_line += ASCIIToUTF16(" --");
|
| + cmd_line += ASCIIToUTF16(switches::kUserDataDir);
|
| + cmd_line += ASCIIToUTF16("=\"");
|
| + cmd_line +=
|
| + command_line.GetSwitchValuePath(switches::kUserDataDir).value();
|
| + cmd_line += ASCIIToUTF16("\"");
|
| + }
|
| +
|
| + cmd_line += ASCIIToUTF16(" --");
|
| + cmd_line += ASCIIToUTF16(switches::kProfileDirectory);
|
| cmd_line += ASCIIToUTF16("=\"");
|
| - cmd_line +=
|
| - command_line.GetSwitchValuePath(switches::kUserDataDir).value();
|
| + cmd_line += profile_directory;
|
| cmd_line += ASCIIToUTF16("\"");
|
| }
|
|
|
| - cmd_line += ASCIIToUTF16(" --");
|
| - cmd_line += ASCIIToUTF16(switches::kProfileDirectory);
|
| - cmd_line += ASCIIToUTF16("=\"");
|
| - cmd_line += profile_directory;
|
| - cmd_line += ASCIIToUTF16("\"");
|
| -
|
| base::win::AddCommandToAutoRun(
|
| HKEY_CURRENT_USER, key_name, cmd_line);
|
| } else {
|
|
|