Chromium Code Reviews| 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..9e4131c4ae26a02a8f162f8379061f6a0f2eb8a3 |
| --- /dev/null |
| +++ b/chrome/browser/prefs/incognito_mode_prefs.cc |
| @@ -0,0 +1,45 @@ |
| +// 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) { |
|
Mattias Nissler (ping if slow)
2011/08/03 09:16:08
Each parameter goes on a separate line (and then t
rustema
2011/08/04 07:00:49
Done.
|
| + 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::SetAvailability(const Availability availability, |
| + PrefService* prefs) { |
| + prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); |
| +} |
| + |
| +// static |
| +void IncognitoModePrefs::RegisterUserPrefs(PrefService* pref_service) { |
| + DCHECK(pref_service); |
| + pref_service->RegisterIntegerPref(prefs::kIncognitoModeAvailability, |
| + IncognitoModePrefs::ENABLED, |
| + PrefService::UNSYNCABLE_PREF); |
| +} |