Index: chrome/browser/ui/browser.cc |
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
index 7ff973d65f63f56b65df597fffd7cef3b841a007..0681af275560ffed2b0309d629978f5592fa58b3 100644 |
--- a/chrome/browser/ui/browser.cc |
+++ b/chrome/browser/ui/browser.cc |
@@ -55,6 +55,7 @@ |
#include "chrome/browser/net/url_fixer_upper.h" |
#include "chrome/browser/notifications/notification_ui_manager.h" |
#include "chrome/browser/platform_util.h" |
+#include "chrome/browser/prefs/incognito_mode_availability_prefs.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
#include "chrome/browser/profiles/profile.h" |
@@ -292,7 +293,7 @@ Browser::Browser(Type type, Profile* profile) |
profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); |
profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); |
profile_pref_registrar_.Add(prefs::kInstantEnabled, this); |
- profile_pref_registrar_.Add(prefs::kIncognitoEnabled, this); |
+ profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); |
InitCommandState(); |
BrowserList::AddBrowser(this); |
@@ -1471,9 +1472,8 @@ void Browser::Stop() { |
void Browser::NewWindow() { |
if (browser_defaults::kAlwaysOpenIncognitoWindow && |
- (CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito) || |
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) && |
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { |
+ profile_->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability) == |
+ IncognitoModeAvailabilityPrefs::FORCED) { |
NewIncognitoWindow(); |
return; |
} |
@@ -1487,7 +1487,8 @@ void Browser::NewWindow() { |
} |
void Browser::NewIncognitoWindow() { |
- if (!profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) { |
+ if (profile_->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability) == |
+ IncognitoModeAvailabilityPrefs::DISABLED) { |
NewWindow(); |
return; |
} |
@@ -2255,8 +2256,8 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { |
prefs->RegisterBooleanPref(prefs::kIncognitoEnabled, |
true, |
PrefService::UNSYNCABLE_PREF); |
- prefs->RegisterBooleanPref(prefs::kIncognitoForced, |
- false, |
+ prefs->RegisterIntegerPref(prefs::kIncognitoModeAvailability, |
Mattias Nissler (ping if slow)
2011/07/28 11:08:50
As mentioned, this should be moved to your helper
rustema
2011/07/29 06:49:23
Done.
|
+ IncognitoModeAvailabilityPrefs::ENABLED, |
PrefService::UNSYNCABLE_PREF); |
prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, |
-1, |
@@ -3695,10 +3696,18 @@ void Browser::Observe(int type, |
} else { |
CreateInstantIfNecessary(); |
} |
- } else if (pref_name == prefs::kIncognitoEnabled) { |
+ } else if (pref_name == prefs::kIncognitoModeAvailability) { |
+ IncognitoModeAvailabilityPrefs::IncognitoModeAvailability available = |
+ static_cast< |
+ IncognitoModeAvailabilityPrefs::IncognitoModeAvailability>( |
+ profile_->GetPrefs()->GetInteger( |
+ prefs::kIncognitoModeAvailability)); |
+ command_updater_.UpdateCommandEnabled( |
+ IDC_NEW_WINDOW, |
+ available != IncognitoModeAvailabilityPrefs::FORCED); |
command_updater_.UpdateCommandEnabled( |
IDC_NEW_INCOGNITO_WINDOW, |
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)); |
+ available != IncognitoModeAvailabilityPrefs::DISABLED); |
} else if (pref_name == prefs::kDevToolsDisabled) { |
UpdateCommandsForDevTools(); |
if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) |
@@ -3833,10 +3842,16 @@ void Browser::InitCommandState() { |
command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true); |
// Window management commands |
- command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true); |
+ IncognitoModeAvailabilityPrefs::IncognitoModeAvailability incognito_avail = |
+ static_cast<IncognitoModeAvailabilityPrefs::IncognitoModeAvailability>( |
+ profile_->GetPrefs()->GetInteger(prefs::kIncognitoModeAvailability)); |
+ command_updater_.UpdateCommandEnabled( |
+ IDC_NEW_WINDOW, |
+ incognito_avail != IncognitoModeAvailabilityPrefs::FORCED); |
command_updater_.UpdateCommandEnabled( |
IDC_NEW_INCOGNITO_WINDOW, |
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)); |
+ incognito_avail != IncognitoModeAvailabilityPrefs::DISABLED); |
+ |
command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); |
command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true); |
command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true); |