Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service.h

Issue 384893002: Add #ifdefs for the extensions parts of SupervisedUserService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <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/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/prefs/pref_change_registrar.h" 14 #include "base/prefs/pref_change_registrar.h"
15 #include "base/scoped_observer.h" 15 #include "base/scoped_observer.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" 17 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
18 #include "chrome/browser/supervised_user/supervised_users.h" 18 #include "chrome/browser/supervised_user/supervised_users.h"
19 #include "chrome/browser/sync/profile_sync_service_observer.h" 19 #include "chrome/browser/sync/profile_sync_service_observer.h"
20 #include "chrome/browser/ui/browser_list_observer.h" 20 #include "chrome/browser/ui/browser_list_observer.h"
21 #include "components/keyed_service/core/keyed_service.h" 21 #include "components/keyed_service/core/keyed_service.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23
24 #if defined(ENABLE_EXTENSIONS)
23 #include "extensions/browser/extension_registry_observer.h" 25 #include "extensions/browser/extension_registry_observer.h"
24 #include "extensions/browser/management_policy.h" 26 #include "extensions/browser/management_policy.h"
27 #endif
25 28
26 class Browser; 29 class Browser;
27 class GoogleServiceAuthError; 30 class GoogleServiceAuthError;
28 class PermissionRequestCreator; 31 class PermissionRequestCreator;
29 class Profile; 32 class Profile;
30 class SupervisedUserRegistrationUtility; 33 class SupervisedUserRegistrationUtility;
31 class SupervisedUserSettingsService; 34 class SupervisedUserSettingsService;
32 class SupervisedUserSiteList; 35 class SupervisedUserSiteList;
33 class SupervisedUserURLFilter; 36 class SupervisedUserURLFilter;
34 37
35 namespace extensions { 38 namespace extensions {
36 class ExtensionRegistry; 39 class ExtensionRegistry;
37 } 40 }
38 41
39 namespace user_prefs { 42 namespace user_prefs {
40 class PrefRegistrySyncable; 43 class PrefRegistrySyncable;
41 } 44 }
42 45
43 // This class handles all the information related to a given supervised profile 46 // This class handles all the information related to a given supervised profile
44 // (e.g. the installed content packs, the default URL filtering behavior, or 47 // (e.g. the installed content packs, the default URL filtering behavior, or
45 // manual whitelist/blacklist overrides). 48 // manual whitelist/blacklist overrides).
46 class SupervisedUserService : public KeyedService, 49 class SupervisedUserService : public KeyedService,
50 #if defined(ENABLE_EXTENSIONS)
47 public extensions::ManagementPolicy::Provider, 51 public extensions::ManagementPolicy::Provider,
52 public extensions::ExtensionRegistryObserver,
53 #endif
48 public ProfileSyncServiceObserver, 54 public ProfileSyncServiceObserver,
49 public extensions::ExtensionRegistryObserver,
50 public chrome::BrowserListObserver { 55 public chrome::BrowserListObserver {
51 public: 56 public:
52 typedef std::vector<base::string16> CategoryList; 57 typedef std::vector<base::string16> CategoryList;
53 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; 58 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback;
54 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; 59 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback;
55 60
56 enum ManualBehavior { 61 enum ManualBehavior {
57 MANUAL_NONE = 0, 62 MANUAL_NONE = 0,
58 MANUAL_ALLOW, 63 MANUAL_ALLOW,
59 MANUAL_BLOCK 64 MANUAL_BLOCK
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const std::string& supervised_user_id, 147 const std::string& supervised_user_id,
143 const AuthErrorCallback& callback); 148 const AuthErrorCallback& callback);
144 149
145 void set_elevated_for_testing(bool skip) { 150 void set_elevated_for_testing(bool skip) {
146 elevated_for_testing_ = skip; 151 elevated_for_testing_ = skip;
147 } 152 }
148 153
149 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback); 154 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback);
150 void DidBlockNavigation(content::WebContents* web_contents); 155 void DidBlockNavigation(content::WebContents* web_contents);
151 156
157 #if defined(ENABLE_EXTENSIONS)
152 // extensions::ManagementPolicy::Provider implementation: 158 // extensions::ManagementPolicy::Provider implementation:
153 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; 159 virtual std::string GetDebugPolicyProviderName() const OVERRIDE;
154 virtual bool UserMayLoad(const extensions::Extension* extension, 160 virtual bool UserMayLoad(const extensions::Extension* extension,
155 base::string16* error) const OVERRIDE; 161 base::string16* error) const OVERRIDE;
156 virtual bool UserMayModifySettings(const extensions::Extension* extension, 162 virtual bool UserMayModifySettings(const extensions::Extension* extension,
157 base::string16* error) const OVERRIDE; 163 base::string16* error) const OVERRIDE;
158 164
159 // ProfileSyncServiceObserver implementation:
160 virtual void OnStateChanged() OVERRIDE;
161
162 // extensions::ExtensionRegistryObserver implementation. 165 // extensions::ExtensionRegistryObserver implementation.
163 virtual void OnExtensionLoaded( 166 virtual void OnExtensionLoaded(
164 content::BrowserContext* browser_context, 167 content::BrowserContext* browser_context,
165 const extensions::Extension* extension) OVERRIDE; 168 const extensions::Extension* extension) OVERRIDE;
166 virtual void OnExtensionUnloaded( 169 virtual void OnExtensionUnloaded(
167 content::BrowserContext* browser_context, 170 content::BrowserContext* browser_context,
168 const extensions::Extension* extension, 171 const extensions::Extension* extension,
169 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; 172 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE;
173 #endif
174
175 // ProfileSyncServiceObserver implementation:
176 virtual void OnStateChanged() OVERRIDE;
170 177
171 // chrome::BrowserListObserver implementation: 178 // chrome::BrowserListObserver implementation:
172 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; 179 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE;
173 180
174 private: 181 private:
175 friend class SupervisedUserServiceExtensionTestBase; 182 friend class SupervisedUserServiceExtensionTestBase;
176 friend class SupervisedUserServiceFactory; 183 friend class SupervisedUserServiceFactory;
177 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); 184 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration);
178 185
179 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which 186 // A bridge from the UI thread to the SupervisedUserURLFilters, one of which
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 const GoogleServiceAuthError& auth_error, 226 const GoogleServiceAuthError& auth_error,
220 const std::string& token); 227 const std::string& token);
221 228
222 void SetupSync(); 229 void SetupSync();
223 void StartSetupSync(); 230 void StartSetupSync();
224 void FinishSetupSyncWhenReady(); 231 void FinishSetupSyncWhenReady();
225 void FinishSetupSync(); 232 void FinishSetupSync();
226 233
227 bool ProfileIsSupervised() const; 234 bool ProfileIsSupervised() const;
228 235
236 #if defined(ENABLE_EXTENSIONS)
229 // Internal implementation for ExtensionManagementPolicy::Delegate methods. 237 // Internal implementation for ExtensionManagementPolicy::Delegate methods.
230 // If |error| is not NULL, it will be filled with an error message if the 238 // If |error| is not NULL, it will be filled with an error message if the
231 // requested extension action (install, modify status, etc.) is not permitted. 239 // requested extension action (install, modify status, etc.) is not permitted.
232 bool ExtensionManagementPolicyImpl(const extensions::Extension* extension, 240 bool ExtensionManagementPolicyImpl(const extensions::Extension* extension,
233 base::string16* error) const; 241 base::string16* error) const;
234 242
235 // Returns a list of all installed and enabled site lists in the current 243 // Returns a list of all installed and enabled site lists in the current
236 // supervised profile. 244 // supervised profile.
237 ScopedVector<SupervisedUserSiteList> GetActiveSiteLists(); 245 ScopedVector<SupervisedUserSiteList> GetActiveSiteLists();
238 246
247 // Extensions helper to SetActive().
248 void SetExtensionsActive();
249 #endif
250
239 SupervisedUserSettingsService* GetSettingsService(); 251 SupervisedUserSettingsService* GetSettingsService();
240 252
241 void OnSupervisedUserIdChanged(); 253 void OnSupervisedUserIdChanged();
242 254
243 void OnDefaultFilteringBehaviorChanged(); 255 void OnDefaultFilteringBehaviorChanged();
244 256
245 void UpdateSiteLists(); 257 void UpdateSiteLists();
246 258
247 // Updates the manual overrides for hosts in the URL filters when the 259 // Updates the manual overrides for hosts in the URL filters when the
248 // corresponding preference is changed. 260 // corresponding preference is changed.
249 void UpdateManualHosts(); 261 void UpdateManualHosts();
250 262
251 // Updates the manual overrides for URLs in the URL filters when the 263 // Updates the manual overrides for URLs in the URL filters when the
252 // corresponding preference is changed. 264 // corresponding preference is changed.
253 void UpdateManualURLs(); 265 void UpdateManualURLs();
254 266
255 // Owns us via the KeyedService mechanism. 267 // Owns us via the KeyedService mechanism.
256 Profile* profile_; 268 Profile* profile_;
257 269
258 bool active_; 270 bool active_;
259 271
260 Delegate* delegate_; 272 Delegate* delegate_;
261 273
274 #if defined(ENABLE_EXTENSIONS)
262 ScopedObserver<extensions::ExtensionRegistry, 275 ScopedObserver<extensions::ExtensionRegistry,
263 extensions::ExtensionRegistryObserver> 276 extensions::ExtensionRegistryObserver>
264 extension_registry_observer_; 277 extension_registry_observer_;
278 #endif
265 279
266 PrefChangeRegistrar pref_change_registrar_; 280 PrefChangeRegistrar pref_change_registrar_;
267 281
268 // True iff we're waiting for the Sync service to be initialized. 282 // True iff we're waiting for the Sync service to be initialized.
269 bool waiting_for_sync_initialization_; 283 bool waiting_for_sync_initialization_;
270 bool is_profile_active_; 284 bool is_profile_active_;
271 285
272 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; 286 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_;
273 287
274 // Sets a profile in elevated state for testing if set to true. 288 // Sets a profile in elevated state for testing if set to true.
275 bool elevated_for_testing_; 289 bool elevated_for_testing_;
276 290
277 // True only when |Shutdown()| method has been called. 291 // True only when |Shutdown()| method has been called.
278 bool did_shutdown_; 292 bool did_shutdown_;
279 293
280 URLFilterContext url_filter_context_; 294 URLFilterContext url_filter_context_;
281 295
282 // Used to create permission requests. 296 // Used to create permission requests.
283 scoped_ptr<PermissionRequestCreator> permissions_creator_; 297 scoped_ptr<PermissionRequestCreator> permissions_creator_;
284 298
285 // True iff we are waiting for a permission request to be issued. 299 // True iff we are waiting for a permission request to be issued.
286 bool waiting_for_permissions_; 300 bool waiting_for_permissions_;
287 301
288 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; 302 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_;
289 }; 303 };
290 304
291 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ 305 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698