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

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: Default to creating incognito windows when incognito param is not specified. 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..3d4cc67ea432b74968bda2d22eb11e1f6b8ed546 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -387,36 +387,46 @@ bool CreateWindowFunction::RunImpl() {
panel_bounds.set_height(bounds_val);
}
+ const IncognitoModePrefs::Availability incognito_availability =
Joao da Silva 2011/10/28 11:05:29 These checks are scoped inside an "if (args)" bloc
rustema 2011/10/29 06:43:21 Done.
+ 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) {
+ if (incognito && incognito_availability == IncognitoModePrefs::DISABLED) {
error_ = keys::kIncognitoModeIsDisabled;
return false;
}
+ if (!incognito && incognito_availability == IncognitoModePrefs::FORCED) {
+ error_ = keys::kIncognitoModeIsForced;
+ return false;
+ }
+ } else if (incognito_availability == IncognitoModePrefs::FORCED) {
+ // If incognito argument is not specified explicitly, we default to
+ // incognito.
pastarmovj 2011/10/27 09:14:31 maybe extend this sentence to include "...when for
rustema 2011/10/29 06:43:21 Done.
+ incognito = true;
+ }
- if (incognito) {
- 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();) {
- if (browser::IsURLAllowedInIncognito(urls[i]) &&
- !Profile::IsGuestSession()) {
- if (first_url_erased.empty())
- first_url_erased = urls[i].spec();
- urls.erase(urls.begin() + i);
- } else {
- i++;
- }
- }
- if (urls.empty() && !first_url_erased.empty()) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(
- keys::kURLsNotAllowedInIncognitoError, first_url_erased);
- return false;
+ // If we are opening an incognito window.
+ if (incognito) {
+ 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();) {
+ if (browser::IsURLAllowedInIncognito(urls[i]) &&
+ !Profile::IsGuestSession()) {
+ if (first_url_erased.empty())
+ first_url_erased = urls[i].spec();
+ urls.erase(urls.begin() + i);
+ } else {
+ i++;
}
- window_profile = window_profile->GetOffTheRecordProfile();
}
+ if (urls.empty() && !first_url_erased.empty()) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(
+ keys::kURLsNotAllowedInIncognitoError, first_url_erased);
+ return false;
+ }
+ window_profile = window_profile->GetOffTheRecordProfile();
}
if (args->HasKey(keys::kFocusedKey)) {

Powered by Google App Engine
This is Rietveld 408576698