OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/scoped_observer.h" | 20 #include "base/scoped_observer.h" |
21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist. h" | 23 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist. h" |
24 #include "chrome/browser/supervised_user/report_url_request_creator.h" | |
24 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 25 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
25 #include "chrome/browser/supervised_user/supervised_users.h" | 26 #include "chrome/browser/supervised_user/supervised_users.h" |
26 #include "chrome/browser/ui/browser_list_observer.h" | 27 #include "chrome/browser/ui/browser_list_observer.h" |
27 #include "components/keyed_service/core/keyed_service.h" | 28 #include "components/keyed_service/core/keyed_service.h" |
28 #include "components/prefs/pref_change_registrar.h" | 29 #include "components/prefs/pref_change_registrar.h" |
29 #include "components/sync_driver/sync_service_observer.h" | 30 #include "components/sync_driver/sync_service_observer.h" |
30 #include "components/sync_driver/sync_type_preference_provider.h" | 31 #include "components/sync_driver/sync_type_preference_provider.h" |
31 #include "net/url_request/url_request_context_getter.h" | 32 #include "net/url_request/url_request_context_getter.h" |
32 | 33 |
33 #if defined(ENABLE_EXTENSIONS) | 34 #if defined(ENABLE_EXTENSIONS) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 return whitelists_; | 114 return whitelists_; |
114 } | 115 } |
115 | 116 |
116 // Whether the user can request to get access to blocked URLs or to new | 117 // Whether the user can request to get access to blocked URLs or to new |
117 // extensions. | 118 // extensions. |
118 bool AccessRequestsEnabled(); | 119 bool AccessRequestsEnabled(); |
119 | 120 |
120 // Adds an access request for the given URL. | 121 // Adds an access request for the given URL. |
121 void AddURLAccessRequest(const GURL& url, const SuccessCallback& callback); | 122 void AddURLAccessRequest(const GURL& url, const SuccessCallback& callback); |
122 | 123 |
124 // Adds a report url request to the SafeSearch API. | |
125 void AddReportUrlRequest(const GURL& url, const SuccessCallback& callback); | |
126 | |
123 // Adds an update request for the given WebStore item (App/Extension). | 127 // Adds an update request for the given WebStore item (App/Extension). |
124 void AddExtensionUpdateRequest(const std::string& extension_id, | 128 void AddExtensionUpdateRequest(const std::string& extension_id, |
125 const base::Version& version, | 129 const base::Version& version, |
126 const SuccessCallback& callback); | 130 const SuccessCallback& callback); |
127 | 131 |
128 // Same as above, but without a callback, just logging errors on failure. | 132 // Same as above, but without a callback, just logging errors on failure. |
129 void AddExtensionUpdateRequest(const std::string& extension_id, | 133 void AddExtensionUpdateRequest(const std::string& extension_id, |
130 const base::Version& version); | 134 const base::Version& version); |
131 | 135 |
132 // Get the string used to identify an extension update request. Public for | 136 // Get the string used to identify an extension update request. Public for |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 | 177 |
174 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback); | 178 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback); |
175 void DidBlockNavigation(content::WebContents* web_contents); | 179 void DidBlockNavigation(content::WebContents* web_contents); |
176 | 180 |
177 void AddObserver(SupervisedUserServiceObserver* observer); | 181 void AddObserver(SupervisedUserServiceObserver* observer); |
178 void RemoveObserver(SupervisedUserServiceObserver* observer); | 182 void RemoveObserver(SupervisedUserServiceObserver* observer); |
179 | 183 |
180 void AddPermissionRequestCreator( | 184 void AddPermissionRequestCreator( |
181 scoped_ptr<PermissionRequestCreator> creator); | 185 scoped_ptr<PermissionRequestCreator> creator); |
182 | 186 |
187 void AddReportUrlRequestCreator(scoped_ptr<ReportUrlRequestCreator> creator); | |
Marc Treib
2016/03/18 11:28:54
All this complexity with a "RequestCreator" interf
atanasova
2016/03/21 10:42:25
Done.
| |
188 | |
183 // ProfileKeyedService override: | 189 // ProfileKeyedService override: |
184 void Shutdown() override; | 190 void Shutdown() override; |
185 | 191 |
186 // SyncTypePreferenceProvider implementation: | 192 // SyncTypePreferenceProvider implementation: |
187 syncer::ModelTypeSet GetPreferredDataTypes() const override; | 193 syncer::ModelTypeSet GetPreferredDataTypes() const override; |
188 | 194 |
189 #if !defined(OS_ANDROID) | 195 #if !defined(OS_ANDROID) |
190 // sync_driver::SyncServiceObserver implementation: | 196 // sync_driver::SyncServiceObserver implementation: |
191 void OnStateChanged() override; | 197 void OnStateChanged() override; |
192 | 198 |
(...skipping 11 matching lines...) Expand all Loading... | |
204 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); | 210 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); |
205 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, | 211 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
206 ChangesIncludedSessionOnChangedSettings); | 212 ChangesIncludedSessionOnChangedSettings); |
207 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, | 213 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, |
208 ChangesSyncSessionStateOnChangedSettings); | 214 ChangesSyncSessionStateOnChangedSettings); |
209 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceExtensionTest, | 215 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceExtensionTest, |
210 ExtensionManagementPolicyProvider); | 216 ExtensionManagementPolicyProvider); |
211 | 217 |
212 using CreatePermissionRequestCallback = | 218 using CreatePermissionRequestCallback = |
213 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>; | 219 base::Callback<void(PermissionRequestCreator*, const SuccessCallback&)>; |
220 using CreateReportUrlRequestCallback = | |
221 base::Callback<void(ReportUrlRequestCreator*, const SuccessCallback&)>; | |
214 | 222 |
215 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which | 223 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which |
216 // lives on the IO thread. This class mediates access to them and makes sure | 224 // lives on the IO thread. This class mediates access to them and makes sure |
217 // they are kept in sync. | 225 // they are kept in sync. |
218 class URLFilterContext { | 226 class URLFilterContext { |
219 public: | 227 public: |
220 URLFilterContext(); | 228 URLFilterContext(); |
221 ~URLFilterContext(); | 229 ~URLFilterContext(); |
222 | 230 |
223 SupervisedUserURLFilter* ui_url_filter() const; | 231 SupervisedUserURLFilter* ui_url_filter() const; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 void AddPermissionRequestInternal( | 308 void AddPermissionRequestInternal( |
301 const CreatePermissionRequestCallback& create_request, | 309 const CreatePermissionRequestCallback& create_request, |
302 const SuccessCallback& callback, | 310 const SuccessCallback& callback, |
303 size_t index); | 311 size_t index); |
304 void OnPermissionRequestIssued( | 312 void OnPermissionRequestIssued( |
305 const CreatePermissionRequestCallback& create_request, | 313 const CreatePermissionRequestCallback& create_request, |
306 const SuccessCallback& callback, | 314 const SuccessCallback& callback, |
307 size_t index, | 315 size_t index, |
308 bool success); | 316 bool success); |
309 | 317 |
318 void AddReportUrlRequestInternal( | |
319 const CreateReportUrlRequestCallback& report_url_request, | |
320 const SuccessCallback& callback, | |
321 size_t index); | |
322 void OnReportUrlRequestIssues( | |
323 const CreateReportUrlRequestCallback& report_url_request, | |
324 const SuccessCallback& callback, | |
325 size_t index, | |
326 bool success); | |
327 | |
310 void OnSupervisedUserIdChanged(); | 328 void OnSupervisedUserIdChanged(); |
311 | 329 |
312 void OnDefaultFilteringBehaviorChanged(); | 330 void OnDefaultFilteringBehaviorChanged(); |
313 | 331 |
314 void OnSafeSitesSettingChanged(); | 332 void OnSafeSitesSettingChanged(); |
315 | 333 |
316 void OnSiteListsChanged( | 334 void OnSiteListsChanged( |
317 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists); | 335 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists); |
318 | 336 |
319 // Asynchronously loads a blacklist from a binary file at |path| and applies | 337 // Asynchronously loads a blacklist from a binary file at |path| and applies |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 SupervisedUserBlacklist blacklist_; | 409 SupervisedUserBlacklist blacklist_; |
392 scoped_ptr<FileDownloader> blacklist_downloader_; | 410 scoped_ptr<FileDownloader> blacklist_downloader_; |
393 | 411 |
394 scoped_ptr<SupervisedUserWhitelistService> whitelist_service_; | 412 scoped_ptr<SupervisedUserWhitelistService> whitelist_service_; |
395 | 413 |
396 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_; | 414 std::vector<scoped_refptr<SupervisedUserSiteList>> whitelists_; |
397 | 415 |
398 // Used to create permission requests. | 416 // Used to create permission requests. |
399 ScopedVector<PermissionRequestCreator> permissions_creators_; | 417 ScopedVector<PermissionRequestCreator> permissions_creators_; |
400 | 418 |
419 // Used to create report url requests. | |
420 std::vector<scoped_ptr<ReportUrlRequestCreator>> report_url_creators_; | |
421 | |
401 base::ObserverList<SupervisedUserServiceObserver> observer_list_; | 422 base::ObserverList<SupervisedUserServiceObserver> observer_list_; |
402 | 423 |
403 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; | 424 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; |
404 }; | 425 }; |
405 | 426 |
406 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 427 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
OLD | NEW |