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 <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/sync/sync_type_preference_provider.h" |
20 #include "chrome/browser/ui/browser_list_observer.h" | 21 #include "chrome/browser/ui/browser_list_observer.h" |
21 #include "components/keyed_service/core/keyed_service.h" | 22 #include "components/keyed_service/core/keyed_service.h" |
22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
23 | 24 |
24 #if defined(ENABLE_EXTENSIONS) | 25 #if defined(ENABLE_EXTENSIONS) |
25 #include "extensions/browser/extension_registry_observer.h" | 26 #include "extensions/browser/extension_registry_observer.h" |
26 #include "extensions/browser/management_policy.h" | 27 #include "extensions/browser/management_policy.h" |
27 #endif | 28 #endif |
28 | 29 |
29 class Browser; | 30 class Browser; |
(...skipping 14 matching lines...) Expand all Loading... |
44 } | 45 } |
45 | 46 |
46 // This class handles all the information related to a given supervised profile | 47 // This class handles all the information related to a given supervised profile |
47 // (e.g. the installed content packs, the default URL filtering behavior, or | 48 // (e.g. the installed content packs, the default URL filtering behavior, or |
48 // manual whitelist/blacklist overrides). | 49 // manual whitelist/blacklist overrides). |
49 class SupervisedUserService : public KeyedService, | 50 class SupervisedUserService : public KeyedService, |
50 #if defined(ENABLE_EXTENSIONS) | 51 #if defined(ENABLE_EXTENSIONS) |
51 public extensions::ManagementPolicy::Provider, | 52 public extensions::ManagementPolicy::Provider, |
52 public extensions::ExtensionRegistryObserver, | 53 public extensions::ExtensionRegistryObserver, |
53 #endif | 54 #endif |
| 55 public SyncTypePreferenceProvider, |
54 public ProfileSyncServiceObserver, | 56 public ProfileSyncServiceObserver, |
55 public chrome::BrowserListObserver { | 57 public chrome::BrowserListObserver { |
56 public: | 58 public: |
57 typedef std::vector<base::string16> CategoryList; | 59 typedef std::vector<base::string16> CategoryList; |
58 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; | 60 typedef base::Callback<void(content::WebContents*)> NavigationBlockedCallback; |
59 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; | 61 typedef base::Callback<void(const GoogleServiceAuthError&)> AuthErrorCallback; |
60 | 62 |
61 enum ManualBehavior { | 63 enum ManualBehavior { |
62 MANUAL_NONE = 0, | 64 MANUAL_NONE = 0, |
63 MANUAL_ALLOW, | 65 MANUAL_ALLOW, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // supervised. | 134 // supervised. |
133 void Init(); | 135 void Init(); |
134 | 136 |
135 // Initializes this profile for syncing, using the provided |refresh_token| to | 137 // Initializes this profile for syncing, using the provided |refresh_token| to |
136 // mint access tokens for Sync. | 138 // mint access tokens for Sync. |
137 void InitSync(const std::string& refresh_token); | 139 void InitSync(const std::string& refresh_token); |
138 | 140 |
139 // Convenience method that registers this supervised user using | 141 // Convenience method that registers this supervised user using |
140 // |registration_utility| and initializes sync with the returned token. | 142 // |registration_utility| and initializes sync with the returned token. |
141 // The |callback| will be called when registration is complete, | 143 // The |callback| will be called when registration is complete, |
142 // whether it suceeded or not -- unless registration was cancelled manually, | 144 // whether it succeeded or not -- unless registration was cancelled manually, |
143 // in which case the callback will be ignored. | 145 // in which case the callback will be ignored. |
144 void RegisterAndInitSync( | 146 void RegisterAndInitSync( |
145 SupervisedUserRegistrationUtility* registration_utility, | 147 SupervisedUserRegistrationUtility* registration_utility, |
146 Profile* custodian_profile, | 148 Profile* custodian_profile, |
147 const std::string& supervised_user_id, | 149 const std::string& supervised_user_id, |
148 const AuthErrorCallback& callback); | 150 const AuthErrorCallback& callback); |
149 | 151 |
150 void set_elevated_for_testing(bool skip) { | 152 void set_elevated_for_testing(bool skip) { |
151 elevated_for_testing_ = skip; | 153 elevated_for_testing_ = skip; |
152 } | 154 } |
(...skipping 12 matching lines...) Expand all Loading... |
165 // extensions::ExtensionRegistryObserver implementation. | 167 // extensions::ExtensionRegistryObserver implementation. |
166 virtual void OnExtensionLoaded( | 168 virtual void OnExtensionLoaded( |
167 content::BrowserContext* browser_context, | 169 content::BrowserContext* browser_context, |
168 const extensions::Extension* extension) OVERRIDE; | 170 const extensions::Extension* extension) OVERRIDE; |
169 virtual void OnExtensionUnloaded( | 171 virtual void OnExtensionUnloaded( |
170 content::BrowserContext* browser_context, | 172 content::BrowserContext* browser_context, |
171 const extensions::Extension* extension, | 173 const extensions::Extension* extension, |
172 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; | 174 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
173 #endif | 175 #endif |
174 | 176 |
| 177 // SyncTypePreferenceProvider implementation: |
| 178 virtual syncer::ModelTypeSet GetPreferredDataTypes() const OVERRIDE; |
| 179 |
175 // ProfileSyncServiceObserver implementation: | 180 // ProfileSyncServiceObserver implementation: |
176 virtual void OnStateChanged() OVERRIDE; | 181 virtual void OnStateChanged() OVERRIDE; |
177 | 182 |
178 // chrome::BrowserListObserver implementation: | 183 // chrome::BrowserListObserver implementation: |
179 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; | 184 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; |
180 | 185 |
181 private: | 186 private: |
182 friend class SupervisedUserServiceExtensionTestBase; | 187 friend class SupervisedUserServiceExtensionTestBase; |
183 friend class SupervisedUserServiceFactory; | 188 friend class SupervisedUserServiceFactory; |
184 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); | 189 FRIEND_TEST_ALL_PREFIXES(SupervisedUserServiceTest, ClearOmitOnRegistration); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 289 |
285 // True iff we're waiting for the Sync service to be initialized. | 290 // True iff we're waiting for the Sync service to be initialized. |
286 bool waiting_for_sync_initialization_; | 291 bool waiting_for_sync_initialization_; |
287 bool is_profile_active_; | 292 bool is_profile_active_; |
288 | 293 |
289 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; | 294 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; |
290 | 295 |
291 // Sets a profile in elevated state for testing if set to true. | 296 // Sets a profile in elevated state for testing if set to true. |
292 bool elevated_for_testing_; | 297 bool elevated_for_testing_; |
293 | 298 |
| 299 // True only when |Init()| method has been called. |
| 300 bool did_init_; |
| 301 |
294 // True only when |Shutdown()| method has been called. | 302 // True only when |Shutdown()| method has been called. |
295 bool did_shutdown_; | 303 bool did_shutdown_; |
296 | 304 |
297 URLFilterContext url_filter_context_; | 305 URLFilterContext url_filter_context_; |
298 | 306 |
299 // Used to create permission requests. | 307 // Used to create permission requests. |
300 scoped_ptr<PermissionRequestCreator> permissions_creator_; | 308 scoped_ptr<PermissionRequestCreator> permissions_creator_; |
301 | 309 |
302 // True iff we are waiting for a permission request to be issued. | 310 // True iff we are waiting for a permission request to be issued. |
303 bool waiting_for_permissions_; | 311 bool waiting_for_permissions_; |
304 | 312 |
305 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; | 313 base::WeakPtrFactory<SupervisedUserService> weak_ptr_factory_; |
306 }; | 314 }; |
307 | 315 |
308 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ | 316 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SERVICE_H_ |
OLD | NEW |