| 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 #endif // OS_WIN |
| 18 | 18 |
| 19 #if defined(OS_ANDROID) |
| 20 #include "chrome/browser/android/chromium_application.h" |
| 21 #endif // OS_ANDROID |
| 22 |
| 19 // static | 23 // static |
| 20 bool IncognitoModePrefs::IntToAvailability(int in_value, | 24 bool IncognitoModePrefs::IntToAvailability(int in_value, |
| 21 Availability* out_value) { | 25 Availability* out_value) { |
| 22 if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) { | 26 if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) { |
| 23 *out_value = ENABLED; | 27 *out_value = ENABLED; |
| 24 return false; | 28 return false; |
| 25 } | 29 } |
| 26 *out_value = static_cast<Availability>(in_value); | 30 *out_value = static_cast<Availability>(in_value); |
| 27 return true; | 31 return true; |
| 28 } | 32 } |
| 29 | 33 |
| 30 // static | 34 // static |
| 31 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability( | 35 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability( |
| 32 const PrefService* pref_service) { | 36 const PrefService* pref_service) { |
| 33 DCHECK(pref_service); | 37 DCHECK(pref_service); |
| 34 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); | 38 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); |
| 35 Availability result = IncognitoModePrefs::ENABLED; | 39 Availability result = IncognitoModePrefs::ENABLED; |
| 36 bool valid = IntToAvailability(pref_value, &result); | 40 bool valid = IntToAvailability(pref_value, &result); |
| 37 DCHECK(valid); | 41 DCHECK(valid); |
| 38 #if defined(OS_WIN) | 42 if (ArePlatformParentalControlsEnabled()) { |
| 39 // Disable incognito mode windows if parental controls are on. This is only | |
| 40 // for Windows Vista and above. | |
| 41 if (base::win::IsParentalControlActivityLoggingOn()) { | |
| 42 if (result == IncognitoModePrefs::FORCED) | 43 if (result == IncognitoModePrefs::FORCED) |
| 43 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; | 44 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; |
| 44 return IncognitoModePrefs::DISABLED; | 45 return IncognitoModePrefs::DISABLED; |
| 45 } | 46 } |
| 46 #endif // OS_WIN | |
| 47 return result; | 47 return result; |
| 48 } | 48 } |
| 49 | 49 |
| 50 // static | 50 // static |
| 51 void IncognitoModePrefs::SetAvailability(PrefService* prefs, | 51 void IncognitoModePrefs::SetAvailability(PrefService* prefs, |
| 52 const Availability availability) { | 52 const Availability availability) { |
| 53 prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); | 53 prefs->SetInteger(prefs::kIncognitoModeAvailability, availability); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| (...skipping 23 matching lines...) Expand all Loading... |
| 80 case IncognitoModePrefs::DISABLED: | 80 case IncognitoModePrefs::DISABLED: |
| 81 return !profile->IsOffTheRecord(); | 81 return !profile->IsOffTheRecord(); |
| 82 case IncognitoModePrefs::FORCED: | 82 case IncognitoModePrefs::FORCED: |
| 83 return profile->IsOffTheRecord(); | 83 return profile->IsOffTheRecord(); |
| 84 case IncognitoModePrefs::AVAILABILITY_NUM_TYPES: | 84 case IncognitoModePrefs::AVAILABILITY_NUM_TYPES: |
| 85 NOTREACHED(); | 85 NOTREACHED(); |
| 86 } | 86 } |
| 87 NOTREACHED(); | 87 NOTREACHED(); |
| 88 return false; | 88 return false; |
| 89 } | 89 } |
| 90 |
| 91 // static |
| 92 bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { |
| 93 #if defined(OS_WIN) |
| 94 // Disable incognito mode windows if parental controls are on. This is only |
| 95 // for Windows Vista and above. |
| 96 return base::win::IsParentalControlActivityLoggingOn(); |
| 97 #elif defined(OS_ANDROID) |
| 98 return chrome::android::ChromiumApplication::AreParentalControlsEnabled(); |
| 99 #endif |
| 100 return false; |
| 101 } |
| OLD | NEW |