Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/prefs/pref_registry_syncable.h" | |
| 9 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 12 | 13 |
| 13 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 14 #include "base/win/metro.h" | 15 #include "base/win/metro.h" |
| 15 #endif // OS_WIN | 16 #endif // OS_WIN |
| 16 | 17 |
| 17 // static | 18 // static |
| 18 bool IncognitoModePrefs::IntToAvailability(int in_value, | 19 bool IncognitoModePrefs::IntToAvailability(int in_value, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 45 return result; | 46 return result; |
| 46 } | 47 } |
| 47 | 48 |
| 48 // static | 49 // static |
| 49 void IncognitoModePrefs::SetAvailability(PrefService* prefs, | 50 void IncognitoModePrefs::SetAvailability(PrefService* prefs, |
| 50 const Availability availability) { | 51 const Availability availability) { |
| 51 prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); | 52 prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); |
| 52 } | 53 } |
| 53 | 54 |
| 54 // static | 55 // static |
| 55 void IncognitoModePrefs::RegisterUserPrefs(PrefServiceSyncable* pref_service) { | 56 void IncognitoModePrefs::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 56 DCHECK(pref_service); | 57 DCHECK(registry); |
|
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
nit: not needed, we crash below if the pointer is
Jói
2013/02/07 14:52:32
Done.
| |
| 57 pref_service->RegisterIntegerPref(prefs::kIncognitoModeAvailability, | 58 registry->RegisterIntegerPref(prefs::kIncognitoModeAvailability, |
| 58 IncognitoModePrefs::ENABLED, | 59 IncognitoModePrefs::ENABLED, |
| 59 PrefServiceSyncable::UNSYNCABLE_PREF); | 60 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 60 } | 61 } |
| 61 | 62 |
| 62 // static | 63 // static |
| 63 bool IncognitoModePrefs::ShouldLaunchIncognito( | 64 bool IncognitoModePrefs::ShouldLaunchIncognito( |
| 64 const CommandLine& command_line, | 65 const CommandLine& command_line, |
| 65 const PrefService* prefs) { | 66 const PrefService* prefs) { |
| 66 Availability incognito_avail = GetAvailability(prefs); | 67 Availability incognito_avail = GetAvailability(prefs); |
| 67 return incognito_avail != IncognitoModePrefs::DISABLED && | 68 return incognito_avail != IncognitoModePrefs::DISABLED && |
| 68 (command_line.HasSwitch(switches::kIncognito) || | 69 (command_line.HasSwitch(switches::kIncognito) || |
| 69 incognito_avail == IncognitoModePrefs::FORCED); | 70 incognito_avail == IncognitoModePrefs::FORCED); |
| 70 } | 71 } |
| OLD | NEW |