| 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..57c6a2ecd0cd0af2de80e3cd71b992746e207f83 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_availability_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"
|
| @@ -364,10 +365,11 @@ SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
|
| 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)) {
|
| + // Safe to cast: value's been sanitized at initialization.
|
| + IncognitoModeAvailabilityPrefs::IncognitoModeAvailability incognito_avail =
|
| + static_cast<IncognitoModeAvailabilityPrefs::IncognitoModeAvailability>(
|
| + profile->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability));
|
| + if (incognito_avail == IncognitoModeAvailabilityPrefs::FORCED) {
|
| // 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 +538,12 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line,
|
| }
|
| #endif
|
|
|
| + // Safe to cast: the value has been sanitized at initialization.
|
| + IncognitoModeAvailabilityPrefs::IncognitoModeAvailability incognito_avail =
|
| + static_cast<IncognitoModeAvailabilityPrefs::IncognitoModeAvailability>(
|
| + profile->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability));
|
| // 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)) {
|
| + if (incognito_avail == IncognitoModeAvailabilityPrefs::FORCED) {
|
| profile = profile->GetOffTheRecordProfile();
|
| }
|
|
|
|
|