Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8067)

Unified Diff: chrome/browser/prefs/incognito_mode_prefs.cc

Issue 950053002: Cache the Windows Parental Controls Platform Answer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit Test Fixes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bae288c839ab65351151b2c7c2b282ef9bee6f77 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 ParentalControlsState {
+ // Parental controls state unknown. We have not queried for this value yet.
+ PARENTAL_CONTROLS_STATE_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 =
+ PARENTAL_CONTROLS_STATE_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,19 @@ 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() {
- g_parental_control_on = base::win::IsParentalControlActivityLoggingOn();
+ g_parental_controls_state =
+ base::win::IsParentalControlActivityLoggingOn() ?
+ ACTIVITY_LOGGING_ENABLED :
+ ACTIVITY_LOGGING_DISABLED;
}
#endif // OS_WIN
bool IncognitoModePrefs::ArePlatformParentalControlsEnabledCached() {
#if defined(OS_WIN)
- return g_parental_control_on;
+ DCHECK(g_parental_controls_state != PARENTAL_CONTROLS_STATE_UNKNOWN);
+ return g_parental_controls_state == ACTIVITY_LOGGING_ENABLED;
#elif defined(OS_ANDROID)
return chrome::android::ChromiumApplication::AreParentalControlsEnabled();
#else

Powered by Google App Engine
This is Rietveld 408576698