| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_POLICY_URL_BLACKLIST_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ |
| 6 #define CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ | 6 #define CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/prefs/pref_change_registrar.h" | 17 #include "base/prefs/pref_change_registrar.h" |
| 18 #include "extensions/common/matcher/url_matcher.h" | 18 #include "extensions/common/matcher/url_matcher.h" |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 class PrefService; | 21 class PrefService; |
| 22 class PrefRegistrySyncable; | |
| 23 | 22 |
| 24 namespace base { | 23 namespace base { |
| 25 class ListValue; | 24 class ListValue; |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace net { | 27 namespace net { |
| 29 class URLRequest; | 28 class URLRequest; |
| 30 } | 29 } |
| 31 | 30 |
| 31 namespace user_prefs { |
| 32 class PrefRegistrySyncable; |
| 33 } |
| 34 |
| 32 namespace policy { | 35 namespace policy { |
| 33 | 36 |
| 34 // Contains a set of filters to block and allow certain URLs, and matches GURLs | 37 // Contains a set of filters to block and allow certain URLs, and matches GURLs |
| 35 // against this set. The filters are currently kept in memory. | 38 // against this set. The filters are currently kept in memory. |
| 36 class URLBlacklist { | 39 class URLBlacklist { |
| 37 public: | 40 public: |
| 38 URLBlacklist(); | 41 URLBlacklist(); |
| 39 virtual ~URLBlacklist(); | 42 virtual ~URLBlacklist(); |
| 40 | 43 |
| 41 // Allows or blocks URLs matching one of the filters, depending on |allow|. | 44 // Allows or blocks URLs matching one of the filters, depending on |allow|. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // or background downloads (e.g. extensions updates, sync, etc) are not | 141 // or background downloads (e.g. extensions updates, sync, etc) are not |
| 139 // filtered. The sync signin page is also not filtered. | 142 // filtered. The sync signin page is also not filtered. |
| 140 // Must be called from the IO thread. | 143 // Must be called from the IO thread. |
| 141 bool IsRequestBlocked(const net::URLRequest& request) const; | 144 bool IsRequestBlocked(const net::URLRequest& request) const; |
| 142 | 145 |
| 143 // Replaces the current blacklist. Must be called on the IO thread. | 146 // Replaces the current blacklist. Must be called on the IO thread. |
| 144 // Virtual for testing. | 147 // Virtual for testing. |
| 145 virtual void SetBlacklist(scoped_ptr<URLBlacklist> blacklist); | 148 virtual void SetBlacklist(scoped_ptr<URLBlacklist> blacklist); |
| 146 | 149 |
| 147 // Registers the preferences related to blacklisting in the given PrefService. | 150 // Registers the preferences related to blacklisting in the given PrefService. |
| 148 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 151 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
| 149 | 152 |
| 150 protected: | 153 protected: |
| 151 // Used to delay updating the blacklist while the preferences are | 154 // Used to delay updating the blacklist while the preferences are |
| 152 // changing, and execute only one update per simultaneous prefs changes. | 155 // changing, and execute only one update per simultaneous prefs changes. |
| 153 void ScheduleUpdate(); | 156 void ScheduleUpdate(); |
| 154 | 157 |
| 155 // Updates the blacklist using the current preference values. | 158 // Updates the blacklist using the current preference values. |
| 156 // Virtual for testing. | 159 // Virtual for testing. |
| 157 virtual void Update(); | 160 virtual void Update(); |
| 158 | 161 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 182 | 185 |
| 183 // The current blacklist. | 186 // The current blacklist. |
| 184 scoped_ptr<URLBlacklist> blacklist_; | 187 scoped_ptr<URLBlacklist> blacklist_; |
| 185 | 188 |
| 186 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager); | 189 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager); |
| 187 }; | 190 }; |
| 188 | 191 |
| 189 } // namespace policy | 192 } // namespace policy |
| 190 | 193 |
| 191 #endif // CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ | 194 #endif // CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ |
| OLD | NEW |