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

Unified Diff: chrome/browser/prefs/incognito_mode_prefs.cc

Issue 7520023: Converted IncognitoForced boolean policy into IncognitoModeAvailability enum policy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removed IncognitoEnabled pref. Fixed style issues. Created 9 years, 5 months 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/prefs/incognito_mode_prefs.cc
diff --git a/chrome/browser/prefs/incognito_mode_prefs.cc b/chrome/browser/prefs/incognito_mode_prefs.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a4bb0ae0ca81c1d5f185c34aeb83494fd5df3782
--- /dev/null
+++ b/chrome/browser/prefs/incognito_mode_prefs.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2011 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/prefs/incognito_mode_prefs.h"
+
+#include "base/logging.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/common/pref_names.h"
+
+// static
+bool IncognitoModePrefs::IntToAvailability(
+ int in_value, Availability* out_value) {
+ if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) {
+ *out_value = ENABLED;
+ return false;
+ }
+ *out_value = static_cast<Availability>(in_value);
+ return true;
+}
+
+// static
+IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability(
+ const PrefService* pref_service) {
+ DCHECK(pref_service);
+ int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability);
+ Availability result = IncognitoModePrefs::ENABLED;
+ bool valid = IntToAvailability(pref_value, &result);
+ DCHECK(valid);
+ return result;
+}
+
+// static
+void IncognitoModePrefs::RegisterUserPrefs(PrefService* pref_service) {
+ DCHECK(pref_service);
+ pref_service->RegisterIntegerPref(prefs::kIncognitoModeAvailability,
+ IncognitoModePrefs::ENABLED,
+ PrefService::UNSYNCABLE_PREF);
+}

Powered by Google App Engine
This is Rietveld 408576698