summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_init.cc
diff options
context:
space:
mode:
authorrustema@google.com <rustema@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 05:28:27 +0000
committerrustema@google.com <rustema@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 05:28:27 +0000
commit4e94ab3d72e4fd1cf76be4014721985dde1b724b (patch)
treec13ad27f4de1f44ee054929ead4960ca90039b90 /chrome/browser/ui/browser_init.cc
parent85acecb3f21d0905acae3fbbb27f904f15a6b878 (diff)
downloadchromium_src-4e94ab3d72e4fd1cf76be4014721985dde1b724b.zip
chromium_src-4e94ab3d72e4fd1cf76be4014721985dde1b724b.tar.gz
chromium_src-4e94ab3d72e4fd1cf76be4014721985dde1b724b.tar.bz2
Converted IncognitoForced boolean policy into IncognitoModeAvailability enum policy.
Enum may take 3 values: * ENABLED (default) - both normal and incognito modes are allowed. * DISABLED - incognito mode cannot be used. * FORCED - browsing is only possible in incognito mode. Mapped IncognitoEnabled::false to IncognitoModeAvailability::DISABLED when IncognitoModeAvailability policy/pref is not set. Removed IncognitoEnabled pref (no longer used). BUG=69580 TEST= Review URL: http://codereview.chromium.org/7520023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_init.cc')
-rw-r--r--chrome/browser/ui/browser_init.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 7fa78c3..0f672f3 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -31,6 +31,7 @@
#include "chrome/browser/net/predictor_api.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
+#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
@@ -360,15 +361,22 @@ bool SessionCrashedInfoBarDelegate::Accept() {
// Utility functions ----------------------------------------------------------
+bool IncognitoIsForced(const CommandLine& command_line,
+ const PrefService* prefs) {
+ IncognitoModePrefs::Availability incognito_avail =
+ IncognitoModePrefs::GetAvailability(prefs);
+ return incognito_avail != IncognitoModePrefs::DISABLED &&
+ (command_line.HasSwitch(switches::kIncognito) ||
+ incognito_avail == IncognitoModePrefs::FORCED);
+}
+
SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
Profile* profile) {
SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
if (command_line.HasSwitch(switches::kRestoreLastSession))
pref.type = SessionStartupPref::LAST;
- if ((command_line.HasSwitch(switches::kIncognito) ||
- profile->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) &&
- pref.type == SessionStartupPref::LAST &&
- profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
+ if (pref.type == SessionStartupPref::LAST &&
+ IncognitoIsForced(command_line, profile->GetPrefs())) {
// We don't store session information when incognito. If the user has
// chosen to restore last session and launched incognito, fallback to
// default launch behavior.
@@ -537,10 +545,9 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line,
}
#endif
- // Continue with the incognito profile from here on if --incognito
- if ((command_line.HasSwitch(switches::kIncognito) ||
- profile->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) &&
- profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
+ // Continue with the incognito profile from here on if Incognito mode
+ // is forced.
+ if (IncognitoIsForced(command_line, profile->GetPrefs())) {
profile = profile->GetOffTheRecordProfile();
}