Chromium Code Reviews| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/threading/thread_restrictions.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "components/pref_registry/pref_registry_syncable.h" | 14 #include "components/pref_registry/pref_registry_syncable.h" |
| 15 #include "content/public/browser/browser_thread.h" | |
| 14 | 16 |
| 15 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 16 #include "base/win/metro.h" | 18 #include "base/win/metro.h" |
| 17 #endif // OS_WIN | 19 #endif // OS_WIN |
| 18 | 20 |
| 19 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
| 20 #include "chrome/browser/android/chromium_application.h" | 22 #include "chrome/browser/android/chromium_application.h" |
| 21 #endif // OS_ANDROID | 23 #endif // OS_ANDROID |
| 22 | 24 |
| 25 using content::BrowserThread; | |
| 26 | |
| 23 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 bool g_parental_control_on = false; | 30 // Possible values for the parental controls state. |
| 31 enum class ParentalControlsState { | |
| 32 // Parental controls state unknown. We have not queried for this value yet. | |
| 33 UNKNOWN = 0, | |
| 34 // Parental controls activity logging disabled. | |
| 35 ACTIVITY_LOGGING_DISABLED = 1, | |
| 36 // Parental controls activity logging enabled. | |
| 37 ACTIVITY_LOGGING_ENABLED = 2, | |
| 38 } g_parental_controls_state = ParentalControlsState::UNKNOWN; | |
| 27 | 39 |
| 28 } // empty namespace | 40 } // empty namespace |
| 29 #endif // OS_WIN | 41 #endif // OS_WIN |
| 30 | 42 |
| 31 // static | 43 // static |
| 32 bool IncognitoModePrefs::IntToAvailability(int in_value, | 44 bool IncognitoModePrefs::IntToAvailability(int in_value, |
| 33 Availability* out_value) { | 45 Availability* out_value) { |
| 34 if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) { | 46 if (in_value < 0 || in_value >= AVAILABILITY_NUM_TYPES) { |
| 35 *out_value = ENABLED; | 47 *out_value = ENABLED; |
| 36 return false; | 48 return false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 109 |
| 98 default: | 110 default: |
| 99 NOTREACHED(); | 111 NOTREACHED(); |
| 100 return false; | 112 return false; |
| 101 } | 113 } |
| 102 } | 114 } |
| 103 | 115 |
| 104 // static | 116 // static |
| 105 bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { | 117 bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() { |
| 106 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
| 107 // Disable incognito mode windows if parental controls are on. This is only | 119 if (g_parental_controls_state == ParentalControlsState::UNKNOWN) { |
| 108 // for Windows Vista and above. | 120 // 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.
| |
| 109 return base::win::IsParentalControlActivityLoggingOn(); | 121 // IO and waiting allowed. |
| 122 // Test: The thread may be initialized, so check that it's the UI thread. | |
| 123 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.
| |
| 124 !BrowserThread::IsThreadInitialized(BrowserThread::UI) || | |
| 125 BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 126 base::ThreadRestrictions::AssertIOAllowed(); | |
| 127 base::ThreadRestrictions::AssertWaitAllowed(); | |
| 128 g_parental_controls_state = | |
| 129 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.
| |
| 130 ParentalControlsState::ACTIVITY_LOGGING_ENABLED : | |
| 131 ParentalControlsState::ACTIVITY_LOGGING_DISABLED; | |
| 132 } | |
| 133 return g_parental_controls_state == | |
| 134 ParentalControlsState::ACTIVITY_LOGGING_ENABLED; | |
| 110 #elif defined(OS_ANDROID) | 135 #elif defined(OS_ANDROID) |
| 111 return chrome::android::ChromiumApplication::AreParentalControlsEnabled(); | 136 return chrome::android::ChromiumApplication::AreParentalControlsEnabled(); |
| 112 #else | 137 #else |
| 113 return false; | |
| 114 #endif | |
| 115 } | |
| 116 | |
| 117 #if defined(OS_WIN) | |
| 118 void IncognitoModePrefs::InitializePlatformParentalControls() { | |
| 119 g_parental_control_on = base::win::IsParentalControlActivityLoggingOn(); | |
| 120 } | |
| 121 #endif // OS_WIN | |
| 122 | |
| 123 bool IncognitoModePrefs::ArePlatformParentalControlsEnabledCached() { | |
| 124 #if defined(OS_WIN) | |
| 125 return g_parental_control_on; | |
| 126 #elif defined(OS_ANDROID) | |
| 127 return chrome::android::ChromiumApplication::AreParentalControlsEnabled(); | |
| 128 #else | |
| 129 return false; | 138 return false; |
| 130 #endif | 139 #endif |
| 131 } | 140 } |
| 132 | 141 |
| OLD | NEW |