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

Unified Diff: chrome/browser/chromeos/session_length_limiter_factory.cc

Issue 11499012: Add policy for limiting the session length (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Not sure why the patch is not applying - bot source out of sync with ToT? Created 8 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/chromeos/session_length_limiter_factory.cc
diff --git a/chrome/browser/chromeos/session_length_limiter_factory.cc b/chrome/browser/chromeos/session_length_limiter_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dac281b700365ad0d7befb22344fbfb332eaa521
--- /dev/null
+++ b/chrome/browser/chromeos/session_length_limiter_factory.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/session_length_limiter_factory.h"
+
+#include "chrome/browser/chromeos/session_length_limiter.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+#include "chrome/common/pref_names.h"
+
+namespace chromeos {
+
+// static
+SessionLengthLimiterFactory* SessionLengthLimiterFactory::GetInstance() {
+ return Singleton<SessionLengthLimiterFactory>::get();
+}
+
+SessionLengthLimiterFactory::SessionLengthLimiterFactory()
+ : ProfileKeyedServiceFactory("SessionLengthLimiter",
+ ProfileDependencyManager::GetInstance()) {
+}
+
+SessionLengthLimiterFactory::~SessionLengthLimiterFactory() {
+}
+
+ProfileKeyedService* SessionLengthLimiterFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ return new SessionLengthLimiter(NULL, profile->GetPrefs());
+}
+
+void SessionLengthLimiterFactory::RegisterUserPrefs(PrefService* prefs) {
+ prefs->RegisterInt64Pref(prefs::kSessionStartTime,
+ 0,
+ PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterIntegerPref(prefs::kSessionLengthLimit,
+ 0,
+ PrefService::UNSYNCABLE_PREF);
+}
+
+bool SessionLengthLimiterFactory::ServiceIsCreatedWithProfile() const {
+ return true;
+}
+
+bool SessionLengthLimiterFactory::ServiceIsNULLWhileTesting() const {
+ // Some tests replace the |PrefService| of the |TestingProfile| after the
+ // |SessionLengthLimiter| has been created, making its |Shutdown()| try to
+ // remove a |PrefChangeRegistrar| from a non-existent |PrefService|.
+ return true;
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698