Index: chrome/browser/chrome_browser_main.cc |
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
index c65bde7550d1106e22b0082cf02ccf9b5c127659..a0ac72637bf632f5c1c114e54cf49546a2653aac 100644 |
--- a/chrome/browser/chrome_browser_main.cc |
+++ b/chrome/browser/chrome_browser_main.cc |
@@ -487,8 +487,7 @@ ChromeBrowserMainParts::ChromeBrowserMainParts( |
profile_(NULL), |
run_message_loop_(true), |
notify_result_(ProcessSingleton::PROCESS_NONE), |
- is_first_run_(false), |
- first_run_ui_bypass_(false), |
+ do_first_run_tasks_(false), |
Nico
2012/12/21 21:44:22
Shoudl this default to true?
gab
2012/12/21 22:10:35
No, it's only set to true if this is first run &&
|
local_state_(NULL), |
restart_last_session_(false) { |
// If we're running tests (ui_task is non-null). |
@@ -689,13 +688,14 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
#endif |
// Android's first run is done in Java instead of native. |
+ bool is_first_run = false; |
#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(). |
process_singleton_->Lock(NULL); |
- is_first_run_ = |
+ is_first_run = |
(first_run::IsChromeFirstRun() || |
parsed_command_line().HasSwitch(switches::kFirstRun)) && |
!HasImportSwitch(parsed_command_line()); |
@@ -731,7 +731,7 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
local_state_ = InitializeLocalState(local_state_task_runner, |
parsed_command_line(), |
- is_first_run_); |
+ is_first_run); |
// These members must be initialized before returning from this function. |
master_prefs_.reset(new first_run::MasterPrefs); |
@@ -797,29 +797,34 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
// On first run, we need to process the predictor preferences before the |
// browser's profile_manager object is created, but after ResourceBundle |
// is initialized. |
- first_run_ui_bypass_ = false; // True to skip first run UI. |
- if (is_first_run_) { |
+ // True to do first run tasks. This should be prefered to is_first_run |
+ // unless the desire is actually to know whether this is really first run |
+ // (i.e. even if --no-first-run is passed). |
+ do_first_run_tasks_ = false; |
Nico
2012/12/21 21:44:22
Oh, I see. From the name alone I would've guessed
gab
2012/12/21 22:10:35
Ack.
|
+ if (is_first_run) { |
first_run::ProcessMasterPreferencesResult pmp_result = |
first_run::ProcessMasterPreferences(user_data_dir_, |
master_prefs_.get()); |
if (pmp_result == first_run::EULA_EXIT_NOW) |
return chrome::RESULT_CODE_EULA_REFUSED; |
- first_run_ui_bypass_ = (pmp_result == first_run::SKIP_FIRST_RUN); |
+ do_first_run_tasks_ = (pmp_result != first_run::SKIP_FIRST_RUN_TASKS); |
AddFirstRunNewTabs(browser_creator_.get(), master_prefs_->new_tabs); |
// If we are running in App mode, we do not want to show the importer |
// (first run) UI. |
- if (!first_run_ui_bypass_ && |
+ if (do_first_run_tasks_ && |
Nico
2012/12/21 21:44:22
Pointless check. HasSwitch() is fast, remove htis.
gab
2012/12/21 22:10:35
Done.
|
(parsed_command_line().HasSwitch(switches::kApp) || |
- parsed_command_line().HasSwitch(switches::kAppId) || |
- parsed_command_line().HasSwitch(switches::kNoFirstRun))) |
- first_run_ui_bypass_ = true; |
+ parsed_command_line().HasSwitch(switches::kAppId))) { |
+ do_first_run_tasks_ = false; |
+ } |
// Create Sentinel if no-first-run argument is passed in. |
- if (parsed_command_line().HasSwitch(switches::kNoFirstRun)) |
+ if (parsed_command_line().HasSwitch(switches::kNoFirstRun)) { |
+ do_first_run_tasks_ = false; |
first_run::CreateSentinel(); |
+ } |
} |
#endif |
@@ -881,10 +886,6 @@ void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
// ... additional setup, including CreateProfile() |
// PostProfileInit() |
// ... additional setup |
-// PreInteractiveFirstRunInit() |
-// ... first_run::AutoImport() |
-// PostInteractiveFirstRunInit() |
-// ... additional setup |
// PreBrowserStart() |
// ... browser_creator_->Start (OR parameters().ui_task->Run()) |
// PostBrowserStart() |
@@ -900,16 +901,6 @@ void ChromeBrowserMainParts::PostProfileInit() { |
chrome_extra_parts_[i]->PostProfileInit(); |
} |
-void ChromeBrowserMainParts::PreInteractiveFirstRunInit() { |
- for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
- chrome_extra_parts_[i]->PreInteractiveFirstRunInit(); |
-} |
- |
-void ChromeBrowserMainParts::PostInteractiveFirstRunInit() { |
- for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
- chrome_extra_parts_[i]->PostInteractiveFirstRunInit(); |
-} |
- |
void ChromeBrowserMainParts::PreBrowserStart() { |
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
chrome_extra_parts_[i]->PreBrowserStart(); |
@@ -1119,7 +1110,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
// Profile creation ---------------------------------------------------------- |
- if (is_first_run_) { |
+ if (do_first_run_tasks_) { |
// Warn the ProfileManager that an import process will run, possibly |
// locking the WebDataService directory of the next Profile created. |
browser_process_->profile_manager()->SetWillImport(); |
@@ -1189,30 +1180,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
// Note that this be done _after_ the PrefService is initialized and all |
// preferences are registered, since some of the code that the importer |
// touches reads preferences. |
- if (is_first_run_) { |
- PreInteractiveFirstRunInit(); |
- |
- if (!first_run_ui_bypass_) { |
- first_run::AutoImport(profile_, |
- master_prefs_->homepage_defined, |
- master_prefs_->do_import_items, |
- master_prefs_->dont_import_items, |
- process_singleton_.get()); |
- first_run::DoFirstRunTasks(profile_, master_prefs_->make_chrome_default); |
-#if defined(OS_POSIX) && !defined(OS_CHROMEOS) |
- // TODO(thakis): Look into moving this POSIX-specific section to |
- // ChromeBrowserMainPartsPosix::PostInteractiveFirstRunInit(). |
- |
- // On Windows, the download is tagged with enable/disable stats so there |
- // is no need for this code. |
- |
- // If stats reporting was turned on by the first run dialog then toggle |
- // the pref. |
- if (GoogleUpdateSettings::GetCollectStatsConsent()) |
- local_state_->SetBoolean(prefs::kMetricsReportingEnabled, true); |
-#endif // OS_POSIX && !OS_CHROMEOS |
- } // if (!first_run_ui_bypass_) |
- PostInteractiveFirstRunInit(); |
+ if (do_first_run_tasks_) { |
+ first_run::AutoImport(profile_, |
+ master_prefs_->homepage_defined, |
+ master_prefs_->do_import_items, |
+ master_prefs_->dont_import_items, |
+ process_singleton_.get()); |
+ first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); |
browser_process_->profile_manager()->OnImportFinished(profile_); |
@@ -1222,7 +1196,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
} else { |
browser_creator_->set_is_default_browser_dialog_suppressed(true); |
} |
- } // if (is_first_run_) |
+ } // if (do_first_run_tasks_) |
#endif // !defined(OS_ANDROID) |
#if defined(OS_WIN) |
@@ -1256,9 +1230,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
// file thread to be run sometime later. If this is the first run we record |
// the installation event. |
PrefService* pref_service = profile_->GetPrefs(); |
- int ping_delay = is_first_run_ ? master_prefs_->ping_delay : |
+ int ping_delay = do_first_run_tasks_ ? master_prefs_->ping_delay : |
pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); |
- RLZTracker::InitRlzFromProfileDelayed(profile_, is_first_run_, ping_delay); |
+ RLZTracker::InitRlzFromProfileDelayed(profile_, do_first_run_tasks_, |
+ ping_delay); |
#endif // defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) |
// Configure modules that need access to resources. |
@@ -1354,7 +1329,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
#if defined(OS_WIN) |
// We check this here because if the profile is OTR (chromeos possibility) |
// it won't still be accessible after browser is destroyed. |
- record_search_engine_ = is_first_run_ && !profile_->IsOffTheRecord(); |
+ record_search_engine_ = do_first_run_tasks_ && !profile_->IsOffTheRecord(); |
#endif |
// Create the instance of the cloud print proxy service so that it can launch |