Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3036)

Unified Diff: chrome/browser/ui/browser_init.cc

Issue 8937001: Fixes for the kWasRestarted pref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test build fix. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser_init.cc
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 4f493b7219aa74dc3c46380470b7864ca33b3993..6d2bc1e91253e745a9393e2ae0cc8bf898564206 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -335,10 +335,9 @@ bool IncognitoIsForced(const CommandLine& command_line,
SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
Profile* profile) {
- PrefService* pref_service = g_browser_process->local_state();
SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
if (command_line.HasSwitch(switches::kRestoreLastSession) ||
- pref_service->GetBoolean(prefs::kWasRestarted)) {
+ BrowserInit::WasRestarted()) {
pref.type = SessionStartupPref::LAST;
}
if (pref.type == SessionStartupPref::LAST &&
@@ -499,6 +498,9 @@ void RegisterComponentsForUpdate(const CommandLine& command_line) {
// BrowserInit ----------------------------------------------------------------
+bool BrowserInit::was_restarted_ = false;
sky 2011/12/13 16:54:42 Since these are only used in WasRestarted, why not
+bool BrowserInit::was_restarted_read_ = false;
+
BrowserInit::BrowserInit() {}
BrowserInit::~BrowserInit() {}
@@ -585,6 +587,17 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line,
return true;
}
+// static
+bool BrowserInit::WasRestarted() {
+ if (!was_restarted_read_) {
+ PrefService* pref_service = g_browser_process->local_state();
+ was_restarted_ = pref_service->GetBoolean(prefs::kWasRestarted);
+ pref_service->SetBoolean(prefs::kWasRestarted, false);
+ pref_service->ScheduleSavePersistentPrefs();
+ was_restarted_read_ = true;
+ }
+ return was_restarted_;
+}
// BrowserInit::LaunchWithProfile::Tab ----------------------------------------

Powered by Google App Engine
This is Rietveld 408576698