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

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

Issue 7520023: Converted IncognitoForced boolean policy into IncognitoModeAvailability enum policy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Converted incognito pref functions to a class. Created 9 years, 5 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
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 7ff973d65f63f56b65df597fffd7cef3b841a007..fcf8e8a45f92c49d64f5301c9259ec7584ad7b1e 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_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);
@@ -1470,10 +1471,12 @@ void Browser::Stop() {
}
void Browser::NewWindow() {
+ IncognitoModePrefs::Availability incognito_avail =
+ IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
if (browser_defaults::kAlwaysOpenIncognitoWindow &&
+ incognito_avail != IncognitoModePrefs::DISABLED &&
(CommandLine::ForCurrentProcess()->HasSwitch(switches::kIncognito) ||
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoForced)) &&
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
+ incognito_avail == IncognitoModePrefs::FORCED)) {
NewIncognitoWindow();
return;
}
@@ -1487,7 +1490,8 @@ void Browser::NewWindow() {
}
void Browser::NewIncognitoWindow() {
- if (!profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled)) {
+ if (IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) ==
+ IncognitoModePrefs::DISABLED) {
NewWindow();
return;
}
@@ -2252,12 +2256,6 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kDevToolsDisabled,
false,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterBooleanPref(prefs::kIncognitoEnabled,
- true,
- PrefService::UNSYNCABLE_PREF);
- prefs->RegisterBooleanPref(prefs::kIncognitoForced,
- false,
- PrefService::UNSYNCABLE_PREF);
prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation,
-1,
PrefService::UNSYNCABLE_PREF);
@@ -3695,10 +3693,15 @@ void Browser::Observe(int type,
} else {
CreateInstantIfNecessary();
}
- } else if (pref_name == prefs::kIncognitoEnabled) {
+ } else if (pref_name == prefs::kIncognitoModeAvailability) {
+ IncognitoModePrefs::Availability available =
+ IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
+ command_updater_.UpdateCommandEnabled(
+ IDC_NEW_WINDOW,
+ available != IncognitoModePrefs::FORCED);
command_updater_.UpdateCommandEnabled(
IDC_NEW_INCOGNITO_WINDOW,
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled));
+ available != IncognitoModePrefs::DISABLED);
} else if (pref_name == prefs::kDevToolsDisabled) {
UpdateCommandsForDevTools();
if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
@@ -3833,10 +3836,15 @@ void Browser::InitCommandState() {
command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true);
// Window management commands
- command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true);
+ IncognitoModePrefs::Availability incognito_avail =
+ IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
+ command_updater_.UpdateCommandEnabled(
+ IDC_NEW_WINDOW,
+ incognito_avail != IncognitoModePrefs::FORCED);
command_updater_.UpdateCommandEnabled(
IDC_NEW_INCOGNITO_WINDOW,
- profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled));
+ incognito_avail != IncognitoModePrefs::DISABLED);
+
command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, true);
command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, true);
command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, true);

Powered by Google App Engine
This is Rietveld 408576698