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

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: . 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..26bca035a91863d098d68de977de0588c3090a24 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()->
@@ -708,18 +712,30 @@ 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));
Bernhard Bauer 2011/10/25 13:11:21 Is it actually necessary to go through CookieSetti
marja 2011/10/26 13:03:21 There are 2 approaches: 1) Everything goes via Coo
Bernhard Bauer 2011/10/26 13:24:09 I think it's fine if code that is not specific to
marja 2011/10/27 08:48:51 Ok, I removed the CookieSettings usage here.
+ }
+ } 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 +758,33 @@ 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),
+ 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 +839,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