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

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

Issue 8383004: Adding CookieSettings for storing cookie content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. 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/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 3ccff84367d1599a95bd007ac12ec9bdeefd87e4..d00443826fce8eab440913872ad275f5492b9b87 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/browser_process.h"
#include "chrome/browser/content_settings/content_settings_details.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"
@@ -384,6 +385,9 @@ std::string ContentSettingsHandler::GetSettingDefaultFromModel(
default_setting =
DesktopNotificationServiceFactory::GetForProfile(profile)->
GetDefaultContentSetting(provider_id);
+ } else if (type == CONTENT_SETTINGS_TYPE_COOKIES) {
+ default_setting = CookieSettings::GetForProfile(profile)->
+ GetDefaultCookieSetting(provider_id);
} else {
default_setting =
profile->GetHostContentSettingsMap()->
@@ -554,7 +558,10 @@ void ContentSettingsHandler::UpdateNotificationExceptionsView() {
void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
ContentSettingsType type) {
HostContentSettingsMap::SettingsForOneType entries;
- GetContentSettingsMap()->GetSettingsForOneType(type, "", &entries);
+ if (type == CONTENT_SETTINGS_TYPE_COOKIES)
+ GetCookieSettings()->GetCookieSettings(&entries);
+ else
+ GetContentSettingsMap()->GetSettingsForOneType(type, "", &entries);
ListValue exceptions;
for (size_t i = 0; i < entries.size(); ++i) {
@@ -598,7 +605,14 @@ void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
return;
HostContentSettingsMap::SettingsForOneType otr_entries;
- otr_settings_map->GetSettingsForOneType(type, "", &otr_entries);
+ if (type == CONTENT_SETTINGS_TYPE_COOKIES) {
+ const CookieSettings* otr_cookie_settings = GetOTRCookieSettings();
+ if (!otr_cookie_settings)
+ return;
+ otr_cookie_settings->GetCookieSettings(&otr_entries);
+ } else {
+ otr_settings_map->GetSettingsForOneType(type, "", &otr_entries);
+ }
ListValue otr_exceptions;
for (size_t i = 0; i < otr_entries.size(); ++i) {
@@ -708,18 +722,31 @@ void ContentSettingsHandler::RemoveException(const ListValue* args) {
rv = args->GetString(arg_i++, &pattern);
DCHECK(rv);
- 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();
+ // |cookie_settings| could be null if the mode was OTR but the OTR profile
+ // got destroyed before we received this message.
+ if (cookie_settings) {
+ cookie_settings->ResetCookieSetting(
+ ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard());
+ }
+ } else {
+ HostContentSettingsMap* settings_map =
+ mode == "normal" ? GetContentSettingsMap() :
+ GetOTRContentSettingsMap();
+ // |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);
+ }
}
}
}
@@ -742,19 +769,34 @@ void ContentSettingsHandler::SetException(const ListValue* args) {
return;
}
- HostContentSettingsMap* settings_map =
- mode == "normal" ? GetContentSettingsMap() :
- GetOTRContentSettingsMap();
+ if (type == CONTENT_SETTINGS_TYPE_COOKIES) {
+ CookieSettings* cookie_settings =
+ mode == "normal" ? GetCookieSettings() :
+ GetOTRCookieSettings();
- // 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));
+ // |cookie_settings| could be null if the mode was OTR but the OTR profile
+ // got destroyed before we received this message.
+ if (!cookie_settings)
+ return;
+ cookie_settings->SetCookieSetting(
+ ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard(),
+ ContentSettingFromString(setting));
+ } else {
+ HostContentSettingsMap* settings_map =
+ mode == "normal" ? GetContentSettingsMap() :
+ GetOTRContentSettingsMap();
+
+ // |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));
+ }
}
void ContentSettingsHandler::CheckExceptionPatternValidity(
@@ -809,3 +851,14 @@ 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;
+}

Powered by Google App Engine
This is Rietveld 408576698