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

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

Issue 376253005: Migrate the notification permission to the new common permission classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 69e9ca9a6a39969b1e1c1b12b9e8f40656992793..00672f543f838d6ae1f57b4e2f4086ee353abe84 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -13,6 +13,7 @@
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/extensions/app_icon_loader_impl.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/favicon/favicon_service.h"
@@ -324,17 +325,23 @@ void MessageCenterSettingsController::SetNotifierEnabled(
// since it has the exact URL pattern.
// TODO(mukai): fix this.
ContentSetting default_setting =
- notification_service->GetDefaultContentSetting(NULL);
+ profile->GetHostContentSettingsMap()->GetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL);
+
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)) {
if (notifier.notifier_id.url.is_valid()) {
- if (enabled)
- notification_service->GrantPermission(notifier.notifier_id.url);
- else
- notification_service->DenyPermission(notifier.notifier_id.url);
+ ContentSettingsPattern primary_pattern =
+ ContentSettingsPattern::FromURLNoWildcard(notifier.notifier_id.url);
+ profile->GetHostContentSettingsMap()->SetContentSetting(
+ primary_pattern,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ NO_RESOURCE_IDENTIFIER,
+ enabled ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
} else {
LOG(ERROR) << "Invalid url pattern: "
<< notifier.notifier_id.url.spec();
@@ -343,7 +350,12 @@ void MessageCenterSettingsController::SetNotifierEnabled(
std::map<base::string16, ContentSettingsPattern>::const_iterator iter =
patterns_.find(notifier.name);
if (iter != patterns_.end()) {
- notification_service->ClearSetting(iter->second);
+ profile->GetHostContentSettingsMap()->SetContentSetting(
+ iter->second,
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ NO_RESOURCE_IDENTIFIER,
+ CONTENT_SETTING_DEFAULT);
} else {
LOG(ERROR) << "Invalid url pattern: "
<< notifier.notifier_id.url.spec();

Powered by Google App Engine
This is Rietveld 408576698