Commit 0f37669d authored by peter's avatar peter Committed by Commit bot

Make it possible to revoke Web Notification exceptions in content settings.

BUG=405441

Review URL: https://codereview.chromium.org/528333002

Cr-Commit-Position: refs/heads/master@{#294419}
parent 54c27ed7
......@@ -579,13 +579,10 @@ cr.define('options.contentSettings', function() {
return;
var dataItem = listItem.dataItem;
var args = [listItem.contentType];
if (listItem.contentType == 'notifications')
args.push(dataItem.origin, dataItem.setting);
else
args.push(listItem.mode, dataItem.origin, dataItem.embeddingOrigin);
chrome.send('removeException', args);
chrome.send('removeException', [listItem.contentType,
listItem.mode,
dataItem.origin,
dataItem.embeddingOrigin]);
},
};
......
......@@ -174,12 +174,18 @@ base::DictionaryValue* GetGeolocationExceptionForPage(
// in the desktop notifications exceptions table. Ownership of the pointer is
// passed to the caller.
base::DictionaryValue* GetNotificationExceptionForPage(
const ContentSettingsPattern& pattern,
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSetting setting,
const std::string& provider_name) {
std::string embedding_origin;
if (secondary_pattern != ContentSettingsPattern::Wildcard())
embedding_origin = secondary_pattern.ToString();
base::DictionaryValue* exception = new base::DictionaryValue();
exception->SetString(kSetting, ContentSettingToString(setting));
exception->SetString(kOrigin, pattern.ToString());
exception->SetString(kOrigin, primary_pattern.ToString());
exception->SetString(kEmbeddingOrigin, embedding_origin);
exception->SetString(kSource, provider_name);
return exception;
}
......@@ -841,7 +847,9 @@ void ContentSettingsHandler::UpdateNotificationExceptionsView() {
}
exceptions.Append(
GetNotificationExceptionForPage(i->primary_pattern, i->setting,
GetNotificationExceptionForPage(i->primary_pattern,
i->secondary_pattern,
i->setting,
i->source));
}
......@@ -1127,24 +1135,6 @@ void ContentSettingsHandler::GetExceptionsFromHostContentSettingsMap(
}
}
void ContentSettingsHandler::RemoveNotificationException(
const base::ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui());
std::string origin;
std::string setting;
bool rv = args->GetString(1, &origin);
DCHECK(rv);
rv = args->GetString(2, &setting);
DCHECK(rv);
ContentSetting content_setting = ContentSettingFromString(setting);
DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
content_setting == CONTENT_SETTING_BLOCK);
DesktopNotificationProfileUtil::ClearSetting(profile,
ContentSettingsPattern::FromString(origin));
}
void ContentSettingsHandler::RemoveMediaException(const base::ListValue* args) {
std::string mode;
bool rv = args->GetString(1, &mode);
......@@ -1327,17 +1317,10 @@ void ContentSettingsHandler::RemoveException(const base::ListValue* args) {
}
ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
switch (type) {
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
RemoveNotificationException(args);
break;
case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM)
RemoveMediaException(args);
break;
default:
else
RemoveExceptionFromHostContentSettingsMap(args, type);
break;
}
}
void ContentSettingsHandler::SetException(const base::ListValue* args) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment