[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 | |
[email protected] | 4771091 | 2012-01-06 18:54:13 | [diff] [blame] | 10 | class CommandLine; |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 11 | class PrefService; |
[email protected] | a2c1e551 | 2013-06-04 10:49:48 | [diff] [blame^] | 12 | class Profile; |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 13 | |
| 14 | namespace user_prefs { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 15 | class PrefRegistrySyncable; |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 16 | } |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 17 | |
| 18 | // Specifies Incognito mode availability preferences. |
| 19 | class IncognitoModePrefs { |
| 20 | public: |
| 21 | // Possible values for Incognito mode availability. Please, do not change |
| 22 | // the order of entries since numeric values are exposed to users. |
| 23 | enum Availability { |
| 24 | // Incognito mode enabled. Users may open pages in both Incognito mode and |
| 25 | // normal mode (the default behaviour). |
| 26 | ENABLED = 0, |
| 27 | // Incognito mode disabled. Users may not open pages in Incognito mode. |
| 28 | // Only normal mode is available for browsing. |
| 29 | DISABLED, |
| 30 | // Incognito mode forced. Users may open pages *ONLY* in Incognito mode. |
| 31 | // Normal mode is not available for browsing. |
| 32 | FORCED, |
| 33 | |
| 34 | AVAILABILITY_NUM_TYPES |
| 35 | }; |
| 36 | |
| 37 | // Register incognito related preferences. |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 38 | static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 39 | |
| 40 | // Returns kIncognitoModeAvailability preference value stored |
| 41 | // in the given pref service. |
| 42 | static Availability GetAvailability(const PrefService* prefs); |
| 43 | |
| 44 | // Sets kIncognitoModeAvailability preference to the specified availability |
| 45 | // value. |
| 46 | static void SetAvailability(PrefService* prefs, |
| 47 | const Availability availability); |
| 48 | |
| 49 | // Converts in_value into the corresponding Availability value. Returns true |
| 50 | // if conversion is successful (in_value is valid). Otherwise, returns false |
| 51 | // and *out_value is set to ENABLED. |
| 52 | static bool IntToAvailability(int in_value, Availability* out_value); |
| 53 | |
[email protected] | 4771091 | 2012-01-06 18:54:13 | [diff] [blame] | 54 | // Returns true if the browser should start in incognito mode. |
| 55 | static bool ShouldLaunchIncognito(const CommandLine& command_line, |
| 56 | const PrefService* prefs); |
| 57 | |
[email protected] | a2c1e551 | 2013-06-04 10:49:48 | [diff] [blame^] | 58 | // Returns true if |profile| can open a new Browser. This checks the incognito |
| 59 | // availability policies and verifies if the |profile| type is allowed to |
| 60 | // open new windows. |
| 61 | static bool CanOpenBrowser(Profile* profile); |
| 62 | |
[email protected] | 4e94ab3 | 2011-08-05 05:28:27 | [diff] [blame] | 63 | private: |
| 64 | DISALLOW_IMPLICIT_CONSTRUCTORS(IncognitoModePrefs); |
| 65 | }; |
| 66 | |
| 67 | #endif // CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_ |