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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_
6 #define CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
18 namespace user_prefs
{
19 class PrefRegistrySyncable
;
22 // Specifies Incognito mode availability preferences.
23 class IncognitoModePrefs
{
25 // Possible values for Incognito mode availability. Please, do not change
26 // the order of entries since numeric values are exposed to users.
28 // Incognito mode enabled. Users may open pages in both Incognito mode and
29 // normal mode (the default behaviour).
31 // Incognito mode disabled. Users may not open pages in Incognito mode.
32 // Only normal mode is available for browsing.
34 // Incognito mode forced. Users may open pages *ONLY* in Incognito mode.
35 // Normal mode is not available for browsing.
38 AVAILABILITY_NUM_TYPES
41 // Register incognito related preferences.
42 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
44 // Returns kIncognitoModeAvailability preference value stored
45 // in the given pref service.
46 static Availability
GetAvailability(const PrefService
* prefs
);
48 // Sets kIncognitoModeAvailability preference to the specified availability
50 static void SetAvailability(PrefService
* prefs
,
51 const Availability availability
);
53 // Converts in_value into the corresponding Availability value. Returns true
54 // if conversion is successful (in_value is valid). Otherwise, returns false
55 // and *out_value is set to ENABLED.
56 static bool IntToAvailability(int in_value
, Availability
* out_value
);
58 // Returns true if the browser should start in incognito mode.
59 static bool ShouldLaunchIncognito(const base::CommandLine
& command_line
,
60 const PrefService
* prefs
);
62 // Returns true if |profile| can open a new Browser. This checks the incognito
63 // availability policies and verifies if the |profile| type is allowed to
65 static bool CanOpenBrowser(Profile
* profile
);
68 // Calculates and caches the platform parental controls enable value on a
70 static void InitializePlatformParentalControls();
73 // Returns whether parental controls have been enabled on the platform. This
74 // method evaluates and caches if the platform controls have been enabled on
75 // the first call, which must be on the UI thread when IO and blocking are
76 // allowed. Subsequent calls may be from any thread.
77 static bool ArePlatformParentalControlsEnabled() WARN_UNUSED_RESULT
;
80 DISALLOW_IMPLICIT_CONSTRUCTORS(IncognitoModePrefs
);
83 #endif // CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_