Chromium Code Reviews| 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( | |
| 13 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.
| |
| 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(const Availability availability, | |
| 35 PrefService* prefs) { | |
| 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 |