From 4e94ab3d72e4fd1cf76be4014721985dde1b724b Mon Sep 17 00:00:00 2001 From: "rustema@google.com" Date: Fri, 5 Aug 2011 05:28:27 +0000 Subject: 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 --- chrome/browser/ui/browser_init.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'chrome/browser/ui/browser_init.cc') 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(); } -- cgit v1.1