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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/scoped_observer.h" |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 16 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
16 #include "chrome/browser/managed_mode/managed_users.h" | 17 #include "chrome/browser/managed_mode/managed_users.h" |
17 #include "chrome/browser/sync/profile_sync_service_observer.h" | 18 #include "chrome/browser/sync/profile_sync_service_observer.h" |
18 #include "chrome/browser/ui/browser_list_observer.h" | 19 #include "chrome/browser/ui/browser_list_observer.h" |
19 #include "components/keyed_service/core/keyed_service.h" | 20 #include "components/keyed_service/core/keyed_service.h" |
20 #include "content/public/browser/notification_observer.h" | |
21 #include "content/public/browser/notification_registrar.h" | |
22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "extensions/browser/extension_registry_observer.h" |
23 #include "extensions/browser/management_policy.h" | 23 #include "extensions/browser/management_policy.h" |
24 | 24 |
25 class Browser; | 25 class Browser; |
26 class GoogleServiceAuthError; | 26 class GoogleServiceAuthError; |
27 class ManagedModeURLFilter; | 27 class ManagedModeURLFilter; |
28 class ManagedModeSiteList; | 28 class ManagedModeSiteList; |
29 class ManagedUserRegistrationUtility; | 29 class ManagedUserRegistrationUtility; |
30 class ManagedUserSettingsService; | 30 class ManagedUserSettingsService; |
31 class PermissionRequestCreator; | 31 class PermissionRequestCreator; |
32 class Profile; | 32 class Profile; |
33 | 33 |
| 34 namespace extensions { |
| 35 class ExtensionRegistry; |
| 36 } |
| 37 |
34 namespace user_prefs { | 38 namespace user_prefs { |
35 class PrefRegistrySyncable; | 39 class PrefRegistrySyncable; |
36 } | 40 } |
37 | 41 |
38 // This class handles all the information related to a given managed profile | 42 // This class handles all the information related to a given managed profile |
39 // (e.g. the installed content packs, the default URL filtering behavior, or | 43 // (e.g. the installed content packs, the default URL filtering behavior, or |
40 // manual whitelist/blacklist overrides). | 44 // manual whitelist/blacklist overrides). |
41 class ManagedUserService : public KeyedService, | 45 class ManagedUserService : public KeyedService, |
42 public extensions::ManagementPolicy::Provider, | 46 public extensions::ManagementPolicy::Provider, |
43 public ProfileSyncServiceObserver, | 47 public ProfileSyncServiceObserver, |
44 public content::NotificationObserver, | 48 public extensions::ExtensionRegistryObserver, |
45 public chrome::BrowserListObserver { | 49 public chrome::BrowserListObserver { |
46 public: | 50 public: |
47 typedef std::vector<base::string16> CategoryList; | 51 typedef std::vector<base::string16> CategoryList; |
48 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; | 52 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; |
49 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; | 53 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; |
50 | 54 |
51 enum ManualBehavior { | 55 enum ManualBehavior { |
52 MANUAL_NONE = 0, | 56 MANUAL_NONE = 0, |
53 MANUAL_ALLOW, | 57 MANUAL_ALLOW, |
54 MANUAL_BLOCK | 58 MANUAL_BLOCK |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // extensions::ManagementPolicy::Provider implementation: | 142 // extensions::ManagementPolicy::Provider implementation: |
139 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 143 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
140 virtual bool UserMayLoad(const extensions::Extension* extension, | 144 virtual bool UserMayLoad(const extensions::Extension* extension, |
141 base::string16* error) const OVERRIDE; | 145 base::string16* error) const OVERRIDE; |
142 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 146 virtual bool UserMayModifySettings(const extensions::Extension* extension, |
143 base::string16* error) const OVERRIDE; | 147 base::string16* error) const OVERRIDE; |
144 | 148 |
145 // ProfileSyncServiceObserver implementation: | 149 // ProfileSyncServiceObserver implementation: |
146 virtual void OnStateChanged() OVERRIDE; | 150 virtual void OnStateChanged() OVERRIDE; |
147 | 151 |
148 // content::NotificationObserver implementation: | 152 // extensions::ExtensionRegistryObserver implementation. |
149 virtual void Observe(int type, | 153 virtual void OnExtensionLoaded( |
150 const content::NotificationSource& source, | 154 content::BrowserContext* browser_context, |
151 const content::NotificationDetails& details) OVERRIDE; | 155 const extensions::Extension* extension) OVERRIDE; |
| 156 virtual void OnExtensionUnloaded( |
| 157 content::BrowserContext* browser_context, |
| 158 const extensions::Extension* extension, |
| 159 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
152 | 160 |
153 // chrome::BrowserListObserver implementation: | 161 // chrome::BrowserListObserver implementation: |
154 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; | 162 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; |
155 | 163 |
156 private: | 164 private: |
157 friend class ManagedUserServiceExtensionTestBase; | 165 friend class ManagedUserServiceExtensionTestBase; |
158 friend class ManagedUserServiceFactory; | 166 friend class ManagedUserServiceFactory; |
159 FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest, ClearOmitOnRegistration); | 167 FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest, ClearOmitOnRegistration); |
160 | 168 |
161 // A bridge from ManagedMode (which lives on the UI thread) to the | 169 // A bridge from ManagedMode (which lives on the UI thread) to the |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // corresponding preference is changed. | 231 // corresponding preference is changed. |
224 void UpdateManualHosts(); | 232 void UpdateManualHosts(); |
225 | 233 |
226 // Updates the manual overrides for URLs in the URL filters when the | 234 // Updates the manual overrides for URLs in the URL filters when the |
227 // corresponding preference is changed. | 235 // corresponding preference is changed. |
228 void UpdateManualURLs(); | 236 void UpdateManualURLs(); |
229 | 237 |
230 // Owns us via the KeyedService mechanism. | 238 // Owns us via the KeyedService mechanism. |
231 Profile* profile_; | 239 Profile* profile_; |
232 | 240 |
233 content::NotificationRegistrar registrar_; | 241 ScopedObserver<extensions::ExtensionRegistry, |
| 242 extensions::ExtensionRegistryObserver> |
| 243 extension_registry_observer_; |
| 244 |
234 PrefChangeRegistrar pref_change_registrar_; | 245 PrefChangeRegistrar pref_change_registrar_; |
235 | 246 |
236 // True iff we're waiting for the Sync service to be initialized. | 247 // True iff we're waiting for the Sync service to be initialized. |
237 bool waiting_for_sync_initialization_; | 248 bool waiting_for_sync_initialization_; |
238 bool is_profile_active_; | 249 bool is_profile_active_; |
239 | 250 |
240 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; | 251 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; |
241 | 252 |
242 // Sets a profile in elevated state for testing if set to true. | 253 // Sets a profile in elevated state for testing if set to true. |
243 bool elevated_for_testing_; | 254 bool elevated_for_testing_; |
244 | 255 |
245 // True only when |Shutdown()| method has been called. | 256 // True only when |Shutdown()| method has been called. |
246 bool did_shutdown_; | 257 bool did_shutdown_; |
247 | 258 |
248 URLFilterContext url_filter_context_; | 259 URLFilterContext url_filter_context_; |
249 | 260 |
250 // Used to create permission requests. | 261 // Used to create permission requests. |
251 scoped_ptr<PermissionRequestCreator> permissions_creator_; | 262 scoped_ptr<PermissionRequestCreator> permissions_creator_; |
252 | 263 |
253 // True iff we are waiting for a permission request to be issued. | 264 // True iff we are waiting for a permission request to be issued. |
254 bool waiting_for_permissions_; | 265 bool waiting_for_permissions_; |
255 | 266 |
256 base::WeakPtrFactory<ManagedUserService> weak_ptr_factory_; | 267 base::WeakPtrFactory<ManagedUserService> weak_ptr_factory_; |
257 }; | 268 }; |
258 | 269 |
259 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | 270 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ |
OLD | NEW |