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

Unified Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 8373027: Prevent incognito windows from opening when incognito mode is disabled. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Moved test to extension_tabs_test.cc. Created 9 years, 2 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/extensions/extension_tabs_module.cc
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index bf40f57dfd0080acbe758e307eb7221d9f0c08c1..ac6876356d262ef90f8e91fcd20e29e3360ddab8 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -387,17 +387,17 @@ bool CreateWindowFunction::RunImpl() {
panel_bounds.set_height(bounds_val);
}
+ const IncognitoModePrefs::Availability incognito_availability =
+ IncognitoModePrefs::GetAvailability(profile_->GetPrefs());
bool incognito = false;
if (args->HasKey(keys::kIncognitoKey)) {
EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kIncognitoKey,
&incognito));
- if (IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) ==
- IncognitoModePrefs::DISABLED) {
- error_ = keys::kIncognitoModeIsDisabled;
- return false;
- }
-
if (incognito) {
+ if (incognito_availability == IncognitoModePrefs::DISABLED) {
+ error_ = keys::kIncognitoModeIsDisabled;
+ return false;
+ }
std::string first_url_erased;
// Guest session is an exception as it always opens in incognito mode.
for (size_t i = 0; i < urls.size();) {
@@ -418,6 +418,10 @@ bool CreateWindowFunction::RunImpl() {
window_profile = window_profile->GetOffTheRecordProfile();
}
}
+ if (!incognito && incognito_availability == IncognitoModePrefs::FORCED) {
+ error_ = keys::kIncognitoModeIsForced;
+ return false;
+ }
if (args->HasKey(keys::kFocusedKey)) {
EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kFocusedKey,

Powered by Google App Engine
This is Rietveld 408576698