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

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

Issue 2842043: Add a default content setting to the notifications service. (Closed)
Patch Set: '' Created 10 years, 6 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/notifications_prefs_cache.cc
diff --git a/chrome/browser/notifications/notifications_prefs_cache.cc b/chrome/browser/notifications/notifications_prefs_cache.cc
index 6a5172bb192956cc43089db8b3cfd0b098e0af67..2fec1e88c6e5d60ddf417a71518a7b8aae2b5610 100644
--- a/chrome/browser/notifications/notifications_prefs_cache.cc
+++ b/chrome/browser/notifications/notifications_prefs_cache.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,7 +11,8 @@
#include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h"
NotificationsPrefsCache::NotificationsPrefsCache()
- : is_initialized_(false) {
+ : default_content_setting_(CONTENT_SETTING_DEFAULT),
+ is_initialized_(false) {
}
void NotificationsPrefsCache::CacheAllowedOrigin(
@@ -44,6 +45,11 @@ void NotificationsPrefsCache::SetCacheDeniedOrigins(
denied_origins_.insert(denied.begin(), denied.end());
}
+void NotificationsPrefsCache::SetCacheDefaultContentSetting(
+ ContentSetting setting) {
+ default_content_setting_ = setting;
+}
+
// static
void NotificationsPrefsCache::ListValueToGurlVector(
const ListValue& origin_list,
@@ -61,19 +67,28 @@ int NotificationsPrefsCache::HasPermission(const GURL& origin) {
return WebKit::WebNotificationPresenter::PermissionAllowed;
if (IsOriginDenied(origin))
return WebKit::WebNotificationPresenter::PermissionDenied;
- return WebKit::WebNotificationPresenter::PermissionNotAllowed;
+ switch (default_content_setting_) {
+ case CONTENT_SETTING_ALLOW:
+ return WebKit::WebNotificationPresenter::PermissionAllowed;
+ case CONTENT_SETTING_BLOCK:
+ return WebKit::WebNotificationPresenter::PermissionDenied;
+ case CONTENT_SETTING_ASK:
+ case CONTENT_SETTING_DEFAULT:
+ default: // Make gcc happy.
+ return WebKit::WebNotificationPresenter::PermissionNotAllowed;
+ }
}
bool NotificationsPrefsCache::IsOriginAllowed(
const GURL& origin) {
CheckThreadAccess();
- return (allowed_origins_.find(origin) != allowed_origins_.end());
+ return allowed_origins_.find(origin) != allowed_origins_.end();
}
bool NotificationsPrefsCache::IsOriginDenied(
const GURL& origin) {
CheckThreadAccess();
- return (denied_origins_.find(origin) != denied_origins_.end());
+ return denied_origins_.find(origin) != denied_origins_.end();
}
void NotificationsPrefsCache::CheckThreadAccess() {

Powered by Google App Engine
This is Rietveld 408576698