[email protected] | 4771091 | 2012-01-06 18:54:13 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_ |
| 6 | #define CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_ |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | |
| 10 | class PrefService; |
[email protected] | a2c1e551 | 2013-06-04 10:49:48 | [diff] [blame] | 11 | class Profile; |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 12 | |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 13 | namespace base { |
| 14 | class CommandLine; |
| 15 | } |
| 16 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 17 | namespace user_prefs { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 18 | class PrefRegistrySyncable; |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 19 | } |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 20 | |
| 21 | // Specifies Incognito mode availability preferences. |
| 22 | class IncognitoModePrefs { |
| 23 | public: |
| 24 | // Possible values for Incognito mode availability. Please, do not change |
| 25 | // the order of entries since numeric values are exposed to users. |
| 26 | enum Availability { |
| 27 | // Incognito mode enabled. Users may open pages in both Incognito mode and |
| 28 | // normal mode (the default behaviour). |
| 29 | ENABLED = 0, |
| 30 | // Incognito mode disabled. Users may not open pages in Incognito mode. |
| 31 | // Only normal mode is available for browsing. |
| 32 | DISABLED, |
| 33 | // Incognito mode forced. Users may open pages *ONLY* in Incognito mode. |
| 34 | // Normal mode is not available for browsing. |
| 35 | FORCED, |
| 36 | |
| 37 | AVAILABILITY_NUM_TYPES |
| 38 | }; |
| 39 | |
| 40 | // Register incognito related preferences. |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame] | 41 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 42 | |
| 43 | // Returns kIncognitoModeAvailability preference value stored |
| 44 | // in the given pref service. |
| 45 | static Availability GetAvailability(const PrefService* prefs); |
| 46 | |
| 47 | // Sets kIncognitoModeAvailability preference to the specified availability |
| 48 | // value. |
| 49 | static void SetAvailability(PrefService* prefs, |
| 50 | const Availability availability); |
| 51 | |
| 52 | // Converts in_value into the corresponding Availability value. Returns true |
| 53 | // if conversion is successful (in_value is valid). Otherwise, returns false |
| 54 | // and *out_value is set to ENABLED. |
| 55 | static bool IntToAvailability(int in_value, Availability* out_value); |
| 56 | |
[email protected] | 4771091 | 2012-01-06 18:54:13 | [diff] [blame] | 57 | // Returns true if the browser should start in incognito mode. |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 58 | static bool ShouldLaunchIncognito(const base::CommandLine& command_line, |
[email protected] | 4771091 | 2012-01-06 18:54:13 | [diff] [blame] | 59 | const PrefService* prefs); |
| 60 | |
[email protected] | a2c1e551 | 2013-06-04 10:49:48 | [diff] [blame] | 61 | // Returns true if |profile| can open a new Browser. This checks the incognito |
| 62 | // availability policies and verifies if the |profile| type is allowed to |
| 63 | // open new windows. |
| 64 | static bool CanOpenBrowser(Profile* profile); |
| 65 | |
[email protected] | e3fd0bd | 2014-06-20 22:46:35 | [diff] [blame] | 66 | // Returns whether parental controls have been enabled on the platform. This |
| 67 | // method simply returns a cached value and thus the result may be stale. May |
| 68 | // be called on any thread. |
| 69 | static bool ArePlatformParentalControlsEnabledCached(); |
| 70 | |
| 71 | #if defined(OS_WIN) |
| 72 | // Initializes the parental control settings. Must be called on UI thread and |
| 73 | // before |ArePlatformParentalControlsEnabled|. |
| 74 | static void InitializePlatformParentalControls(); |
| 75 | #endif // OS_WIN |
| 76 | |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 77 | private: |
[email protected] | 1e4fdc0 | 2014-01-17 00:18:11 | [diff] [blame] | 78 | // Returns whether parental controls have been enabled on the platform, which |
| 79 | // if enabled will overrule the Availability as configured in prefs. |
| 80 | static bool ArePlatformParentalControlsEnabled(); |
| 81 | |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 82 | DISALLOW_IMPLICIT_CONSTRUCTORS(IncognitoModePrefs); |
| 83 | }; |
| 84 | |
| 85 | #endif // CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_ |