Index: chrome/browser/ui/browser.cc |
=================================================================== |
--- chrome/browser/ui/browser.cc (revision 72638) |
+++ chrome/browser/ui/browser.cc (working copy) |
@@ -221,11 +221,15 @@ |
registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, |
NotificationService::AllSources()); |
+ // NOTE: These prefs all need to be explicitly destroyed in the destructor |
+ // or you'll get a nasty surprise when you run the incognito tests. |
PrefService* local_state = g_browser_process->local_state(); |
if (local_state) |
printing_enabled_.Init(prefs::kPrintingEnabled, local_state, this); |
dev_tools_disabled_.Init(prefs::kDevToolsDisabled, |
profile_->GetPrefs(), this); |
+ incognito_mode_allowed_.Init(prefs::kIncognitoEnabled, |
+ profile_->GetPrefs(), this); |
InitCommandState(); |
BrowserList::AddBrowser(this); |
@@ -289,6 +293,7 @@ |
encoding_auto_detect_.Destroy(); |
printing_enabled_.Destroy(); |
dev_tools_disabled_.Destroy(); |
+ incognito_mode_allowed_.Destroy(); |
instant_enabled_.Destroy(); |
use_vertical_tabs_.Destroy(); |
@@ -1308,7 +1313,8 @@ |
void Browser::NewWindow() { |
if (browser_defaults::kAlwaysOpenIncognitoWindow && |
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito)) { |
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito) && |
+ incognito_mode_allowed_.GetValue()) { |
NewIncognitoWindow(); |
return; |
} |
@@ -1322,6 +1328,11 @@ |
} |
void Browser::NewIncognitoWindow() { |
+ if (!incognito_mode_allowed_.GetValue()) { |
+ NewWindow(); |
+ return; |
+ } |
+ |
UserMetrics::RecordAction(UserMetricsAction("NewIncognitoWindow"), profile_); |
Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile()); |
} |
@@ -1945,7 +1956,7 @@ |
switches::kDisableTabbedOptions)) { |
ShowOptionsTab(chrome::kLanguageOptionsSubPage); |
} else { |
- // Language options dialog has been replaced by DOMUI. |
+ // Language options dialog has been replaced by DOMUI. |
} |
} |
@@ -2041,6 +2052,7 @@ |
prefs->RegisterBooleanPref(prefs::kRemotingHasSetupCompleted, false); |
prefs->RegisterStringPref(prefs::kCloudPrintEmail, std::string()); |
prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, false); |
+ prefs->RegisterBooleanPref(prefs::kIncognitoEnabled, true); |
prefs->RegisterRealPref(prefs::kDefaultZoomLevel, 0.0); |
prefs->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0); |
// We need to register the type of this preference in order to query |
@@ -3444,7 +3456,8 @@ |
// Window management commands |
command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true); |
- command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); |
+ command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, |
+ incognito_mode_allowed_.GetValue()); |
command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true); |
command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true); |
command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true); |