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