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 "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "components/user_prefs/pref_registry_syncable.h" | 13 #include "components/user_prefs/pref_registry_syncable.h" |
| 14 | 14 |
| 15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 16 #include "base/win/metro.h" | 16 #include "base/win/metro.h" |
| 17 #endif // OS_WIN | 17 #elif defined(OS_ANDROID) |
|
Bernhard Bauer
2014/01/14 09:59:07
Nit: I'd rather keep these #ifdefs separate (it re
Ted C
2014/01/15 00:15:49
Done.
| |
| 18 #include "chrome/browser/android/chromium_application.h" | |
| 19 #endif | |
| 18 | 20 |
| 19 // static | 21 // static |
| 20 bool IncognitoModePrefs::IntToAvailability(int in_value, | 22 bool IncognitoModePrefs::IntToAvailability(int in_value, |
| 21 Availability* out_value) { | 23 Availability* out_value) { |
| 22 if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) { | 24 if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) { |
| 23 *out_value = ENABLED; | 25 *out_value = ENABLED; |
| 24 return false; | 26 return false; |
| 25 } | 27 } |
| 26 *out_value = static_cast<Availability>(in_value); | 28 *out_value = static_cast<Availability>(in_value); |
| 27 return true; | 29 return true; |
| 28 } | 30 } |
| 29 | 31 |
| 30 // static | 32 // static |
| 31 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability( | 33 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability( |
| 32 const PrefService* pref_service) { | 34 const PrefService* pref_service) { |
| 33 DCHECK(pref_service); | 35 DCHECK(pref_service); |
| 34 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); | 36 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); |
| 35 Availability result = IncognitoModePrefs::ENABLED; | 37 Availability result = IncognitoModePrefs::ENABLED; |
| 36 bool valid = IntToAvailability(pref_value, &result); | 38 bool valid = IntToAvailability(pref_value, &result); |
| 37 DCHECK(valid); | 39 DCHECK(valid); |
| 38 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
| 39 // Disable incognito mode windows if parental controls are on. This is only | 41 // Disable incognito mode windows if parental controls are on. This is only |
| 40 // for Windows Vista and above. | 42 // for Windows Vista and above. |
| 41 if (base::win::IsParentalControlActivityLoggingOn()) { | 43 if (base::win::IsParentalControlActivityLoggingOn()) { |
|
Bernhard Bauer
2014/01/14 09:59:07
Hm, would it make sense to make this into a single
Ted C
2014/01/14 20:22:59
Thoughts on where such a thing should live?
Since
Bernhard Bauer
2014/01/14 23:26:26
Hmm... good question. We could probably add some h
Ted C
2014/01/15 00:15:49
I split it out a separate function.
| |
| 42 if (result == IncognitoModePrefs::FORCED) | 44 if (result == IncognitoModePrefs::FORCED) |
| 43 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; | 45 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; |
| 44 return IncognitoModePrefs::DISABLED; | 46 return IncognitoModePrefs::DISABLED; |
| 45 } | 47 } |
| 48 #elif defined(OS_ANDROID) | |
| 49 if (chrome::android::ChromiumApplication::AreParentalControlsEnabled()) | |
| 50 return IncognitoModePrefs::DISABLED; | |
| 46 #endif // OS_WIN | 51 #endif // OS_WIN |
| 47 return result; | 52 return result; |
| 48 } | 53 } |
| 49 | 54 |
| 50 // static | 55 // static |
| 51 void IncognitoModePrefs::SetAvailability(PrefService* prefs, | 56 void IncognitoModePrefs::SetAvailability(PrefService* prefs, |
| 52 const Availability availability) { | 57 const Availability availability) { |
| 53 prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); | 58 prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); |
| 54 } | 59 } |
| 55 | 60 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 80 case IncognitoModePrefs::DISABLED: | 85 case IncognitoModePrefs::DISABLED: |
| 81 return !profile->IsOffTheRecord(); | 86 return !profile->IsOffTheRecord(); |
| 82 case IncognitoModePrefs::FORCED: | 87 case IncognitoModePrefs::FORCED: |
| 83 return profile->IsOffTheRecord(); | 88 return profile->IsOffTheRecord(); |
| 84 case IncognitoModePrefs::AVAILABILITY_NUM_TYPES: | 89 case IncognitoModePrefs::AVAILABILITY_NUM_TYPES: |
| 85 NOTREACHED(); | 90 NOTREACHED(); |
| 86 } | 91 } |
| 87 NOTREACHED(); | 92 NOTREACHED(); |
| 88 return false; | 93 return false; |
| 89 } | 94 } |
| OLD | NEW |