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..8d756e8e5c1a979f8c09cf544f1aac271833451f 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,27 @@ bool IncognitoModePrefs::CanOpenBrowser(Profile* profile) { |
| } |
| } |
| -// static |
| -bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { |
| +void IncognitoModePrefs::InitializePlatformParentalControls() { |
| #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 |
| + DCHECK(g_parental_controls_state == ParentalControlsState::UNKNOWN); |
| + g_parental_controls_state = |
| + base::win::IsParentalControlActivityLoggingOn() ? |
| + ParentalControlsState::ACTIVITY_LOGGING_ENABLED : |
| + ParentalControlsState::ACTIVITY_LOGGING_DISABLED; |
| +#endif // defined(OS_WIN) |
| } |
| +void IncognitoModePrefs::UninitializePlatformParentalControlsImpl() { |
| #if defined(OS_WIN) |
| -void IncognitoModePrefs::InitializePlatformParentalControls() { |
| - g_parental_control_on = base::win::IsParentalControlActivityLoggingOn(); |
| + g_parental_controls_state = ParentalControlsState::UNKNOWN; |
|
msw
2015/02/28 01:05:33
Why do tests have to do this? Will the system valu
robliao
2015/02/28 01:16:31
Turns out this state is shared between groups of t
|
| +#endif // defined(OS_WIN) |
| } |
| -#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 |