| 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 | 16 |
| 16 class ListValue; | 17 class ListValue; |
| 17 | 18 |
| 18 // Class which caches notification preferences. | 19 // Class which caches notification preferences. |
| 19 // Construction occurs on the UI thread when the contents | 20 // Construction occurs on the UI thread when the contents |
| 20 // of the profile preferences are initialized. Once is_initialized() is set, | 21 // of the profile preferences are initialized. Once is_initialized() is set, |
| 21 // access can only be done from the IO thread. | 22 // access can only be done from the IO thread. |
| 22 class NotificationsPrefsCache | 23 class NotificationsPrefsCache |
| 23 : public base::RefCountedThreadSafe<NotificationsPrefsCache> { | 24 : public base::RefCountedThreadSafe<NotificationsPrefsCache> { |
| 24 public: | 25 public: |
| 25 NotificationsPrefsCache(); | 26 NotificationsPrefsCache(); |
| 26 | 27 |
| 27 // Once is_initialized() is set, all accesses must happen on the IO thread. | 28 // Once is_initialized() is set, all accesses must happen on the IO thread. |
| 28 // Before that, all accesses need to happen on the UI thread. | 29 // Before that, all accesses need to happen on the UI thread. |
| 29 void set_is_initialized(bool val) { is_initialized_ = val; } | 30 void set_is_initialized(bool val) { is_initialized_ = val; } |
| 30 bool is_initialized() { return is_initialized_; } | 31 bool is_initialized() { return is_initialized_; } |
| 31 | 32 |
| 32 // Checks to see if a given origin has permission to create desktop | 33 // Checks to see if a given origin has permission to create desktop |
| 33 // notifications. Returns a constant from WebNotificationPresenter | 34 // notifications. |
| 34 // class. | 35 WebKit::WebNotificationPresenter::Permission |
| 35 int HasPermission(const GURL& origin); | 36 HasPermission(const GURL& origin); |
| 36 | 37 |
| 37 // Updates the cache with a new origin allowed or denied. | 38 // Updates the cache with a new origin allowed or denied. |
| 38 void CacheAllowedOrigin(const GURL& origin); | 39 void CacheAllowedOrigin(const GURL& origin); |
| 39 void CacheDeniedOrigin(const GURL& origin); | 40 void CacheDeniedOrigin(const GURL& origin); |
| 40 | 41 |
| 41 // Set the cache to the supplied values. This clears the current | 42 // Set the cache to the supplied values. This clears the current |
| 42 // contents of the cache. | 43 // contents of the cache. |
| 43 void SetCacheAllowedOrigins(const std::vector<GURL>& allowed); | 44 void SetCacheAllowedOrigins(const std::vector<GURL>& allowed); |
| 44 void SetCacheDeniedOrigins(const std::vector<GURL>& denied); | 45 void SetCacheDeniedOrigins(const std::vector<GURL>& denied); |
| 45 void SetCacheDefaultContentSetting(ContentSetting setting); | 46 void SetCacheDefaultContentSetting(ContentSetting setting); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 73 ContentSetting default_content_setting_; | 74 ContentSetting default_content_setting_; |
| 74 | 75 |
| 75 // Set to true once the initial cached settings have been completely read. | 76 // Set to true once the initial cached settings have been completely read. |
| 76 // Once this is done, the class can no longer be accessed on the UI thread. | 77 // Once this is done, the class can no longer be accessed on the UI thread. |
| 77 bool is_initialized_; | 78 bool is_initialized_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(NotificationsPrefsCache); | 80 DISALLOW_COPY_AND_ASSIGN(NotificationsPrefsCache); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H_ | 83 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATIONS_PREFS_CACHE_H_ |
| OLD | NEW |