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

Unified Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 7713034: HostContentSettingsMap refactoring. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Code review comments. Created 9 years, 4 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/webui/options/content_settings_handler.cc
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc
index 365b07d555e39e6e759d593547d098b3ffd0abb5..95231d2fd3579d9d4546a654b3850e21a281fad6 100644
--- a/chrome/browser/ui/webui/options/content_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -16,6 +16,8 @@
#include "chrome/browser/content_settings/content_settings_details.h"
#include "chrome/browser/content_settings/content_settings_pattern.h"
#include "chrome/browser/content_settings/content_settings_utils.h"
+#include "chrome/browser/content_settings/cookie_settings.h"
+#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
@@ -61,6 +63,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"},
{CONTENT_SETTINGS_TYPE_INTENTS, "intents"},
{CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
+ {CONTENT_SETTINGS_TYPE_COOKIES_SESSION_ONLY, "cookies-session-only"},
};
COMPILE_ASSERT(arraysize(kContentSettingsTypeGroupNames) ==
CONTENT_SETTINGS_NUM_TYPES,
@@ -614,6 +617,8 @@ void ContentSettingsHandler::SetContentFilter(const ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui_);
DesktopNotificationServiceFactory::GetForProfile(profile)->
SetDefaultContentSetting(default_setting);
+ } else if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
+ GetCookieSettings()->SetDefaultSetting(default_setting);
} else {
GetContentSettingsMap()->
SetDefaultContentSetting(content_type, default_setting);
@@ -666,15 +671,24 @@ void ContentSettingsHandler::RemoveException(const ListValue* args) {
HostContentSettingsMap* settings_map =
mode == "normal" ? GetContentSettingsMap() :
GetOTRContentSettingsMap();
+
// The settings map could be null if the mode was OTR but the OTR profile
// got destroyed before we received this message.
if (settings_map) {
- settings_map->SetContentSetting(
- ContentSettingsPattern::FromString(pattern),
- ContentSettingsPattern::Wildcard(),
- ContentSettingsTypeFromGroupName(type_string),
- "",
- CONTENT_SETTING_DEFAULT);
+ if (type == CONTENT_SETTINGS_TYPE_COOKIES) {
+ CookieSettings* cookie_settings =
+ mode == "normal" ? GetCookieSettings() : GetOTRCookieSettings();
+ DCHECK(cookie_settings != NULL);
Bernhard Bauer 2011/09/01 11:41:54 I think we should be a bit more defensive here, as
marja 2011/09/01 13:34:48 Crash here would mean that GetContentSettingsMap r
+ cookie_settings->ResetCookieSetting(
+ ContentSettingsPattern::FromString(pattern));
+ } else {
+ settings_map->SetContentSetting(
+ ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard(),
+ ContentSettingsTypeFromGroupName(type_string),
+ "",
+ CONTENT_SETTING_DEFAULT);
+ }
}
}
}
@@ -700,16 +714,24 @@ void ContentSettingsHandler::SetException(const ListValue* args) {
HostContentSettingsMap* settings_map =
mode == "normal" ? GetContentSettingsMap() :
GetOTRContentSettingsMap();
-
// The settings map could be null if the mode was OTR but the OTR profile
// got destroyed before we received this message.
if (!settings_map)
return;
- settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern),
- ContentSettingsPattern::Wildcard(),
- type,
- "",
- ContentSettingFromString(setting));
+ if (type == CONTENT_SETTINGS_TYPE_COOKIES) {
+ CookieSettings* cookie_settings =
+ mode == "normal" ? GetCookieSettings() : GetOTRCookieSettings();
+ DCHECK(cookie_settings != NULL);
+ cookie_settings->SetCookieSetting(
+ ContentSettingsPattern::FromString(pattern),
+ ContentSettingFromString(setting));
+ } else {
+ settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard(),
+ type,
+ "",
+ ContentSettingFromString(setting));
+ }
}
void ContentSettingsHandler::CheckExceptionPatternValidity(
@@ -764,3 +786,15 @@ HostContentSettingsMap*
return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap();
return NULL;
}
+
+CookieSettings* ContentSettingsHandler::GetCookieSettings() {
+ return CookieSettingsFactory::GetForProfile(Profile::FromWebUI(web_ui_));
+}
+
+CookieSettings* ContentSettingsHandler::GetOTRCookieSettings() {
+ Profile* profile = Profile::FromWebUI(web_ui_);
+ if (profile->HasOffTheRecordProfile())
+ return CookieSettingsFactory::GetForProfile(
+ profile->GetOffTheRecordProfile());
+ return NULL;
+}

Powered by Google App Engine
This is Rietveld 408576698