diff options
author | guohui@chromium.org <guohui@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 22:46:35 +0000 |
---|---|---|
committer | guohui@chromium.org <guohui@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-20 22:46:35 +0000 |
commit | e3fd0bd10b02144e394532f2be15cfc0cfe27382 (patch) | |
tree | 714abe2193addfe9f8641a81e7b4bd89e4bd3842 | |
parent | db25a7e9bf34e638a1cbb4c8974ca566c22eb62c (diff) | |
download | chromium_src-e3fd0bd10b02144e394532f2be15cfc0cfe27382.zip chromium_src-e3fd0bd10b02144e394532f2be15cfc0cfe27382.tar.gz chromium_src-e3fd0bd10b02144e394532f2be15cfc0cfe27382.tar.bz2 |
Disable incognito link if parental control is on
The CL disables the incognito link on the gaia page if parental control is on. It adds a cached version for windows parental control check so that it may be accessed from IO thread. A similar CL for thread-safe android parental control check is under review at https://chrome-internal-review.googlesource.com/#/c/166265/.
BUG=383682
Review URL: https://codereview.chromium.org/336213005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278848 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chrome_browser_main_win.cc | 3 | ||||
-rw-r--r-- | chrome/browser/prefs/incognito_mode_prefs.cc | 25 | ||||
-rw-r--r-- | chrome/browser/prefs/incognito_mode_prefs.h | 11 | ||||
-rw-r--r-- | chrome/browser/signin/signin_header_helper.cc | 4 |
4 files changed, 41 insertions, 2 deletions
diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index e3aac45..c03597d 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -27,6 +27,7 @@ #include "chrome/browser/chrome_elf_init_win.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/install_verification/win/install_verification.h" +#include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_shortcut_manager.h" #include "chrome/browser/shell_integration.h" @@ -213,6 +214,8 @@ void ChromeBrowserMainPartsWin::PreMainMessageLoopStart() { // Make sure that we know how to handle exceptions from the message loop. InitializeWindowProcExceptions(); } + + IncognitoModePrefs::InitializePlatformParentalControls(); } int ChromeBrowserMainPartsWin::PreCreateThreads() { diff --git a/chrome/browser/prefs/incognito_mode_prefs.cc b/chrome/browser/prefs/incognito_mode_prefs.cc index 7d124ff..3b7b327 100644 --- a/chrome/browser/prefs/incognito_mode_prefs.cc +++ b/chrome/browser/prefs/incognito_mode_prefs.cc @@ -20,6 +20,14 @@ #include "chrome/browser/android/chromium_application.h" #endif // OS_ANDROID +#if defined(OS_WIN) +namespace { + +bool g_parental_control_on = false; + +} // empty namespace +#endif // OS_WIN + // static bool IncognitoModePrefs::IntToAvailability(int in_value, Availability* out_value) { @@ -102,3 +110,20 @@ bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { 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; +#elif defined(OS_ANDROID) + return chrome::android::ChromiumApplication::AreParentalControlsEnabled(); +#else + return false; +#endif +} + diff --git a/chrome/browser/prefs/incognito_mode_prefs.h b/chrome/browser/prefs/incognito_mode_prefs.h index d7d8d29..0837cb4 100644 --- a/chrome/browser/prefs/incognito_mode_prefs.h +++ b/chrome/browser/prefs/incognito_mode_prefs.h @@ -63,6 +63,17 @@ class IncognitoModePrefs { // open new windows. static bool CanOpenBrowser(Profile* profile); + // Returns whether parental controls have been enabled on the platform. This + // method simply returns a cached value and thus the result may be stale. May + // be called on any thread. + static bool ArePlatformParentalControlsEnabledCached(); + +#if defined(OS_WIN) + // Initializes the parental control settings. Must be called on UI thread and + // before |ArePlatformParentalControlsEnabled|. + static void InitializePlatformParentalControls(); +#endif // OS_WIN + private: // Returns whether parental controls have been enabled on the platform, which // if enabled will overrule the Availability as configured in prefs. diff --git a/chrome/browser/signin/signin_header_helper.cc b/chrome/browser/signin/signin_header_helper.cc index c3b1b96..b2c8891 100644 --- a/chrome/browser/signin/signin_header_helper.cc +++ b/chrome/browser/signin/signin_header_helper.cc @@ -224,9 +224,9 @@ bool AppendMirrorRequestHeaderIfPossible( std::string account_id(io_data->google_services_account_id()->GetValue()); int profile_mode_mask = PROFILE_MODE_DEFAULT; - // TODO(guohui): Needs to check for parent control as well. if (io_data->incognito_availibility()->GetValue() == - IncognitoModePrefs::DISABLED) { + IncognitoModePrefs::DISABLED || + IncognitoModePrefs::ArePlatformParentalControlsEnabledCached()) { profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED; } |