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" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include <windows.h> | 25 #include <windows.h> |
26 #include <wpcapi.h> | 26 #include <wpcapi.h> |
27 #include "base/bind.h" | 27 #include "base/bind.h" |
28 #include "base/bind_helpers.h" | 28 #include "base/bind_helpers.h" |
29 #include "base/memory/singleton.h" | 29 #include "base/memory/singleton.h" |
30 #include "base/win/scoped_comptr.h" | 30 #include "base/win/scoped_comptr.h" |
31 #include "base/win/windows_version.h" | 31 #include "base/win/windows_version.h" |
32 #endif // OS_WIN | 32 #endif // OS_WIN |
33 | 33 |
34 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
35 #include "chrome/browser/android/chrome_application.h" | 35 #include "base/android/jni_android.h" |
36 #include "jni/PartnerBrowserCustomizations_jni.h" | |
Bernhard Bauer
2017/03/27 10:09:40
Including JNI headers in arbitrary .cc files is a
estevenson
2017/03/27 20:03:53
Done.
| |
36 #endif // defined(OS_ANDROID) | 37 #endif // defined(OS_ANDROID) |
37 | 38 |
38 using content::BrowserThread; | 39 using content::BrowserThread; |
39 | 40 |
40 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
41 namespace { | 42 namespace { |
42 | 43 |
43 // This singleton allows us to attempt to calculate the Platform Parental | 44 // 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 | 45 // 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 | 46 // value. If the UI thread finishes sooner than we expect, that's no worse than |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 base::Bind( | 207 base::Bind( |
207 base::IgnoreResult(&PlatformParentalControlsValue::GetInstance))); | 208 base::IgnoreResult(&PlatformParentalControlsValue::GetInstance))); |
208 } | 209 } |
209 #endif | 210 #endif |
210 | 211 |
211 // static | 212 // static |
212 bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { | 213 bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { |
213 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
214 return PlatformParentalControlsValue::GetInstance()->is_enabled(); | 215 return PlatformParentalControlsValue::GetInstance()->is_enabled(); |
215 #elif defined(OS_ANDROID) | 216 #elif defined(OS_ANDROID) |
216 return chrome::android::ChromeApplication::AreParentalControlsEnabled(); | 217 return Java_PartnerBrowserCustomizations_areParentalControlsEnabled( |
218 base::android::AttachCurrentThread()); | |
217 #else | 219 #else |
218 return false; | 220 return false; |
219 #endif | 221 #endif |
220 } | 222 } |
221 | 223 |
222 // static | 224 // static |
223 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailabilityInternal( | 225 IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailabilityInternal( |
224 const PrefService* pref_service, | 226 const PrefService* pref_service, |
225 GetAvailabilityMode mode) { | 227 GetAvailabilityMode mode) { |
226 DCHECK(pref_service); | 228 DCHECK(pref_service); |
227 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); | 229 int pref_value = pref_service->GetInteger(prefs::kIncognitoModeAvailability); |
228 Availability result = IncognitoModePrefs::ENABLED; | 230 Availability result = IncognitoModePrefs::ENABLED; |
229 bool valid = IntToAvailability(pref_value, &result); | 231 bool valid = IntToAvailability(pref_value, &result); |
230 DCHECK(valid); | 232 DCHECK(valid); |
231 if (result != IncognitoModePrefs::DISABLED && | 233 if (result != IncognitoModePrefs::DISABLED && |
232 mode == CHECK_PARENTAL_CONTROLS && ArePlatformParentalControlsEnabled()) { | 234 mode == CHECK_PARENTAL_CONTROLS && ArePlatformParentalControlsEnabled()) { |
233 if (result == IncognitoModePrefs::FORCED) | 235 if (result == IncognitoModePrefs::FORCED) |
234 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; | 236 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; |
235 return IncognitoModePrefs::DISABLED; | 237 return IncognitoModePrefs::DISABLED; |
236 } | 238 } |
237 return result; | 239 return result; |
238 } | 240 } |
OLD | NEW |