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

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

Issue 6279012: Implement pref policy for disabling incognito mode.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698