Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4239)

Unified Diff: chrome/browser/ui/browser_init.cc

Issue 7520023: Converted IncognitoForced boolean policy into IncognitoModeAvailability enum policy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Converted incognito pref functions to a class. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser_init.cc
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index d6a6f3465af0b2a4eb1c980b503c556e77bd9c03..da6080a1302986812066f8b15400eb4153e2a9f1 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"
@@ -359,15 +360,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.
@@ -536,10 +544,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();
}

Powered by Google App Engine
This is Rietveld 408576698