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

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

Issue 969813005: Unify the Windows Parental Controls Platform Caching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chrome/browser/prefs/incognito_mode_prefs.h ('k') | chrome/browser/signin/signin_header_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..99f4c3fe21db81dbbf155e3b46fa1c040603f912 100644
--- a/chrome/browser/prefs/incognito_mode_prefs.cc
+++ b/chrome/browser/prefs/incognito_mode_prefs.cc
@@ -7,10 +7,12 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/prefs/pref_service.h"
+#include "base/threading/thread_restrictions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
+#include "content/public/browser/browser_thread.h"
#if defined(OS_WIN)
#include "base/win/metro.h"
@@ -20,10 +22,20 @@
#include "chrome/browser/android/chromium_application.h"
#endif // OS_ANDROID
+using content::BrowserThread;
+
#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,
+} g_parental_controls_state = ParentalControlsState::UNKNOWN;
} // empty namespace
#endif // OS_WIN
@@ -104,25 +116,22 @@ 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();
-}
-#endif // OS_WIN
-
-bool IncognitoModePrefs::ArePlatformParentalControlsEnabledCached() {
-#if defined(OS_WIN)
- return g_parental_control_on;
+ if (g_parental_controls_state == ParentalControlsState::UNKNOWN) {
+ // Production: The thread isn't initialized, so we're the only thread with
gab 2015/03/03 13:38:59 I don't really like having the implementation rely
robliao 2015/03/03 18:10:12 We already depend on this today. base::win::IsPare
gab 2015/03/03 18:22:59 Acknowledged.
+ // IO and waiting allowed.
+ // Test: The thread may be initialized, so check that it's the UI thread.
+ CHECK(
gab 2015/03/03 13:38:59 DCHECK is good enough for such things.
robliao 2015/03/03 18:10:12 If this condition fails, we are potentially presen
gab 2015/03/03 18:22:59 Acknowledged.
gab 2015/03/03 18:36:38 Actually going back on this, I don't think it's po
robliao 2015/03/03 18:52:42 Fair enough. Downgrading the check.
+ !BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
+ BrowserThread::CurrentlyOn(BrowserThread::UI));
+ base::ThreadRestrictions::AssertIOAllowed();
+ base::ThreadRestrictions::AssertWaitAllowed();
+ g_parental_controls_state =
+ base::win::IsParentalControlActivityLoggingOn() ?
gab 2015/03/03 13:39:00 I would argue that we should move the implementati
robliao 2015/03/03 18:10:12 I'm don't quite understand this comment. The reaso
gab 2015/03/03 18:22:59 I'm talking about moving the implementation of bas
robliao 2015/03/03 18:26:13 Ah gotcha. To confirm, the proposal to move this f
gab 2015/03/03 18:36:38 Yes.
+ ParentalControlsState::ACTIVITY_LOGGING_ENABLED :
+ ParentalControlsState::ACTIVITY_LOGGING_DISABLED;
+ }
+ return g_parental_controls_state ==
+ ParentalControlsState::ACTIVITY_LOGGING_ENABLED;
#elif defined(OS_ANDROID)
return chrome::android::ChromiumApplication::AreParentalControlsEnabled();
#else
« no previous file with comments | « chrome/browser/prefs/incognito_mode_prefs.h ('k') | chrome/browser/signin/signin_header_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698