| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 typedef std::vector<base::string16> CategoryList; | 51 typedef std::vector<base::string16> CategoryList; |
| 52 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; | 52 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; |
| 53 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; | 53 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; |
| 54 | 54 |
| 55 enum ManualBehavior { | 55 enum ManualBehavior { |
| 56 MANUAL_NONE = 0, | 56 MANUAL_NONE = 0, |
| 57 MANUAL_ALLOW, | 57 MANUAL_ALLOW, |
| 58 MANUAL_BLOCK | 58 MANUAL_BLOCK |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class Delegate { |
| 62 public: |
| 63 virtual ~Delegate() {} |
| 64 // Returns true to indicate that the delegate handled the (de)activation, or |
| 65 // false to indicate that the ManagedUserService itself should handle it. |
| 66 virtual bool SetActive(bool active) = 0; |
| 67 }; |
| 68 |
| 61 virtual ~ManagedUserService(); | 69 virtual ~ManagedUserService(); |
| 62 | 70 |
| 63 // ProfileKeyedService override: | 71 // ProfileKeyedService override: |
| 64 virtual void Shutdown() OVERRIDE; | 72 virtual void Shutdown() OVERRIDE; |
| 65 | 73 |
| 66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 74 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 67 | 75 |
| 68 static void MigrateUserPrefs(PrefService* prefs); | 76 static void MigrateUserPrefs(PrefService* prefs); |
| 69 | 77 |
| 78 void SetDelegate(Delegate* delegate); |
| 79 |
| 70 // Returns the URL filter for the IO thread, for filtering network requests | 80 // Returns the URL filter for the IO thread, for filtering network requests |
| 71 // (in ManagedModeResourceThrottle). | 81 // (in ManagedModeResourceThrottle). |
| 72 scoped_refptr<const ManagedModeURLFilter> GetURLFilterForIOThread(); | 82 scoped_refptr<const ManagedModeURLFilter> GetURLFilterForIOThread(); |
| 73 | 83 |
| 74 // Returns the URL filter for the UI thread, for filtering navigations and | 84 // Returns the URL filter for the UI thread, for filtering navigations and |
| 75 // classifying sites in the history view. | 85 // classifying sites in the history view. |
| 76 ManagedModeURLFilter* GetURLFilterForUIThread(); | 86 ManagedModeURLFilter* GetURLFilterForUIThread(); |
| 77 | 87 |
| 78 // Returns the URL's category, obtained from the installed content packs. | 88 // Returns the URL's category, obtained from the installed content packs. |
| 79 int GetCategory(const GURL& url); | 89 int GetCategory(const GURL& url); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 scoped_refptr<ManagedModeURLFilter> ui_url_filter_; | 203 scoped_refptr<ManagedModeURLFilter> ui_url_filter_; |
| 194 scoped_refptr<ManagedModeURLFilter> io_url_filter_; | 204 scoped_refptr<ManagedModeURLFilter> io_url_filter_; |
| 195 | 205 |
| 196 DISALLOW_COPY_AND_ASSIGN(URLFilterContext); | 206 DISALLOW_COPY_AND_ASSIGN(URLFilterContext); |
| 197 }; | 207 }; |
| 198 | 208 |
| 199 // Use |ManagedUserServiceFactory::GetForProfile(..)| to get | 209 // Use |ManagedUserServiceFactory::GetForProfile(..)| to get |
| 200 // an instance of this service. | 210 // an instance of this service. |
| 201 explicit ManagedUserService(Profile* profile); | 211 explicit ManagedUserService(Profile* profile); |
| 202 | 212 |
| 213 void SetActive(bool active); |
| 214 |
| 203 void OnCustodianProfileDownloaded(const base::string16& full_name); | 215 void OnCustodianProfileDownloaded(const base::string16& full_name); |
| 204 | 216 |
| 205 void OnManagedUserRegistered(const AuthErrorCallback& callback, | 217 void OnManagedUserRegistered(const AuthErrorCallback& callback, |
| 206 Profile* custodian_profile, | 218 Profile* custodian_profile, |
| 207 const GoogleServiceAuthError& auth_error, | 219 const GoogleServiceAuthError& auth_error, |
| 208 const std::string& token); | 220 const std::string& token); |
| 209 | 221 |
| 210 void SetupSync(); | 222 void SetupSync(); |
| 211 | 223 |
| 212 bool ProfileIsManaged() const; | 224 bool ProfileIsManaged() const; |
| 213 | 225 |
| 214 // Internal implementation for ExtensionManagementPolicy::Delegate methods. | 226 // Internal implementation for ExtensionManagementPolicy::Delegate methods. |
| 215 // If |error| is not NULL, it will be filled with an error message if the | 227 // If |error| is not NULL, it will be filled with an error message if the |
| 216 // requested extension action (install, modify status, etc.) is not permitted. | 228 // requested extension action (install, modify status, etc.) is not permitted. |
| 217 bool ExtensionManagementPolicyImpl(const extensions::Extension* extension, | 229 bool ExtensionManagementPolicyImpl(const extensions::Extension* extension, |
| 218 base::string16* error) const; | 230 base::string16* error) const; |
| 219 | 231 |
| 220 // Returns a list of all installed and enabled site lists in the current | 232 // Returns a list of all installed and enabled site lists in the current |
| 221 // managed profile. | 233 // managed profile. |
| 222 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); | 234 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); |
| 223 | 235 |
| 224 ManagedUserSettingsService* GetSettingsService(); | 236 ManagedUserSettingsService* GetSettingsService(); |
| 225 | 237 |
| 238 void OnManagedUserIdChanged(); |
| 239 |
| 226 void OnDefaultFilteringBehaviorChanged(); | 240 void OnDefaultFilteringBehaviorChanged(); |
| 227 | 241 |
| 228 void UpdateSiteLists(); | 242 void UpdateSiteLists(); |
| 229 | 243 |
| 230 // Updates the manual overrides for hosts in the URL filters when the | 244 // Updates the manual overrides for hosts in the URL filters when the |
| 231 // corresponding preference is changed. | 245 // corresponding preference is changed. |
| 232 void UpdateManualHosts(); | 246 void UpdateManualHosts(); |
| 233 | 247 |
| 234 // Updates the manual overrides for URLs in the URL filters when the | 248 // Updates the manual overrides for URLs in the URL filters when the |
| 235 // corresponding preference is changed. | 249 // corresponding preference is changed. |
| 236 void UpdateManualURLs(); | 250 void UpdateManualURLs(); |
| 237 | 251 |
| 238 // Owns us via the KeyedService mechanism. | 252 // Owns us via the KeyedService mechanism. |
| 239 Profile* profile_; | 253 Profile* profile_; |
| 240 | 254 |
| 255 bool active_; |
| 256 |
| 257 Delegate* delegate_; |
| 258 |
| 241 ScopedObserver<extensions::ExtensionRegistry, | 259 ScopedObserver<extensions::ExtensionRegistry, |
| 242 extensions::ExtensionRegistryObserver> | 260 extensions::ExtensionRegistryObserver> |
| 243 extension_registry_observer_; | 261 extension_registry_observer_; |
| 244 | 262 |
| 245 PrefChangeRegistrar pref_change_registrar_; | 263 PrefChangeRegistrar pref_change_registrar_; |
| 246 | 264 |
| 247 // True iff we're waiting for the Sync service to be initialized. | 265 // True iff we're waiting for the Sync service to be initialized. |
| 248 bool waiting_for_sync_initialization_; | 266 bool waiting_for_sync_initialization_; |
| 249 bool is_profile_active_; | 267 bool is_profile_active_; |
| 250 | 268 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 261 // Used to create permission requests. | 279 // Used to create permission requests. |
| 262 scoped_ptr<PermissionRequestCreator> permissions_creator_; | 280 scoped_ptr<PermissionRequestCreator> permissions_creator_; |
| 263 | 281 |
| 264 // True iff we are waiting for a permission request to be issued. | 282 // True iff we are waiting for a permission request to be issued. |
| 265 bool waiting_for_permissions_; | 283 bool waiting_for_permissions_; |
| 266 | 284 |
| 267 base::WeakPtrFactory<ManagedUserService> weak_ptr_factory_; | 285 base::WeakPtrFactory<ManagedUserService> weak_ptr_factory_; |
| 268 }; | 286 }; |
| 269 | 287 |
| 270 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | 288 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ |
| OLD | NEW |