Index: chrome/browser/ui/startup/startup_browser_creator.cc |
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc |
index 08086b4994b48c585697a3dab22ff06e2523a23a..b5837d9080be3995c9ee4cba53ad03ce30afe41b 100644 |
--- a/chrome/browser/ui/startup/startup_browser_creator.cc |
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc |
@@ -36,6 +36,7 @@ |
#include "chrome/browser/google/google_util.h" |
#include "chrome/browser/net/url_fixer_upper.h" |
#include "chrome/browser/notifications/desktop_notification_service.h" |
+#include "chrome/browser/operation_output.h" |
#include "chrome/browser/prefs/incognito_mode_prefs.h" |
#include "chrome/browser/prefs/session_startup_pref.h" |
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
@@ -240,6 +241,17 @@ void StartupBrowserCreator::AddFirstRunTab(const GURL& url) { |
first_run_tabs_.push_back(url); |
} |
+bool StartupBrowserCreator::Start( |
+ const CommandLine& cmd_line, |
+ const base::FilePath& cur_dir, |
+ Profile* last_used_profile, |
+ const Profiles& last_opened_profiles, |
+ scoped_ptr<OperationOutput> operation_output) { |
+ return ProcessCmdLineImpl(cmd_line, cur_dir, true, last_used_profile, |
+ last_opened_profiles, this, |
+ operation_output.Pass()); |
+} |
+ |
// static |
bool StartupBrowserCreator::InSynchronousProfileLaunch() { |
return in_synchronous_profile_launch_; |
@@ -430,14 +442,25 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
bool process_startup, |
Profile* last_used_profile, |
const Profiles& last_opened_profiles, |
- int* return_code, |
- StartupBrowserCreator* browser_creator) { |
+ StartupBrowserCreator* browser_creator, |
+ scoped_ptr<OperationOutput> operation_output) { |
DCHECK(last_used_profile); |
if (process_startup) { |
if (command_line.HasSwitch(switches::kDisablePromptOnRepost)) |
content::NavigationController::DisablePromptOnRepost(); |
} |
+ // TODO(erikwright): Remove before committing. |
+ if (command_line.HasSwitch("greetings")) { |
+ if (operation_output) { |
+ std::string hello_world("hello world!"); |
+ operation_output->Write(hello_world.c_str(), hello_world.length()); |
+ OperationOutput::Complete(operation_output.Pass(), 42); |
+ } |
+ |
+ return false; |
+ } |
+ |
bool silent_launch = false; |
#if defined(ENABLE_AUTOMATION) |
@@ -627,9 +650,12 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
// |last_used_profile| is the last used incognito profile. Restoring it will |
// create a browser window for the corresponding original profile. |
if (last_opened_profiles.empty()) { |
+ int return_code = 0; |
if (!browser_creator->LaunchBrowser(command_line, last_used_profile, |
cur_dir, is_process_startup, |
- is_first_run, return_code)) { |
+ is_first_run, &return_code)) { |
+ if (operation_output) |
+ OperationOutput::Complete(operation_output.Pass(), return_code); |
return false; |
} |
} else { |
@@ -654,10 +680,14 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
startup_pref.type == SessionStartupPref::DEFAULT && |
!HasPendingUncleanExit(*it)) |
continue; |
+ int return_code = 0; |
if (!browser_creator->LaunchBrowser((*it == last_used_profile) ? |
command_line : command_line_without_urls, *it, cur_dir, |
- is_process_startup, is_first_run, return_code)) |
+ is_process_startup, is_first_run, &return_code)) { |
+ if (operation_output) |
+ OperationOutput::Complete(operation_output.Pass(), return_code); |
return false; |
+ } |
// We've launched at least one browser. |
is_process_startup = chrome::startup::IS_NOT_PROCESS_STARTUP; |
} |
@@ -665,6 +695,10 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( |
// knows about all profiles to wait for before activating this one. |
profile_launch_observer.Get().set_profile_to_activate(last_used_profile); |
} |
+ if (operation_output) { |
+ OperationOutput::Complete(operation_output.Pass(), |
+ content::RESULT_CODE_NORMAL_EXIT); |
+ } |
return true; |
} |
@@ -692,31 +726,39 @@ bool StartupBrowserCreator::CreateAutomationProvider( |
void StartupBrowserCreator::ProcessCommandLineOnProfileCreated( |
const CommandLine& command_line, |
const base::FilePath& cur_dir, |
+ scoped_ptr<OperationOutput> operation_output, |
Profile* profile, |
Profile::CreateStatus status) { |
- if (status == Profile::CREATE_STATUS_INITIALIZED) |
+ if (status == Profile::CREATE_STATUS_INITIALIZED) { |
ProcessCmdLineImpl(command_line, cur_dir, false, profile, Profiles(), NULL, |
- NULL); |
+ operation_output.Pass()); |
+ } else { |
+ // Signal failure on operation_output? |
+ } |
} |
// static |
void StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
const CommandLine& command_line, |
const base::FilePath& cur_dir, |
- const base::FilePath& profile_path) { |
+ const base::FilePath& profile_path, |
+ scoped_ptr<OperationOutput> operation_output) { |
ProfileManager* profile_manager = g_browser_process->profile_manager(); |
Profile* profile = profile_manager->GetProfileByPath(profile_path); |
// The profile isn't loaded yet and so needs to be loaded asynchronously. |
if (!profile) { |
- profile_manager->CreateProfileAsync(profile_path, |
- base::Bind(&StartupBrowserCreator::ProcessCommandLineOnProfileCreated, |
- command_line, cur_dir), string16(), string16(), false); |
+ profile_manager->CreateProfileAsync( |
+ profile_path, |
+ base::Bind( |
+ &StartupBrowserCreator::ProcessCommandLineOnProfileCreated, |
+ command_line, cur_dir, base::Passed(operation_output.Pass())), |
+ string16(), string16(), false); |
return; |
} |
ProcessCmdLineImpl(command_line, cur_dir, false, profile, Profiles(), NULL, |
- NULL); |
+ operation_output.Pass()); |
} |
// static |