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 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 5 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
12 #include "components/user_prefs/pref_registry_syncable.h" | 13 #include "components/user_prefs/pref_registry_syncable.h" |
13 | 14 |
14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
15 #include "base/win/metro.h" | 16 #include "base/win/metro.h" |
16 #endif // OS_WIN | 17 #endif // OS_WIN |
17 | 18 |
18 // static | 19 // static |
19 bool IncognitoModePrefs::IntToAvailability(int in_value, | 20 bool IncognitoModePrefs::IntToAvailability(int in_value, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 64 |
64 // static | 65 // static |
65 bool IncognitoModePrefs::ShouldLaunchIncognito( | 66 bool IncognitoModePrefs::ShouldLaunchIncognito( |
66 const CommandLine& command_line, | 67 const CommandLine& command_line, |
67 const PrefService* prefs) { | 68 const PrefService* prefs) { |
68 Availability incognito_avail = GetAvailability(prefs); | 69 Availability incognito_avail = GetAvailability(prefs); |
69 return incognito_avail != IncognitoModePrefs::DISABLED && | 70 return incognito_avail != IncognitoModePrefs::DISABLED && |
70 (command_line.HasSwitch(switches::kIncognito) || | 71 (command_line.HasSwitch(switches::kIncognito) || |
71 incognito_avail == IncognitoModePrefs::FORCED); | 72 incognito_avail == IncognitoModePrefs::FORCED); |
72 } | 73 } |
| 74 |
| 75 // static |
| 76 bool IncognitoModePrefs::CanOpenBrowser(Profile* profile) { |
| 77 switch (GetAvailability(profile->GetPrefs())) { |
| 78 case IncognitoModePrefs::ENABLED: |
| 79 return true; |
| 80 case IncognitoModePrefs::DISABLED: |
| 81 return !profile->IsOffTheRecord(); |
| 82 case IncognitoModePrefs::FORCED: |
| 83 return profile->IsOffTheRecord(); |
| 84 case IncognitoModePrefs::AVAILABILITY_NUM_TYPES: |
| 85 NOTREACHED(); |
| 86 } |
| 87 NOTREACHED(); |
| 88 return false; |
| 89 } |
OLD | NEW |