OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/ref_counted.h" |
| 11 #include "googleurl/src/gurl.h" |
| 12 |
| 13 class ListValue; |
| 14 |
| 15 // Class which caches notification preferences. |
| 16 // Construction occurs on the UI thread when the contents |
| 17 // of the profile preferences are initially cached. Once constructed |
| 18 // this class should only be accessed on the IO thread. |
| 19 class NotificationsPrefsCache : |
| 20 public base::RefCountedThreadSafe<NotificationsPrefsCache> { |
| 21 public: |
| 22 NotificationsPrefsCache(ListValue* allowed, ListValue* denied); |
| 23 |
| 24 // Checks to see if a given origin has permission to create desktop |
| 25 // notifications. Returns a constant from WebNotificationPresenter |
| 26 // class. |
| 27 int HasPermission(const GURL& origin); |
| 28 |
| 29 // Updates the cache with a new origin allowed or denied. |
| 30 void CacheAllowedOrigin(const GURL& origin); |
| 31 void CacheDeniedOrigin(const GURL& origin); |
| 32 |
| 33 private: |
| 34 // Helper functions which read preferences. |
| 35 bool IsOriginAllowed(const GURL& origin); |
| 36 bool IsOriginDenied(const GURL& origin); |
| 37 |
| 38 // Storage of the actual preferences. |
| 39 std::set<GURL> allowed_origins_; |
| 40 std::set<GURL> denied_origins_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(NotificationsPrefsCache); |
| 43 }; |
| 44 |
| 45 #endif // #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H |
OLD | NEW |