| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/features.h" | |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 20 #include "components/pref_registry/pref_registry_syncable.h" | 19 #include "components/pref_registry/pref_registry_syncable.h" |
| 21 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 22 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 23 | 22 |
| 24 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 25 #include <windows.h> | 24 #include <windows.h> |
| 26 #include <wpcapi.h> | 25 #include <wpcapi.h> |
| 27 #include "base/bind.h" | 26 #include "base/bind.h" |
| 28 #include "base/bind_helpers.h" | 27 #include "base/bind_helpers.h" |
| 29 #include "base/memory/singleton.h" | 28 #include "base/memory/singleton.h" |
| 30 #include "base/win/scoped_comptr.h" | 29 #include "base/win/scoped_comptr.h" |
| 31 #include "base/win/windows_version.h" | 30 #include "base/win/windows_version.h" |
| 32 #endif // OS_WIN | 31 #endif // OS_WIN |
| 33 | 32 |
| 34 #if BUILDFLAG(ANDROID_JAVA_UI) | 33 #if defined(OS_ANDROID) |
| 35 #include "chrome/browser/android/chrome_application.h" | 34 #include "chrome/browser/android/chrome_application.h" |
| 36 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 35 #endif // defined(OS_ANDROID) |
| 37 | 36 |
| 38 using content::BrowserThread; | 37 using content::BrowserThread; |
| 39 | 38 |
| 40 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 41 namespace { | 40 namespace { |
| 42 | 41 |
| 43 // This singleton allows us to attempt to calculate the Platform Parental | 42 // This singleton allows us to attempt to calculate the Platform Parental |
| 44 // Controls enabled value on a worker thread before the UI thread needs the | 43 // Controls enabled value on a worker thread before the UI thread needs the |
| 45 // value. If the UI thread finishes sooner than we expect, that's no worse than | 44 // value. If the UI thread finishes sooner than we expect, that's no worse than |
| 46 // today where we block. | 45 // today where we block. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 FROM_HERE, | 201 FROM_HERE, |
| 203 base::Bind( | 202 base::Bind( |
| 204 base::IgnoreResult(&PlatformParentalControlsValue::GetInstance))); | 203 base::IgnoreResult(&PlatformParentalControlsValue::GetInstance))); |
| 205 } | 204 } |
| 206 #endif | 205 #endif |
| 207 | 206 |
| 208 // static | 207 // static |
| 209 bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { | 208 bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { |
| 210 #if defined(OS_WIN) | 209 #if defined(OS_WIN) |
| 211 return PlatformParentalControlsValue::GetInstance()->is_enabled(); | 210 return PlatformParentalControlsValue::GetInstance()->is_enabled(); |
| 212 #elif BUILDFLAG(ANDROID_JAVA_UI) | 211 #elif defined(OS_ANDROID) |
| 213 return chrome::android::ChromeApplication::AreParentalControlsEnabled(); | 212 return chrome::android::ChromeApplication::AreParentalControlsEnabled(); |
| 214 #else | 213 #else |
| 215 return false; | 214 return false; |
| 216 #endif | 215 #endif |
| 217 } | 216 } |
| 218 | 217 |
| 219 // static | 218 // static |
| 220 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailabilityInternal( | 219 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailabilityInternal( |
| 221 const PrefService* pref_service, | 220 const PrefService* pref_service, |
| 222 GetAvailabilityMode mode) { | 221 GetAvailabilityMode mode) { |
| 223 DCHECK(pref_service); | 222 DCHECK(pref_service); |
| 224 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); | 223 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); |
| 225 Availability result = IncognitoModePrefs::ENABLED; | 224 Availability result = IncognitoModePrefs::ENABLED; |
| 226 bool valid = IntToAvailability(pref_value, &result); | 225 bool valid = IntToAvailability(pref_value, &result); |
| 227 DCHECK(valid); | 226 DCHECK(valid); |
| 228 if (result != IncognitoModePrefs::DISABLED && | 227 if (result != IncognitoModePrefs::DISABLED && |
| 229 mode == CHECK_PARENTAL_CONTROLS && ArePlatformParentalControlsEnabled()) { | 228 mode == CHECK_PARENTAL_CONTROLS && ArePlatformParentalControlsEnabled()) { |
| 230 if (result == IncognitoModePrefs::FORCED) | 229 if (result == IncognitoModePrefs::FORCED) |
| 231 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; | 230 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; |
| 232 return IncognitoModePrefs::DISABLED; | 231 return IncognitoModePrefs::DISABLED; |
| 233 } | 232 } |
| 234 return result; | 233 return result; |
| 235 } | 234 } |
| OLD | NEW |