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 COMPONENTS_POLICY_CORE_COMMON_URL_BLACKLIST_MANAGER_H_ |
6 #define CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_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/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/prefs/pref_change_registrar.h" | 18 #include "base/prefs/pref_change_registrar.h" |
| 19 #include "components/policy/policy_export.h" |
19 #include "components/url_matcher/url_matcher.h" | 20 #include "components/url_matcher/url_matcher.h" |
20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
21 | 22 |
22 class PrefService; | 23 class PrefService; |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class ListValue; | 26 class ListValue; |
26 class SequencedTaskRunner; | 27 class SequencedTaskRunner; |
27 } | 28 } |
28 | 29 |
29 namespace net { | 30 namespace net { |
30 class URLRequest; | 31 class URLRequest; |
31 } | 32 } |
32 | 33 |
33 namespace user_prefs { | 34 namespace user_prefs { |
34 class PrefRegistrySyncable; | 35 class PrefRegistrySyncable; |
35 } | 36 } |
36 | 37 |
37 namespace policy { | 38 namespace policy { |
38 | 39 |
39 // Contains a set of filters to block and allow certain URLs, and matches GURLs | 40 // Contains a set of filters to block and allow certain URLs, and matches GURLs |
40 // against this set. The filters are currently kept in memory. | 41 // against this set. The filters are currently kept in memory. |
41 class URLBlacklist { | 42 class POLICY_EXPORT URLBlacklist { |
42 public: | 43 public: |
43 // This is meant to be bound to URLFixerUpper::SegmentURL. See that function | 44 // This is meant to be bound to URLFixerUpper::SegmentURL. See that function |
44 // for documentation on the parameters and return value. | 45 // for documentation on the parameters and return value. |
45 typedef std::string (*SegmentURLCallback)(const std::string&, | 46 typedef std::string (*SegmentURLCallback)(const std::string&, |
46 url_parse::Parsed*); | 47 url_parse::Parsed*); |
47 | 48 |
48 explicit URLBlacklist(SegmentURLCallback segment_url); | 49 explicit URLBlacklist(SegmentURLCallback segment_url); |
49 virtual ~URLBlacklist(); | 50 virtual ~URLBlacklist(); |
50 | 51 |
51 // Allows or blocks URLs matching one of the filters, depending on |allow|. | 52 // Allows or blocks URLs matching one of the filters, depending on |allow|. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // the prefs listeners. | 122 // the prefs listeners. |
122 // | 123 // |
123 // ShutdownOnUIThread must be called from UI before destruction, to release | 124 // ShutdownOnUIThread must be called from UI before destruction, to release |
124 // the prefs listeners on the UI thread. This is done from ProfileIOData. | 125 // the prefs listeners on the UI thread. This is done from ProfileIOData. |
125 // | 126 // |
126 // Update tasks from the UI thread can post safely to the IO thread, since the | 127 // Update tasks from the UI thread can post safely to the IO thread, since the |
127 // destruction order of Profile and ProfileIOData guarantees that if this | 128 // destruction order of Profile and ProfileIOData guarantees that if this |
128 // exists in UI, then a potential destruction on IO will come after any task | 129 // exists in UI, then a potential destruction on IO will come after any task |
129 // posted to IO from that method on UI. This is used to go through IO before | 130 // posted to IO from that method on UI. This is used to go through IO before |
130 // the actual update starts, and grab a WeakPtr. | 131 // the actual update starts, and grab a WeakPtr. |
131 class URLBlacklistManager { | 132 class POLICY_EXPORT URLBlacklistManager { |
132 public: | 133 public: |
133 // Returns true if the blacklist should be skipped for |url|. | 134 // Returns true if the blacklist should be skipped for |url|. |
134 typedef bool (*SkipBlacklistCallback)(const GURL& url); | 135 typedef bool (*SkipBlacklistCallback)(const GURL& url); |
135 | 136 |
136 // Must be constructed on the UI thread. | 137 // Must be constructed on the UI thread. |
137 // |background_task_runner| is used to build the blacklist in a background | 138 // |background_task_runner| is used to build the blacklist in a background |
138 // thread. | 139 // thread. |
139 // |io_task_runner| must be backed by the IO thread. | 140 // |io_task_runner| must be backed by the IO thread. |
140 // |segment_url| is used to break a URL spec into its components. | 141 // |segment_url| is used to break a URL spec into its components. |
141 URLBlacklistManager( | 142 URLBlacklistManager( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 217 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
217 | 218 |
218 // The current blacklist. | 219 // The current blacklist. |
219 scoped_ptr<URLBlacklist> blacklist_; | 220 scoped_ptr<URLBlacklist> blacklist_; |
220 | 221 |
221 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager); | 222 DISALLOW_COPY_AND_ASSIGN(URLBlacklistManager); |
222 }; | 223 }; |
223 | 224 |
224 } // namespace policy | 225 } // namespace policy |
225 | 226 |
226 #endif // CHROME_BROWSER_POLICY_URL_BLACKLIST_MANAGER_H_ | 227 #endif // COMPONENTS_POLICY_CORE_COMMON_URL_BLACKLIST_MANAGER_H_ |
OLD | NEW |