| Index: chrome/browser/ui/browser_init.cc
|
| diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
|
| index 123b07ee9c06fa00fb87e1d36e2966045f53f0c0..4731b1ea836868a827f37bd32972d87a1e992a1a 100644
|
| --- a/chrome/browser/ui/browser_init.cc
|
| +++ b/chrome/browser/ui/browser_init.cc
|
| @@ -1538,13 +1538,15 @@ std::vector<GURL> BrowserInit::GetURLsFromCommandLine(
|
| return urls;
|
| }
|
|
|
| -bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
|
| - const FilePath& cur_dir,
|
| - bool process_startup,
|
| - Profile* profile,
|
| - int* return_code,
|
| - BrowserInit* browser_init) {
|
| - DCHECK(profile);
|
| +bool BrowserInit::ProcessCmdLineImpl(
|
| + const CommandLine& command_line,
|
| + const FilePath& cur_dir,
|
| + bool process_startup,
|
| + Profile* last_active_profile,
|
| + const std::vector<Profile*>& other_profiles,
|
| + int* return_code,
|
| + BrowserInit* browser_init) {
|
| + DCHECK(last_active_profile);
|
| if (process_startup) {
|
| if (command_line.HasSwitch(switches::kDisablePromptOnRepost))
|
| content::NavigationController::DisablePromptOnRepost();
|
| @@ -1574,13 +1576,13 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
|
| base::StringToInt(restore_session_value, &expected_tab_count);
|
| } else {
|
| std::vector<GURL> urls_to_open = GetURLsFromCommandLine(
|
| - command_line, cur_dir, profile);
|
| + command_line, cur_dir, last_active_profile);
|
| expected_tab_count =
|
| std::max(1, static_cast<int>(urls_to_open.size()));
|
| }
|
| if (!CreateAutomationProvider<TestingAutomationProvider>(
|
| testing_channel_id,
|
| - profile,
|
| + last_active_profile,
|
| static_cast<size_t>(expected_tab_count)))
|
| return false;
|
| }
|
| @@ -1594,7 +1596,7 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
|
| // If there are any extra parameters, we expect each one to generate a
|
| // new tab; if there are none then we have no tabs
|
| std::vector<GURL> urls_to_open = GetURLsFromCommandLine(
|
| - command_line, cur_dir, profile);
|
| + command_line, cur_dir, last_active_profile);
|
| size_t expected_tabs =
|
| std::max(static_cast<int>(urls_to_open.size()), 0);
|
| if (expected_tabs == 0)
|
| @@ -1603,12 +1605,12 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
|
| if (command_line.HasSwitch(switches::kChromeFrame)) {
|
| #if !defined(USE_AURA)
|
| if (!CreateAutomationProvider<ChromeFrameAutomationProvider>(
|
| - automation_channel_id, profile, expected_tabs))
|
| + automation_channel_id, last_active_profile, expected_tabs))
|
| return false;
|
| #endif
|
| } else {
|
| if (!CreateAutomationProvider<AutomationProvider>(
|
| - automation_channel_id, profile, expected_tabs))
|
| + automation_channel_id, last_active_profile, expected_tabs))
|
| return false;
|
| }
|
| }
|
| @@ -1617,7 +1619,7 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
|
| // the service process, we do not want to open any browser windows.
|
| if (command_line.HasSwitch(switches::kNotifyCloudPrintTokenExpired)) {
|
| silent_launch = true;
|
| - CloudPrintProxyServiceFactory::GetForProfile(profile)->
|
| + CloudPrintProxyServiceFactory::GetForProfile(last_active_profile)->
|
| ShowTokenExpiredNotification();
|
| }
|
|
|
| @@ -1672,8 +1674,29 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
|
| IS_PROCESS_STARTUP : IS_NOT_PROCESS_STARTUP;
|
| IsFirstRun is_first_run = first_run::IsChromeFirstRun() ?
|
| IS_FIRST_RUN : IS_NOT_FIRST_RUN;
|
| - return browser_init->LaunchBrowser(command_line, profile, cur_dir,
|
| - is_process_startup, is_first_run, return_code);
|
| + // Launch the last active profile with the full command line, and the other
|
| + // profiles without the URLs to launch.
|
| + CommandLine command_line_without_urls(command_line.GetProgram());
|
| + const CommandLine::SwitchMap& switches = command_line.GetSwitches();
|
| + CommandLine::SwitchMap::const_iterator switch_it;
|
| + for (switch_it = switches.begin(); switch_it != switches.end();
|
| + ++switch_it) {
|
| + command_line_without_urls.AppendSwitchNative(switch_it->first,
|
| + switch_it->second);
|
| + }
|
| + std::vector<Profile*>::const_iterator it;
|
| + for (it = other_profiles.begin(); it != other_profiles.end(); ++it) {
|
| + if (*it == last_active_profile)
|
| + continue;
|
| + if (!browser_init->LaunchBrowser(
|
| + command_line_without_urls, *it, cur_dir, is_process_startup,
|
| + is_first_run, return_code)) {
|
| + return false;
|
| + }
|
| + }
|
| + return browser_init->LaunchBrowser(
|
| + command_line, last_active_profile, cur_dir, is_process_startup,
|
| + is_first_run, return_code);
|
| }
|
| return true;
|
| }
|
| @@ -1703,7 +1726,8 @@ void BrowserInit::ProcessCommandLineOnProfileCreated(
|
| Profile* profile,
|
| Profile::CreateStatus status) {
|
| if (status == Profile::CREATE_STATUS_INITIALIZED)
|
| - ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL);
|
| + ProcessCmdLineImpl(cmd_line, cur_dir, false, profile,
|
| + std::vector<Profile*>(), NULL, NULL);
|
| }
|
|
|
| // static
|
| @@ -1726,5 +1750,6 @@ void BrowserInit::ProcessCommandLineAlreadyRunning(const CommandLine& cmd_line,
|
| NOTREACHED();
|
| return;
|
| }
|
| - ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, NULL, NULL);
|
| + ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, std::vector<Profile*>(),
|
| + NULL, NULL);
|
| }
|
|
|