| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/common/content_settings.h" | 13 #include "chrome/common/content_settings.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen
ter.h" |
| 16 | 16 |
| 17 namespace base { |
| 17 class ListValue; | 18 class ListValue; |
| 19 } |
| 18 | 20 |
| 19 // Class which caches notification preferences. | 21 // Class which caches notification preferences. |
| 20 // Construction occurs on the UI thread when the contents | 22 // Construction occurs on the UI thread when the contents |
| 21 // of the profile preferences are initialized. Once is_initialized() is set, | 23 // of the profile preferences are initialized. Once is_initialized() is set, |
| 22 // access can only be done from the IO thread. | 24 // access can only be done from the IO thread. |
| 23 class NotificationsPrefsCache | 25 class NotificationsPrefsCache |
| 24 : public base::RefCountedThreadSafe<NotificationsPrefsCache> { | 26 : public base::RefCountedThreadSafe<NotificationsPrefsCache> { |
| 25 public: | 27 public: |
| 26 NotificationsPrefsCache(); | 28 NotificationsPrefsCache(); |
| 27 | 29 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 // Updates the cache with a new origin allowed or denied. | 40 // Updates the cache with a new origin allowed or denied. |
| 39 void CacheAllowedOrigin(const GURL& origin); | 41 void CacheAllowedOrigin(const GURL& origin); |
| 40 void CacheDeniedOrigin(const GURL& origin); | 42 void CacheDeniedOrigin(const GURL& origin); |
| 41 | 43 |
| 42 // Set the cache to the supplied values. This clears the current | 44 // Set the cache to the supplied values. This clears the current |
| 43 // contents of the cache. | 45 // contents of the cache. |
| 44 void SetCacheAllowedOrigins(const std::vector<GURL>& allowed); | 46 void SetCacheAllowedOrigins(const std::vector<GURL>& allowed); |
| 45 void SetCacheDeniedOrigins(const std::vector<GURL>& denied); | 47 void SetCacheDeniedOrigins(const std::vector<GURL>& denied); |
| 46 void SetCacheDefaultContentSetting(ContentSetting setting); | 48 void SetCacheDefaultContentSetting(ContentSetting setting); |
| 47 | 49 |
| 48 static void ListValueToGurlVector(const ListValue& origin_list, | 50 static void ListValueToGurlVector(const base::ListValue& origin_list, |
| 49 std::vector<GURL>* origin_vector); | 51 std::vector<GURL>* origin_vector); |
| 50 | 52 |
| 51 // Exposed for testing. | 53 // Exposed for testing. |
| 52 ContentSetting CachedDefaultContentSetting() { | 54 ContentSetting CachedDefaultContentSetting() { |
| 53 return default_content_setting_; | 55 return default_content_setting_; |
| 54 } | 56 } |
| 55 | 57 |
| 56 private: | 58 private: |
| 57 friend class base::RefCountedThreadSafe<NotificationsPrefsCache>; | 59 friend class base::RefCountedThreadSafe<NotificationsPrefsCache>; |
| 58 | 60 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 ContentSetting default_content_setting_; | 76 ContentSetting default_content_setting_; |
| 75 | 77 |
| 76 // Set to true once the initial cached settings have been completely read. | 78 // Set to true once the initial cached settings have been completely read. |
| 77 // Once this is done, the class can no longer be accessed on the UI thread. | 79 // Once this is done, the class can no longer be accessed on the UI thread. |
| 78 bool is_initialized_; | 80 bool is_initialized_; |
| 79 | 81 |
| 80 DISALLOW_COPY_AND_ASSIGN(NotificationsPrefsCache); | 82 DISALLOW_COPY_AND_ASSIGN(NotificationsPrefsCache); |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H_ | 85 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H_ |
| OLD | NEW |