Index: chrome/browser/chrome_browser_main.cc |
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
index 4c962b02aff372ed7e945dd928bd43bc8e352d42..b188dbd2e15481ae823b6c96f8b0dd9fd49a8431 100644 |
--- a/chrome/browser/chrome_browser_main.cc |
+++ b/chrome/browser/chrome_browser_main.cc |
@@ -820,7 +820,6 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
bool is_first_run = false; |
// Android's first run is done in Java instead of native. |
#if !defined(OS_ANDROID) |
- |
process_singleton_.reset(new ProcessSingleton(user_data_dir_)); |
// Ensure ProcessSingleton won't process messages too early. It will be |
// unlocked in PostBrowserStart(). |
@@ -968,9 +967,12 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
local_state_->SetInt64(prefs::kVariationsSeedDate, |
base::Time::Now().ToInternalValue()); |
} |
- } else if (parsed_command_line().HasSwitch(switches::kNoFirstRun)) { |
- // Create the First Run beacon anyways if --no-first-run was passed on the |
- // command line. |
+ } |
+ |
+ if (do_first_run_tasks_ || |
+ parsed_command_line().HasSwitch(switches::kNoFirstRun)) { |
+ // Create the First Run sentinel whether first run tasks are executed |
+ // or not. |
first_run::CreateSentinel(); |
} |
} |
@@ -1036,6 +1038,12 @@ void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
// PostBrowserStart() |
void ChromeBrowserMainParts::PreProfileInit() { |
+ if (do_first_run_tasks_) { |
+ // Import tasks which launch a process writing to the profile need to happen |
+ // before this process takes control of the profile (but after the process |
+ // singleton was created). |
+ first_run::LaunchInitialImport(master_prefs_.get()); |
+ } |
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
chrome_extra_parts_[i]->PreProfileInit(); |
} |
@@ -1337,11 +1345,23 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
// preferences are registered, since some of the code that the importer |
// touches reads preferences. |
if (do_first_run_tasks_) { |
+// On Windows the import process was already launched from |
+// PreProfileInit()-->LaunchInitialImport(). |
+// TODO(gab): Windows should really use the OOP import (http://crbug.com/22142), |
+// but for now let's at least not run the import twice on Windows. It has to run |
+// before the profile is created because the import process is designed to |
+// interact with the profile itself (and trying to launch the import process |
+// from here causes issues like http://crbug.com/180459 and |
+// http://crbug.com/171475). |
+#if defined(OS_WIN) |
+ DCHECK(first_run::DidPerformProfileImport(NULL)); |
+#else |
first_run::AutoImport(profile_, |
master_prefs_->homepage_defined, |
master_prefs_->do_import_items, |
master_prefs_->dont_import_items, |
process_singleton_.get()); |
+#endif |
// Note: this can pop the first run consent dialog on linux. |
first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); |