Chromium Code Reviews| 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); |