summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications/notifications_prefs_cache.h
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 05:44:26 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 05:44:26 +0000
commit4bb33630869981809c47c36c3c18813d6b005d34 (patch)
tree505252dfeac2de2d02a89d1f7e69ffcdf4affcf5 /chrome/browser/notifications/notifications_prefs_cache.h
parenta93244407e205a8619d620ce91bafbdf88eab195 (diff)
downloadchromium_src-4bb33630869981809c47c36c3c18813d6b005d34.zip
chromium_src-4bb33630869981809c47c36c3c18813d6b005d34.tar.gz
chromium_src-4bb33630869981809c47c36c3c18813d6b005d34.tar.bz2
Browser side support (sans UI) for desktop notifications.
BUG=none TEST=none Review URL: http://codereview.chromium.org/194108 Review URL: http://codereview.chromium.org/271052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications/notifications_prefs_cache.h')
-rw-r--r--chrome/browser/notifications/notifications_prefs_cache.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/notifications/notifications_prefs_cache.h b/chrome/browser/notifications/notifications_prefs_cache.h
new file mode 100644
index 0000000..e873da7
--- /dev/null
+++ b/chrome/browser/notifications/notifications_prefs_cache.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 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.
+
+#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H
+#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H
+
+#include <set>
+
+#include "base/ref_counted.h"
+#include "googleurl/src/gurl.h"
+
+class ListValue;
+
+// Class which caches notification preferences.
+// Construction occurs on the UI thread when the contents
+// of the profile preferences are initially cached. Once constructed
+// this class should only be accessed on the IO thread.
+class NotificationsPrefsCache :
+ public base::RefCountedThreadSafe<NotificationsPrefsCache> {
+ public:
+ NotificationsPrefsCache(ListValue* allowed, ListValue* denied);
+
+ // Checks to see if a given origin has permission to create desktop
+ // notifications. Returns a constant from WebNotificationPresenter
+ // class.
+ int HasPermission(const GURL& origin);
+
+ // Updates the cache with a new origin allowed or denied.
+ void CacheAllowedOrigin(const GURL& origin);
+ void CacheDeniedOrigin(const GURL& origin);
+
+ private:
+ // Helper functions which read preferences.
+ bool IsOriginAllowed(const GURL& origin);
+ bool IsOriginDenied(const GURL& origin);
+
+ // Storage of the actual preferences.
+ std::set<GURL> allowed_origins_;
+ std::set<GURL> denied_origins_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationsPrefsCache);
+};
+
+#endif // #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H