summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_shutdown.cc
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 15:41:58 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 15:41:58 +0000
commit4d2605ce1b6cc6c5a81ac62e39d84d128f2bcd6f (patch)
treef6419bed3d800c195d2d981fc14e3a24e979a1b3 /chrome/browser/browser_shutdown.cc
parent59461d2076ab5bbe6274d07d7e7855643f64862c (diff)
downloadchromium_src-4d2605ce1b6cc6c5a81ac62e39d84d128f2bcd6f.zip
chromium_src-4d2605ce1b6cc6c5a81ac62e39d84d128f2bcd6f.tar.gz
chromium_src-4d2605ce1b6cc6c5a81ac62e39d84d128f2bcd6f.tar.bz2
Make sure restart due to Upgrade Notification works, even if the browser was started through ShellExecute (with a switch argument terminator).
BUG=46182 TEST=Launch Chrome on Windows by double clicking on a .htm file. Wait for Chrome to be upgraded in the background, select Update Chrome from Wrench menu and make sure your session is properly restored (even if Restore Last Session is not set). Review URL: http://codereview.chromium.org/2868063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_shutdown.cc')
-rw-r--r--chrome/browser/browser_shutdown.cc35
1 files changed, 27 insertions, 8 deletions
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index 7e5fded..e8b668b 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -164,18 +164,37 @@ void Shutdown() {
if (restart_last_session) {
#if !defined(OS_CHROMEOS)
- // Make sure to relaunch the browser with the same command line and add
- // Restore Last Session flag if session restore is not set.
- CommandLine command_line(*CommandLine::ForCurrentProcess());
- if (!command_line.HasSwitch(switches::kRestoreLastSession))
- command_line.AppendSwitch(switches::kRestoreLastSession);
+ // Make sure to relaunch the browser with the original command line plus
+ // the Restore Last Session flag. Note that Chrome can be launched (ie.
+ // through ShellExecute on Windows) with a switch argument terminator at
+ // the end (double dash, as described in b/1366444) plus a URL,
+ // which prevents us from appending to the command line directly (issue
+ // 46182). We therefore use GetSwitches to copy the command line (it stops
+ // at the switch argument terminator).
+ CommandLine old_cl(*CommandLine::ForCurrentProcess());
+ scoped_ptr<CommandLine> new_cl(new CommandLine(old_cl.GetProgram()));
+ std::map<std::string, CommandLine::StringType> switches =
+ old_cl.GetSwitches();
+ // Append the old switches to the new command line.
+ for (std::map<std::string, CommandLine::StringType>::const_iterator i =
+ switches.begin(); i != switches.end(); ++i) {
+ CommandLine::StringType switch_value = i->second;
+ if (!switch_value.empty())
+ new_cl->AppendSwitchWithValue(i->first, i->second);
+ else
+ new_cl->AppendSwitch(i->first);
+ }
+ // Ensure restore last session is set.
+ if (!new_cl->HasSwitch(switches::kRestoreLastSession))
+ new_cl->AppendSwitch(switches::kRestoreLastSession);
+
#if defined(OS_WIN) || defined(OS_LINUX)
- Upgrade::RelaunchChromeBrowser(command_line);
+ Upgrade::RelaunchChromeBrowser(*new_cl.get());
#endif // defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_MACOSX)
- command_line.AppendSwitch(switches::kActivateOnLaunch);
- base::LaunchApp(command_line, false, false, NULL);
+ new_cl->AppendSwitch(switches::kActivateOnLaunch);
+ base::LaunchApp(*new_cl.get(), false, false, NULL);
#endif // defined(OS_MACOSX)
#else