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