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

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: add a test 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
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..bc3f74fcf3e79e62af29bd4032b4de7021518128 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -314,8 +314,12 @@ 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)) {
+
+ bool derive_from_default_value =
dewittj 2015/04/27 16:48:51 nit: derive isn't completely clear here.. Possibl
Peter Beverloo 2015/04/28 12:14:44 Done.
+ (default_setting != CONTENT_SETTING_ALLOW && enabled) ||
+ (default_setting == CONTENT_SETTING_ALLOW && !enabled);
+
+ if (derive_from_default_value) {
if (notifier.notifier_id.url.is_valid()) {
if (enabled)
dewittj 2015/04/27 16:48:51 nit: please add braces to this if/else since they
Peter Beverloo 2015/04/28 12:14:45 Done.
DesktopNotificationProfileUtil::GrantPermission(
@@ -328,14 +332,21 @@ void MessageCenterSettingsController::SetNotifierEnabled(
<< 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);

Powered by Google App Engine
This is Rietveld 408576698