Chromium Code Reviews| Index: chrome/browser/prefs/incognito_mode_prefs.cc |
| diff --git a/chrome/browser/prefs/incognito_mode_prefs.cc b/chrome/browser/prefs/incognito_mode_prefs.cc |
| index e0255d4947d11a90c3d2e5fbbd56f707459c811b..1821ceb0174e64d67a54c0074f6d4e7bc5136ccb 100644 |
| --- a/chrome/browser/prefs/incognito_mode_prefs.cc |
| +++ b/chrome/browser/prefs/incognito_mode_prefs.cc |
| @@ -23,7 +23,17 @@ |
| #if defined(OS_WIN) |
| namespace { |
| -bool g_parental_control_on = false; |
| +// Possible values for the parental controls state. |
| +enum class ParentalControlsState { |
| + // Parental controls state unknown. We have not queried for this value yet. |
| + UNKNOWN = 0, |
| + // Parental controls activity logging disabled. |
| + ACTIVITY_LOGGING_DISABLED = 1, |
| + // Parental controls activity logging enabled. |
| + ACTIVITY_LOGGING_ENABLED = 2, |
| +}; |
| +ParentalControlsState g_parental_controls_state = |
| + ParentalControlsState::UNKNOWN; |
| } // empty namespace |
| #endif // OS_WIN |
| @@ -47,7 +57,7 @@ IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability( |
| Availability result = IncognitoModePrefs::ENABLED; |
| bool valid = IntToAvailability(pref_value, &result); |
| DCHECK(valid); |
| - if (ArePlatformParentalControlsEnabled()) { |
| + if (ArePlatformParentalControlsEnabledCached()) { |
| if (result == IncognitoModePrefs::FORCED) |
| LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; |
| return IncognitoModePrefs::DISABLED; |
| @@ -101,28 +111,20 @@ bool IncognitoModePrefs::CanOpenBrowser(Profile* profile) { |
| } |
| } |
| -// static |
| -bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { |
| -#if defined(OS_WIN) |
| - // Disable incognito mode windows if parental controls are on. This is only |
| - // for Windows Vista and above. |
| - return base::win::IsParentalControlActivityLoggingOn(); |
| -#elif defined(OS_ANDROID) |
| - return chrome::android::ChromiumApplication::AreParentalControlsEnabled(); |
| -#else |
| - return false; |
| -#endif |
| -} |
| - |
| #if defined(OS_WIN) |
| void IncognitoModePrefs::InitializePlatformParentalControls() { |
|
msw
2015/02/27 02:08:28
Define this on all platforms and just do platform-
robliao
2015/02/27 02:14:02
Agreed with this at this point. The change started
|
| - g_parental_control_on = base::win::IsParentalControlActivityLoggingOn(); |
| + g_parental_controls_state = |
| + base::win::IsParentalControlActivityLoggingOn() ? |
| + ParentalControlsState::ACTIVITY_LOGGING_ENABLED : |
| + ParentalControlsState::ACTIVITY_LOGGING_DISABLED; |
| } |
| #endif // OS_WIN |
| bool IncognitoModePrefs::ArePlatformParentalControlsEnabledCached() { |
| #if defined(OS_WIN) |
| - return g_parental_control_on; |
| + DCHECK(g_parental_controls_state != ParentalControlsState::UNKNOWN); |
| + return g_parental_controls_state == |
| + ParentalControlsState::ACTIVITY_LOGGING_ENABLED; |
| #elif defined(OS_ANDROID) |
| return chrome::android::ChromiumApplication::AreParentalControlsEnabled(); |
| #else |