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

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

Issue 7655019: Migrate Obsolete NotificationsSettings and remove content_settings::NotificationsProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove include of deleted notifications_prefs_cache.h Created 9 years, 4 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
deleted file mode 100644
index cacf1361e31d7eb9d1a185e35feac7aa5c2967ba..0000000000000000000000000000000000000000
--- a/chrome/browser/notifications/notifications_prefs_cache.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// 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.
-
-#include "chrome/browser/notifications/notifications_prefs_cache.h"
-
-#include <string>
-
-#include "base/string_util.h"
-#include "base/values.h"
-#include "base/utf_string_conversions.h"
-#include "content/browser/browser_thread.h"
-
-NotificationsPrefsCache::NotificationsPrefsCache()
- : default_content_setting_(CONTENT_SETTING_DEFAULT),
- is_initialized_(false) {
-}
-
-void NotificationsPrefsCache::CacheAllowedOrigin(
- const GURL& origin) {
- CheckThreadAccess();
- std::set<GURL>::iterator iter;
- allowed_origins_.insert(origin);
- if ((iter = denied_origins_.find(origin)) != denied_origins_.end())
- denied_origins_.erase(iter);
-}
-
-void NotificationsPrefsCache::CacheDeniedOrigin(
- const GURL& origin) {
- CheckThreadAccess();
- std::set<GURL>::iterator iter;
- denied_origins_.insert(origin);
- if ((iter = allowed_origins_.find(origin)) != allowed_origins_.end())
- allowed_origins_.erase(iter);
-}
-
-void NotificationsPrefsCache::SetCacheAllowedOrigins(
- const std::vector<GURL>& allowed) {
- allowed_origins_.clear();
- allowed_origins_.insert(allowed.begin(), allowed.end());
-}
-
-void NotificationsPrefsCache::SetCacheDeniedOrigins(
- const std::vector<GURL>& denied) {
- denied_origins_.clear();
- denied_origins_.insert(denied.begin(), denied.end());
-}
-
-void NotificationsPrefsCache::SetCacheDefaultContentSetting(
- ContentSetting setting) {
- default_content_setting_ = setting;
-}
-
-// static
-void NotificationsPrefsCache::ListValueToGurlVector(
- const ListValue& origin_list,
- std::vector<GURL>* origin_vector) {
- ListValue::const_iterator i;
- std::string origin;
- for (i = origin_list.begin(); i != origin_list.end(); ++i) {
- (*i)->GetAsString(&origin);
- origin_vector->push_back(GURL(origin));
- }
-}
-
-WebKit::WebNotificationPresenter::Permission
- NotificationsPrefsCache::HasPermission(const GURL& origin) {
- if (IsOriginAllowed(origin))
- return WebKit::WebNotificationPresenter::PermissionAllowed;
- if (IsOriginDenied(origin))
- return WebKit::WebNotificationPresenter::PermissionDenied;
- 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;
- }
-}
-
-NotificationsPrefsCache::~NotificationsPrefsCache() {}
-
-bool NotificationsPrefsCache::IsOriginAllowed(
- const GURL& origin) {
- CheckThreadAccess();
- return allowed_origins_.find(origin) != allowed_origins_.end();
-}
-
-bool NotificationsPrefsCache::IsOriginDenied(
- const GURL& origin) {
- CheckThreadAccess();
- return denied_origins_.find(origin) != denied_origins_.end();
-}
-
-void NotificationsPrefsCache::CheckThreadAccess() {
- if (is_initialized_) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- } else {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- }
-}

Powered by Google App Engine
This is Rietveld 408576698