diff options
author | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 02:13:29 +0000 |
---|---|---|
committer | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 02:13:29 +0000 |
commit | 69e9069a847c7dbbbfb53bfc48001dde03306473 (patch) | |
tree | a4ff75fba65f5c3dc0a15926edf7dcd6fe6859e9 /chrome/browser/first_run/first_run.cc | |
parent | 9897b56b8d9d371c42f1a81491a92c28aa1c40de (diff) | |
download | chromium_src-69e9069a847c7dbbbfb53bfc48001dde03306473.zip chromium_src-69e9069a847c7dbbbfb53bfc48001dde03306473.tar.gz chromium_src-69e9069a847c7dbbbfb53bfc48001dde03306473.tar.bz2 |
Merge 3 different ways of obtaining first run state (BrowserMain's |is_first_run|/|do_first_run_tasks_| and first_run::IsChromeFirstRun()) into a single one.
We have switches to force the browser in/out of thinking it's first run (--force-first-run and --no-first-run). Yet first_run::IsChromeFirstRun() didn't use those and thus some code entry points weren't respecting --force-first-run correctly.
We also had |is_first_run| and |do_first_run_tasks_| in chrome_browser_main.cc... I forget why I thought that was a good idea originally, but I no longer do..! Perhaps some things changed since..?
There are basically 3 first run state that matter:
1) It is first run => do the first run things everywhere (can be forced by --force-first-run)
2) It's not first run (neither forced, nor is first run sentinel present) => Don't do first run things.
3) --no-first-run => Just like (2), but we also create the first run sentinel to prevent any subsequent launches from being a natural first run.
This logic is now all coded up in a single place in first_run::IsChromeFirstRun().
Other changes (highlighted inline in patch set 1):
1) Some first run things used to be skipped on CHROME_OS based on a hidden ifdef; moved that ifdef up where it makes sense in chrome_browser_main.cc
2) Running first run in App mode or App Launcher mode would prevent a bunch of silent things from happening, based on an if which was originally there to prevent the import UI I believe (which is now silent...), reverted that trend: running App mode now only prevents adding first run tabs.
Also found issue 264694 while working on this CL, addressed with further cleanup in https://codereview.chromium.org/20743002/.
BUG=234647, 264694
TEST=
A) Launch chrome.exe with no First Run sentinel, make sure first run happens once (relaunch and it shouldn't happen twice).
B) Launch chrome.exe with First Run sentinel, but with --force-first-run, make sure first run happens anyways.
C) Launch chrome.exe with no First Run sentinel, but with --no-first-run, make sure first run doesn't happen (and doesn't happen in subsequent relaunches either without the flag).
R=cpu@chromium.org, jam@chromium.org
Review URL: https://codereview.chromium.org/20483002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/first_run/first_run.cc')
-rw-r--r-- | chrome/browser/first_run/first_run.cc | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index 315d6f9..585ba2c 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -469,14 +469,35 @@ bool IsChromeFirstRun() { if (internal::first_run_ != internal::FIRST_RUN_UNKNOWN) return internal::first_run_ == internal::FIRST_RUN_TRUE; + enum FirstRunState { + CANCEL_FIRST_RUN, + NOT_FIRST_RUN, + IS_FIRST_RUN, + }; + + FirstRunState first_run_state = NOT_FIRST_RUN; + base::FilePath first_run_sentinel; - if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel) || - base::PathExists(first_run_sentinel)) { + const CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kForceFirstRun)) { + first_run_state = IS_FIRST_RUN; + } else if (command_line->HasSwitch(switches::kNoFirstRun)) { + first_run_state = CANCEL_FIRST_RUN; + } else if (internal::GetFirstRunSentinelFilePath(&first_run_sentinel) && + !base::PathExists(first_run_sentinel)) { + first_run_state = IS_FIRST_RUN; + } + + if (first_run_state == IS_FIRST_RUN || first_run_state == CANCEL_FIRST_RUN) + CreateSentinel(); + + if (first_run_state == IS_FIRST_RUN) { + internal::first_run_ = internal::FIRST_RUN_TRUE; + return true; + } else { internal::first_run_ = internal::FIRST_RUN_FALSE; return false; } - internal::first_run_ = internal::FIRST_RUN_TRUE; - return true; } bool CreateSentinel() { @@ -636,13 +657,6 @@ ProcessMasterPreferencesResult ProcessMasterPreferences( MasterPrefs* out_prefs) { DCHECK(!user_data_dir.empty()); -#if defined(OS_CHROMEOS) - // Chrome OS has its own out-of-box-experience code. Create the sentinel to - // mark the fact that we've run once but skip the full first-run flow. - CreateSentinel(); - return SKIP_FIRST_RUN_TASKS; -#endif - base::FilePath master_prefs_path; scoped_ptr<installer::MasterPreferences> install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); @@ -664,7 +678,7 @@ ProcessMasterPreferencesResult ProcessMasterPreferences( internal::SetDefaultBrowser(install_prefs.get()); } - return DO_FIRST_RUN_TASKS; + return FIRST_RUN_PROCEED; } void AutoImport( |