summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 10:19:27 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 10:19:27 +0000
commite95a993bd76e6bcd3417c97fd9c8a02c1d5ba35e (patch)
tree5d7890959d1eaf5fb1cf6469a882499aff6489a8 /chrome/browser/ui
parenta0e0a75aab7812c7683a571cd31e7fb7496dbdb3 (diff)
downloadchromium_src-e95a993bd76e6bcd3417c97fd9c8a02c1d5ba35e.zip
chromium_src-e95a993bd76e6bcd3417c97fd9c8a02c1d5ba35e.tar.gz
chromium_src-e95a993bd76e6bcd3417c97fd9c8a02c1d5ba35e.tar.bz2
Implement pref policy for disabling incognito mode.
BUG=66413 TEST=None Review URL: http://codereview.chromium.org/6313008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser.cc16
-rw-r--r--chrome/browser/ui/browser.h3
-rw-r--r--chrome/browser/ui/browser_init.cc7
3 files changed, 21 insertions, 5 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index c95aa7d..03ee5e1 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -223,6 +223,8 @@ Browser::Browser(Type type, Profile* profile)
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);
@@ -1305,7 +1307,8 @@ void Browser::Stop() {
void Browser::NewWindow() {
if (browser_defaults::kAlwaysOpenIncognitoWindow &&
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito)) {
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito) &&
+ incognito_mode_allowed_.GetValue()) {
NewIncognitoWindow();
return;
}
@@ -1319,6 +1322,11 @@ void Browser::NewWindow() {
}
void Browser::NewIncognitoWindow() {
+ if (!incognito_mode_allowed_.GetValue()) {
+ NewWindow();
+ return;
+ }
+
UserMetrics::RecordAction(UserMetricsAction("NewIncognitoWindow"), profile_);
Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile());
}
@@ -1942,7 +1950,7 @@ void Browser::OpenLanguageOptionsDialog() {
switches::kDisableTabbedOptions)) {
ShowOptionsTab(chrome::kLanguageOptionsSubPage);
} else {
- // Language options dialog has been replaced by DOMUI.
+ // Language options dialog has been replaced by DOMUI.
}
}
@@ -2038,6 +2046,7 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
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
@@ -3441,7 +3450,8 @@ void Browser::InitCommandState() {
// 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);
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index d59030e..0ab7df6 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -1112,6 +1112,9 @@ class Browser : public TabHandlerDelegate,
// Keep track of when instant enabled changes.
BooleanPrefMember instant_enabled_;
+ // Tracks the preference that controls whether incognito mode is allowed.
+ BooleanPrefMember incognito_mode_allowed_;
+
// Indicates if command execution is blocked.
bool block_command_execution_;
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 6d93a53..d99c3df 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -370,7 +370,8 @@ SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
if (command_line.HasSwitch(switches::kRestoreLastSession))
pref.type = SessionStartupPref::LAST;
if (command_line.HasSwitch(switches::kIncognito) &&
- pref.type == SessionStartupPref::LAST) {
+ pref.type == SessionStartupPref::LAST &&
+ profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
// 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.
@@ -484,8 +485,10 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line,
#endif
// Continue with the off-the-record profile from here on if --incognito
- if (command_line.HasSwitch(switches::kIncognito))
+ if (command_line.HasSwitch(switches::kIncognito) &&
+ profile->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
profile = profile->GetOffTheRecordProfile();
+ }
BrowserInit::LaunchWithProfile lwp(cur_dir, command_line, this);
bool launched = lwp.Launch(profile, process_startup);