| Index: chrome/browser/chrome_browser_main.cc
|
| diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
|
| index 3f92f84b7750f9ae504decdb130547ec5bbfac46..a85e75694b86ef275f86f60b978e0b951d7e59e6 100644
|
| --- a/chrome/browser/chrome_browser_main.cc
|
| +++ b/chrome/browser/chrome_browser_main.cc
|
| @@ -494,6 +494,7 @@ void RegisterComponentsForUpdate(const CommandLine& command_line) {
|
| cus->Start();
|
| }
|
|
|
| +#if !defined(OS_ANDROID)
|
| bool ProcessSingletonNotificationCallback(
|
| const CommandLine& command_line,
|
| const base::FilePath& current_directory) {
|
| @@ -533,6 +534,7 @@ bool ProcessSingletonNotificationCallback(
|
| command_line, current_directory, startup_profile_dir);
|
| return true;
|
| }
|
| +#endif
|
|
|
| void LaunchDevToolsHandlerIfNeeded(Profile* profile,
|
| const CommandLine& command_line) {
|
| @@ -608,6 +610,11 @@ ChromeBrowserMainParts::ChromeBrowserMainParts(
|
| shutdown_watcher_(new ShutdownWatcherHelper()),
|
| startup_timer_(new performance_monitor::StartupTimer()),
|
| browser_field_trials_(parameters.command_line),
|
| +#if !defined(OS_ANDROID)
|
| + process_singleton_lock_(
|
| + base::Bind(&ProcessSingletonNotificationCallback)),
|
| + modal_dialog_lock_(process_singleton_lock_.AsNotificationCallback()),
|
| +#endif
|
| record_search_engine_(false),
|
| translate_manager_(NULL),
|
| profile_(NULL),
|
| @@ -827,11 +834,10 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
|
| // Android's first run is done in Java instead of native.
|
| #if !defined(OS_ANDROID)
|
|
|
| + // Pass command-line invocations through modal_dialog_lock_ and
|
| + // process_singleton_lock_ before handling them ourselves.
|
| process_singleton_.reset(new ProcessSingleton(
|
| - user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback)));
|
| - // Ensure ProcessSingleton won't process messages too early. It will be
|
| - // unlocked in PostBrowserStart().
|
| - process_singleton_->Lock(NULL);
|
| + user_data_dir_, modal_dialog_lock_.AsNotificationCallback()));
|
|
|
| bool force_first_run =
|
| parsed_command_line().HasSwitch(switches::kForceFirstRun);
|
| @@ -1069,7 +1075,7 @@ void ChromeBrowserMainParts::PostBrowserStart() {
|
| chrome_extra_parts_[i]->PostBrowserStart();
|
| #if !defined(OS_ANDROID)
|
| // Allow ProcessSingleton to process messages.
|
| - process_singleton_->Unlock();
|
| + process_singleton_lock_.Unlock();
|
| #endif
|
| }
|
|
|
| @@ -1244,8 +1250,11 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| // sucessfully grabbed above.
|
| int try_chrome_int;
|
| base::StringToInt(try_chrome, &try_chrome_int);
|
| - TryChromeDialogView::Result answer =
|
| - TryChromeDialogView::Show(try_chrome_int, process_singleton_.get());
|
| + TryChromeDialogView::Result answer = TryChromeDialogView::Show(
|
| + try_chrome_int,
|
| + base::Bind(
|
| + &ModalDialogLock::SetActiveModalDialog,
|
| + base::Unretained(&modal_dialog_lock_)));
|
| if (answer == TryChromeDialogView::NOT_NOW)
|
| return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL;
|
| if (answer == TryChromeDialogView::UNINSTALL_CHROME)
|
| @@ -1344,11 +1353,11 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| // preferences are registered, since some of the code that the importer
|
| // touches reads preferences.
|
| if (do_first_run_tasks_) {
|
| + DCHECK(process_singleton_lock_.locked());
|
| first_run::AutoImport(profile_,
|
| master_prefs_->homepage_defined,
|
| master_prefs_->do_import_items,
|
| - master_prefs_->dont_import_items,
|
| - process_singleton_.get());
|
| + master_prefs_->dont_import_items);
|
| // Note: this can pop the first run consent dialog on linux.
|
| first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default);
|
|
|
|
|