Chromium Code Reviews| Index: chrome/browser/first_run/first_run.cc |
| diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc |
| index 5d94bcb06a066ae31340b4e95583c13afc7a3744..15d288dde6a4c08e3ee4a763d0783f6dfd96a586 100644 |
| --- a/chrome/browser/first_run/first_run.cc |
| +++ b/chrome/browser/first_run/first_run.cc |
| @@ -25,7 +25,6 @@ |
| #include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/updater/extension_updater.h" |
| -#include "chrome/browser/first_run/first_run_internal.h" |
| #include "chrome/browser/google/google_brand.h" |
| #include "chrome/browser/importer/external_process_importer_host.h" |
| #include "chrome/browser/importer/importer_list.h" |
| @@ -72,6 +71,10 @@ |
| #include "ui/base/l10n/l10n_util.h" |
| #include "url/gurl.h" |
| +#if defined(OS_WIN) |
| +#include "base/win/windows_version.h" |
|
grt (UTC plus 2)
2016/09/09 11:40:29
unused?
|
| +#endif |
| + |
| namespace content { |
| class BrowserContext; |
| } |
| @@ -89,6 +92,11 @@ uint16_t g_auto_import_state = first_run::AUTO_IMPORT_NONE; |
| bool g_should_show_welcome_page = false; |
| bool g_should_do_autofill_personal_data_manager_first_run = false; |
| +// Indicates whether this is first run. Populated when IsChromeFirstRun |
| +// is invoked, then used as a cache on subsequent calls. |
| +first_run::internal::FirstRunState g_first_run = |
| + first_run::internal::FIRST_RUN_UNKNOWN; |
| + |
| // This class acts as an observer for the ImporterProgressObserver::ImportEnded |
| // callback. When the import process is started, certain errors may cause |
| // ImportEnded() to be called synchronously, but the typical case is that |
| @@ -495,8 +503,6 @@ void ProcessDefaultBrowserPolicy(bool make_chrome_default_for_user) { |
| namespace first_run { |
| namespace internal { |
| -FirstRunState g_first_run = FIRST_RUN_UNKNOWN; |
| - |
| void SetupMasterPrefsFromInstallPrefs( |
| const installer::MasterPreferences& install_prefs, |
| MasterPrefs* out_prefs) { |
| @@ -632,17 +638,23 @@ MasterPrefs::MasterPrefs() |
| MasterPrefs::~MasterPrefs() {} |
| bool IsChromeFirstRun() { |
| - if (internal::g_first_run == internal::FIRST_RUN_UNKNOWN) { |
| - internal::g_first_run = internal::FIRST_RUN_FALSE; |
| + if (g_first_run == internal::FIRST_RUN_UNKNOWN) { |
| const base::CommandLine* command_line = |
| base::CommandLine::ForCurrentProcess(); |
| - if (command_line->HasSwitch(switches::kForceFirstRun) || |
| - (!command_line->HasSwitch(switches::kNoFirstRun) && |
| - !internal::IsFirstRunSentinelPresent())) { |
| - internal::g_first_run = internal::FIRST_RUN_TRUE; |
| - } |
| + g_first_run = DetermineFirstRunState( |
| + internal::IsFirstRunSentinelPresent(), |
| + command_line->HasSwitch(switches::kForceFirstRun), |
| + command_line->HasSwitch(switches::kNoFirstRun)); |
| } |
| - return internal::g_first_run == internal::FIRST_RUN_TRUE; |
| + return g_first_run == internal::FIRST_RUN_TRUE; |
| +} |
| + |
| +internal::FirstRunState DetermineFirstRunState(bool has_sentinel, |
| + bool has_force_switch, |
|
grt (UTC plus 2)
2016/09/09 11:40:29
nit: has_force_switch -> force_first_run, has_supp
|
| + bool has_suppress_switch) { |
| + return (has_force_switch || (!has_sentinel && !has_suppress_switch)) |
| + ? internal::FIRST_RUN_TRUE |
| + : internal::FIRST_RUN_FALSE; |
| } |
| #if defined(OS_MACOSX) |