incognito_mode_prefs.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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.
4
5#ifndef CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_
6#define CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_
7
8#include "base/basictypes.h"
9
10class CommandLine;
11class PrefService;
12
13namespace user_prefs {
14class PrefRegistrySyncable;
15}
16
17// Specifies Incognito mode availability preferences.
18class IncognitoModePrefs {
19 public:
20  // Possible values for Incognito mode availability. Please, do not change
21  // the order of entries since numeric values are exposed to users.
22  enum Availability {
23    // Incognito mode enabled. Users may open pages in both Incognito mode and
24    // normal mode (the default behaviour).
25    ENABLED = 0,
26    // Incognito mode disabled. Users may not open pages in Incognito mode.
27    // Only normal mode is available for browsing.
28    DISABLED,
29    // Incognito mode forced. Users may open pages *ONLY* in Incognito mode.
30    // Normal mode is not available for browsing.
31    FORCED,
32
33    AVAILABILITY_NUM_TYPES
34  };
35
36  // Register incognito related preferences.
37  static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry);
38
39  // Returns kIncognitoModeAvailability preference value stored
40  // in the given pref service.
41  static Availability GetAvailability(const PrefService* prefs);
42
43  // Sets kIncognitoModeAvailability preference to the specified availability
44  // value.
45  static void SetAvailability(PrefService* prefs,
46                              const Availability availability);
47
48  // Converts in_value into the corresponding Availability value. Returns true
49  // if conversion is successful (in_value is valid). Otherwise, returns false
50  // and *out_value is set to ENABLED.
51  static bool IntToAvailability(int in_value, Availability* out_value);
52
53  // Returns true if the browser should start in incognito mode.
54  static bool ShouldLaunchIncognito(const CommandLine& command_line,
55                                    const PrefService* prefs);
56
57 private:
58  DISALLOW_IMPLICIT_CONSTRUCTORS(IncognitoModePrefs);
59};
60
61#endif  // CHROME_BROWSER_PREFS_INCOGNITO_MODE_PREFS_H_
62