OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/common/pref_names.h" |
| 10 |
| 11 // static |
| 12 bool IncognitoModePrefs::IntToAvailability(int in_value, |
| 13 Availability* out_value) { |
| 14 if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) { |
| 15 *out_value = ENABLED; |
| 16 return false; |
| 17 } |
| 18 *out_value = static_cast<Availability>(in_value); |
| 19 return true; |
| 20 } |
| 21 |
| 22 // static |
| 23 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability( |
| 24 const PrefService* pref_service) { |
| 25 DCHECK(pref_service); |
| 26 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); |
| 27 Availability result = IncognitoModePrefs::ENABLED; |
| 28 bool valid = IntToAvailability(pref_value, &result); |
| 29 DCHECK(valid); |
| 30 return result; |
| 31 } |
| 32 |
| 33 // static |
| 34 void IncognitoModePrefs::SetAvailability(PrefService* prefs, |
| 35 const Availability availability) { |
| 36 prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); |
| 37 } |
| 38 |
| 39 // static |
| 40 void IncognitoModePrefs::RegisterUserPrefs(PrefService* pref_service) { |
| 41 DCHECK(pref_service); |
| 42 pref_service->RegisterIntegerPref(prefs::kIncognitoModeAvailability, |
| 43 IncognitoModePrefs::ENABLED, |
| 44 PrefService::UNSYNCABLE_PREF); |
| 45 } |
OLD | NEW |