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

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: Synced and All Unit Tests Fixed 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..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

Powered by Google App Engine
This is Rietveld 408576698