Index: chrome/browser/chromeos/login/session/user_session_manager.cc |
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc |
index ae78f45f033c132517d0b0f238e6f3efc5e230ba..d5003c154bdb1e10493799bfcd679409e4043fff 100644 |
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc |
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc |
@@ -119,6 +119,9 @@ static const int kFlagsFetchingLoginTimeoutMs = 1000; |
// for, waiting for a session restore to finish. |
static const int kMaxRestartDelaySeconds = 10; |
+// Max days after initial login that we're willing to show Goodies. |
+static const int kMaxDaysAfterOobeForGoodies = 14; |
+ |
// ChromeVox tutorial URL (used in place of "getting started" url when |
// accessibility is enabled). |
const char kChromeVoxTutorialURLPattern[] = |
@@ -213,6 +216,33 @@ void InitLocaleAndInputMethodsForNewUser( |
prefs->SetBoolean(prefs::kLanguageShouldMergeInputMethods, true); |
} |
+// We want to show Goodies page the first time a new browser window is opened |
+// on a new Chromebook. kCanShowOobeGoodiesPage defaults to |true|; we set it |
+// to |false| (return |false|) for any device over kMaxDaysAfterOobeForGoodies |
+// days old, to avoid showing it after update on older devices. |
+static bool CheckGoodiesPrefAgainstOobeTimestamp() { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
+ const base::FilePath oobe_timestamp_file = |
+ StartupUtils::GetOobeCompleteFlagPath(); |
+ base::File::Info fileInfo; |
+ if (base::GetFileInfo(oobe_timestamp_file, &fileInfo)) { |
+ base::TimeDelta time_since_oobe = |
+ base::Time::Now() - fileInfo.creation_time; |
+ if (time_since_oobe > |
+ base::TimeDelta::FromDays(kMaxDaysAfterOobeForGoodies)) |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+// Callback into main thread to set pref to |false| if too long since oobe. |
+static void UpdateGoodiesPrefCantShow(bool can_show_goodies) { |
+ if (can_show_goodies) |
+ return; |
+ PrefService* prefs = g_browser_process->local_state(); |
+ prefs->SetBoolean(prefs::kCanShowOobeGoodiesPage, false); |
+} |
+ |
#if defined(ENABLE_RLZ) |
// Flag file that disables RLZ tracking, when present. |
const base::FilePath::CharType kRLZDisabledFlagName[] = |
@@ -350,6 +380,7 @@ void UserSessionManager::OverrideHomedir() { |
void UserSessionManager::RegisterPrefs(PrefRegistrySimple* registry) { |
registry->RegisterStringPref(prefs::kRLZBrand, std::string()); |
registry->RegisterBooleanPref(prefs::kRLZDisabled, false); |
+ registry->RegisterBooleanPref(prefs::kCanShowOobeGoodiesPage, true); |
} |
UserSessionManager::UserSessionManager() |
@@ -1137,6 +1168,8 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) { |
// launch browser. |
bool browser_launched = InitializeUserSession(profile); |
+ CheckCanShowGoodiesPref(); |
Greg Levin
2015/09/09 23:20:33
My choice to put this here was a little arbitrary.
|
+ |
// TODO(nkostylev): This pointer should probably never be NULL, but it looks |
// like OnProfileCreated() may be getting called before |
// UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is |
@@ -1192,6 +1225,16 @@ void UserSessionManager::InitializeStartUrls() const { |
} |
} |
+void UserSessionManager::CheckCanShowGoodiesPref() { |
+ PrefService* prefs = g_browser_process->local_state(); |
+ bool can_show_goodies = prefs->GetBoolean(prefs::kCanShowOobeGoodiesPage); |
+ if (can_show_goodies) |
+ content::BrowserThread::PostTaskAndReplyWithResult( |
+ content::BrowserThread::FILE, FROM_HERE, |
+ base::Bind(&CheckGoodiesPrefAgainstOobeTimestamp), |
+ base::Bind(&UpdateGoodiesPrefCantShow)); |
+} |
+ |
bool UserSessionManager::InitializeUserSession(Profile* profile) { |
ChildAccountService* child_service = |
ChildAccountServiceFactory::GetForProfile(profile); |