blob: 03ad9282af7fb1ae1ef93f0f7e2e74c810f03721 [file] [log] [blame]
[email protected]47710912012-01-06 18:54:131// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]4e94ab32011-08-05 05:28:272// 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]4e94ab32011-08-05 05:28:277
robliao4e3ceb422015-03-06 19:49:248#include "base/compiler_specific.h"
avib896c712015-12-26 02:10:439#include "base/macros.h"
10#include "build/build_config.h"
[email protected]4e94ab32011-08-05 05:28:2711
12class PrefService;
[email protected]a2c1e5512013-06-04 10:49:4813class Profile;
[email protected]443e9312013-05-06 06:17:3414
[email protected]2f3b1cc2014-03-17 23:07:1515namespace base {
16class CommandLine;
17}
18
[email protected]443e9312013-05-06 06:17:3419namespace user_prefs {
[email protected]c753f142013-02-10 13:14:0420class PrefRegistrySyncable;
[email protected]443e9312013-05-06 06:17:3421}
[email protected]4e94ab32011-08-05 05:28:2722
23// Specifies Incognito mode availability preferences.
24class IncognitoModePrefs {
25 public:
26 // Possible values for Incognito mode availability. Please, do not change
27 // the order of entries since numeric values are exposed to users.
28 enum Availability {
29 // Incognito mode enabled. Users may open pages in both Incognito mode and
Michael Thiessen0f4e7852019-03-11 16:00:4530 // normal mode (usually the default behaviour).
[email protected]4e94ab32011-08-05 05:28:2731 ENABLED = 0,
32 // Incognito mode disabled. Users may not open pages in Incognito mode.
33 // Only normal mode is available for browsing.
34 DISABLED,
35 // Incognito mode forced. Users may open pages *ONLY* in Incognito mode.
36 // Normal mode is not available for browsing.
37 FORCED,
38
39 AVAILABILITY_NUM_TYPES
40 };
41
Michael Thiessendb4bfdbd2019-10-07 23:22:3242 static constexpr Availability kDefaultAvailability = ENABLED;
Ian Vollick381389a62019-06-26 16:49:4043
[email protected]4e94ab32011-08-05 05:28:2744 // Register incognito related preferences.
[email protected]37ca3fe02013-07-05 15:32:4445 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
[email protected]4e94ab32011-08-05 05:28:2746
47 // Returns kIncognitoModeAvailability preference value stored
48 // in the given pref service.
49 static Availability GetAvailability(const PrefService* prefs);
50
51 // Sets kIncognitoModeAvailability preference to the specified availability
52 // value.
53 static void SetAvailability(PrefService* prefs,
54 const Availability availability);
55
56 // Converts in_value into the corresponding Availability value. Returns true
57 // if conversion is successful (in_value is valid). Otherwise, returns false
58 // and *out_value is set to ENABLED.
59 static bool IntToAvailability(int in_value, Availability* out_value);
60
[email protected]47710912012-01-06 18:54:1361 // Returns true if the browser should start in incognito mode.
[email protected]2f3b1cc2014-03-17 23:07:1562 static bool ShouldLaunchIncognito(const base::CommandLine& command_line,
[email protected]47710912012-01-06 18:54:1363 const PrefService* prefs);
64
[email protected]a2c1e5512013-06-04 10:49:4865 // Returns true if |profile| can open a new Browser. This checks the incognito
66 // availability policies and verifies if the |profile| type is allowed to
67 // open new windows.
68 static bool CanOpenBrowser(Profile* profile);
69
robliao99ed8262015-05-27 21:36:2170#if defined(OS_WIN)
71 // Calculates and caches the platform parental controls enable value on a
72 // worker thread.
73 static void InitializePlatformParentalControls();
74#endif
75
[email protected]e3fd0bd2014-06-20 22:46:3576 // Returns whether parental controls have been enabled on the platform. This
robliao4e3ceb422015-03-06 19:49:2477 // method evaluates and caches if the platform controls have been enabled on
78 // the first call, which must be on the UI thread when IO and blocking are
79 // allowed. Subsequent calls may be from any thread.
80 static bool ArePlatformParentalControlsEnabled() WARN_UNUSED_RESULT;
[email protected]e3fd0bd2014-06-20 22:46:3581
[email protected]4e94ab32011-08-05 05:28:2782 private:
asvitkineb62d7d92016-10-03 21:15:0383 // Specifies whether parental controls should be checked. See comment below.
84 enum GetAvailabilityMode {
85 CHECK_PARENTAL_CONTROLS,
86 DONT_CHECK_PARENTAL_CONTROLS,
87 };
88
89 // Internal version of GetAvailability() that specifies whether parental
90 // controls should be checked (which is expensive and not always necessary
91 // to do - such as when checking for FORCED state).
92 static Availability GetAvailabilityInternal(const PrefService* pref_service,
93 GetAvailabilityMode mode);
94
[email protected]4e94ab32011-08-05 05:28:2795 DISALLOW_IMPLICIT_CONSTRUCTORS(IncognitoModePrefs);
96};
97
98#endif // CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_