| 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..90d57ee92ea1e16e080c6b2a76d5276de83039fe 100644
|
| --- a/chrome/browser/ui/webui/options/content_settings_handler.cc
|
| +++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
|
| @@ -16,6 +16,7 @@
|
| #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/host_content_settings_map.h"
|
| #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
|
| #include "chrome/browser/notifications/desktop_notification_service.h"
|
| @@ -61,6 +62,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 +616,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);
|
| @@ -669,12 +673,23 @@ void ContentSettingsHandler::RemoveException(const ListValue* args) {
|
| // 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();
|
| + if (cookie_settings == NULL) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| + cookie_settings->ResetCookieSetting(
|
| + ContentSettingsPattern::FromString(pattern));
|
| + } else {
|
| + settings_map->SetContentSetting(
|
| + ContentSettingsPattern::FromString(pattern),
|
| + ContentSettingsPattern::Wildcard(),
|
| + ContentSettingsTypeFromGroupName(type_string),
|
| + "",
|
| + CONTENT_SETTING_DEFAULT);
|
| + }
|
| }
|
| }
|
| }
|
| @@ -700,16 +715,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 +787,15 @@ HostContentSettingsMap*
|
| return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap();
|
| return NULL;
|
| }
|
| +
|
| +CookieSettings* ContentSettingsHandler::GetCookieSettings() {
|
| + return CookieSettings::GetForProfile(Profile::FromWebUI(web_ui_));
|
| +}
|
| +
|
| +CookieSettings* ContentSettingsHandler::GetOTRCookieSettings() {
|
| + Profile* profile = Profile::FromWebUI(web_ui_);
|
| + if (profile->HasOffTheRecordProfile())
|
| + return CookieSettings::GetForProfile(
|
| + profile->GetOffTheRecordProfile());
|
| + return NULL;
|
| +}
|
|
|