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

Unified Diff: chrome/browser/notifications/message_center_settings_controller.cc

Issue 1103203002: Allow resetting Notification permission from the toast's context menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/notifications/message_center_settings_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/message_center_settings_controller.cc
diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc
index 3b6eed59a6266700c075c2d5c9272bb6a34a939e..70d674488056c2fbd3b89dfdb319b8172e6aa053 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -314,28 +314,42 @@ void MessageCenterSettingsController::SetNotifierEnabled(
DCHECK(default_setting == CONTENT_SETTING_ALLOW ||
default_setting == CONTENT_SETTING_BLOCK ||
default_setting == CONTENT_SETTING_ASK);
- if ((enabled && default_setting != CONTENT_SETTING_ALLOW) ||
- (!enabled && default_setting == CONTENT_SETTING_ALLOW)) {
+
+ // The content setting for notifications needs to clear when it changes to
+ // the default value or get explicitly set when it differs from the default.
+ bool differs_from_default_value =
+ (default_setting != CONTENT_SETTING_ALLOW && enabled) ||
+ (default_setting == CONTENT_SETTING_ALLOW && !enabled);
+
+ if (differs_from_default_value) {
if (notifier.notifier_id.url.is_valid()) {
- if (enabled)
+ if (enabled) {
DesktopNotificationProfileUtil::GrantPermission(
profile, notifier.notifier_id.url);
- else
+ } else {
DesktopNotificationProfileUtil::DenyPermission(
profile, notifier.notifier_id.url);
+ }
} else {
LOG(ERROR) << "Invalid url pattern: "
<< notifier.notifier_id.url.spec();
}
} else {
- std::map<base::string16, ContentSettingsPattern>::const_iterator iter =
- patterns_.find(notifier.name);
+ ContentSettingsPattern pattern;
+
+ const auto& iter = patterns_.find(notifier.name);
if (iter != patterns_.end()) {
- DesktopNotificationProfileUtil::ClearSetting(profile, iter->second);
+ pattern = iter->second;
+ } else if (notifier.notifier_id.url.is_valid()) {
+ pattern =
+ ContentSettingsPattern::FromURLNoWildcard(notifier.notifier_id.url);
} else {
LOG(ERROR) << "Invalid url pattern: "
<< notifier.notifier_id.url.spec();
}
+
+ if (pattern.IsValid())
+ DesktopNotificationProfileUtil::ClearSetting(profile, pattern);
}
} else {
notification_service->SetNotifierEnabled(notifier.notifier_id, enabled);
« no previous file with comments | « no previous file | chrome/browser/notifications/message_center_settings_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698