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

Unified Diff: chrome/browser/prefs/incognito_mode_prefs.cc

Issue 15670011: Prevent new Browser windows from violating the IncognitoModeAvailability policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser_tests Created 7 years, 7 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/prefs/incognito_mode_prefs.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/incognito_mode_prefs.cc
diff --git a/chrome/browser/prefs/incognito_mode_prefs.cc b/chrome/browser/prefs/incognito_mode_prefs.cc
index 4f5f7cf9b03eb8cc1a0e372acdb40e7748d10cb6..e899015397e8db7ebf6b9b83b71f3449afb68c15 100644
--- a/chrome/browser/prefs/incognito_mode_prefs.cc
+++ b/chrome/browser/prefs/incognito_mode_prefs.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/user_prefs/pref_registry_syncable.h"
@@ -70,3 +71,23 @@ bool IncognitoModePrefs::ShouldLaunchIncognito(
(command_line.HasSwitch(switches::kIncognito) ||
incognito_avail == IncognitoModePrefs::FORCED);
}
+
+// static
+bool IncognitoModePrefs::CanOpenBrowser(Profile* profile) {
+ // If this causes a crash in Browser then a window is being opened using a
+ // profile type that is disallowed by policy. The crash prevents the
+ // "forbidden" window type from opening at all, but the path that triggered
+ // it should be fixed.
Mattias Nissler (ping if slow) 2013/05/29 11:33:08 Shouldn't this comment go with the CHECK()?
Joao da Silva 2013/05/29 11:40:40 Done.
+ switch (GetAvailability(profile->GetPrefs())) {
+ case IncognitoModePrefs::ENABLED:
+ return true;
+ case IncognitoModePrefs::DISABLED:
+ return !profile->IsOffTheRecord();
+ case IncognitoModePrefs::FORCED:
+ return profile->IsOffTheRecord();
+ case IncognitoModePrefs::AVAILABILITY_NUM_TYPES:
+ NOTREACHED();
+ }
+ NOTREACHED();
+ return false;
+}
« no previous file with comments | « chrome/browser/prefs/incognito_mode_prefs.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698