| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ManualBehavior GetManualBehaviorForURL(const GURL& url); | 109 ManualBehavior GetManualBehaviorForURL(const GURL& url); |
| 110 | 110 |
| 111 // Returns all URLS on the given host that have exceptions. | 111 // Returns all URLS on the given host that have exceptions. |
| 112 void GetManualExceptionsForHost(const std::string& host, | 112 void GetManualExceptionsForHost(const std::string& host, |
| 113 std::vector<GURL>* urls); | 113 std::vector<GURL>* urls); |
| 114 | 114 |
| 115 // Initializes this object. This method does nothing if the profile is not | 115 // Initializes this object. This method does nothing if the profile is not |
| 116 // managed. | 116 // managed. |
| 117 void Init(); | 117 void Init(); |
| 118 | 118 |
| 119 // Marks the profile as managed and initializes it. | |
| 120 void InitForTesting(); | |
| 121 | |
| 122 // Initializes this profile for syncing, using the provided |refresh_token| to | 119 // Initializes this profile for syncing, using the provided |refresh_token| to |
| 123 // mint access tokens for Sync. | 120 // mint access tokens for Sync. |
| 124 void InitSync(const std::string& refresh_token); | 121 void InitSync(const std::string& refresh_token); |
| 125 | 122 |
| 126 // Convenience method that registers this managed user using | 123 // Convenience method that registers this managed user using |
| 127 // |registration_utility| and initializes sync with the returned token. | 124 // |registration_utility| and initializes sync with the returned token. |
| 128 // The |callback| will be called when registration is complete, | 125 // The |callback| will be called when registration is complete, |
| 129 // whether it suceeded or not -- unless registration was cancelled manually, | 126 // whether it suceeded or not -- unless registration was cancelled manually, |
| 130 // in which case the callback will be ignored. | 127 // in which case the callback will be ignored. |
| 131 void RegisterAndInitSync(ManagedUserRegistrationUtility* registration_utility, | 128 void RegisterAndInitSync(ManagedUserRegistrationUtility* registration_utility, |
| 132 Profile* custodian_profile, | 129 Profile* custodian_profile, |
| 133 const std::string& managed_user_id, | 130 const std::string& managed_user_id, |
| 134 const AuthErrorCallback& callback); | 131 const AuthErrorCallback& callback); |
| 135 | 132 |
| 136 // Returns a pseudo-email address for systems that expect well-formed email | 133 // Returns a pseudo-email address for systems that expect well-formed email |
| 137 // addresses (like Sync), even though we're not signed in. | 134 // addresses (like Sync), even though we're not signed in. |
| 138 static const char* GetManagedUserPseudoEmail(); | 135 static const char* GetManagedUserPseudoEmail(); |
| 139 | 136 |
| 140 void set_elevated_for_testing(bool skip) { | 137 void set_elevated_for_testing(bool skip) { |
| 141 elevated_for_testing_ = skip; | 138 elevated_for_testing_ = skip; |
| 142 } | 139 } |
| 143 | 140 |
| 144 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback); | 141 void AddNavigationBlockedCallback(const NavigationBlockedCallback& callback); |
| 145 void DidBlockNavigation(content::WebContents* web_contents); | 142 void DidBlockNavigation(content::WebContents* web_contents); |
| 146 | 143 |
| 147 void AddInitCallback(const base::Closure& callback); | |
| 148 | |
| 149 // extensions::ManagementPolicy::Provider implementation: | 144 // extensions::ManagementPolicy::Provider implementation: |
| 150 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 145 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
| 151 virtual bool UserMayLoad(const extensions::Extension* extension, | 146 virtual bool UserMayLoad(const extensions::Extension* extension, |
| 152 string16* error) const OVERRIDE; | 147 string16* error) const OVERRIDE; |
| 153 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 148 virtual bool UserMayModifySettings(const extensions::Extension* extension, |
| 154 string16* error) const OVERRIDE; | 149 string16* error) const OVERRIDE; |
| 155 | 150 |
| 156 // ProfileSyncServiceObserver implementation: | 151 // ProfileSyncServiceObserver implementation: |
| 157 virtual void OnStateChanged() OVERRIDE; | 152 virtual void OnStateChanged() OVERRIDE; |
| 158 | 153 |
| 159 // content::NotificationObserver implementation: | 154 // content::NotificationObserver implementation: |
| 160 virtual void Observe(int type, | 155 virtual void Observe(int type, |
| 161 const content::NotificationSource& source, | 156 const content::NotificationSource& source, |
| 162 const content::NotificationDetails& details) OVERRIDE; | 157 const content::NotificationDetails& details) OVERRIDE; |
| 163 | 158 |
| 164 // chrome::BrowserListObserver implementation: | 159 // chrome::BrowserListObserver implementation: |
| 165 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; | 160 virtual void OnBrowserSetLastActive(Browser* browser) OVERRIDE; |
| 166 | 161 |
| 167 private: | 162 private: |
| 168 friend class ManagedUserServiceExtensionTest; | 163 friend class ManagedUserServiceExtensionTestBase; |
| 169 friend class ManagedUserServiceFactory; | 164 friend class ManagedUserServiceFactory; |
| 170 FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest, | 165 FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest, |
| 171 ExtensionManagementPolicyProviderUnmanaged); | 166 ExtensionManagementPolicyProviderUnmanaged); |
| 172 FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest, | 167 FRIEND_TEST_ALL_PREFIXES(ManagedUserServiceTest, |
| 173 ExtensionManagementPolicyProviderManaged); | 168 ExtensionManagementPolicyProviderManaged); |
| 174 | 169 |
| 175 // A bridge from ManagedMode (which lives on the UI thread) to the | 170 // A bridge from ManagedMode (which lives on the UI thread) to the |
| 176 // ManagedModeURLFilters, one of which lives on the IO thread. This class | 171 // ManagedModeURLFilters, one of which lives on the IO thread. This class |
| 177 // mediates access to them and makes sure they are kept in sync. | 172 // mediates access to them and makes sure they are kept in sync. |
| 178 class URLFilterContext { | 173 class URLFilterContext { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Owns us via the BrowserContextKeyedService mechanism. | 247 // Owns us via the BrowserContextKeyedService mechanism. |
| 253 Profile* profile_; | 248 Profile* profile_; |
| 254 | 249 |
| 255 content::NotificationRegistrar registrar_; | 250 content::NotificationRegistrar registrar_; |
| 256 PrefChangeRegistrar pref_change_registrar_; | 251 PrefChangeRegistrar pref_change_registrar_; |
| 257 | 252 |
| 258 // True iff we're waiting for the Sync service to be initialized. | 253 // True iff we're waiting for the Sync service to be initialized. |
| 259 bool waiting_for_sync_initialization_; | 254 bool waiting_for_sync_initialization_; |
| 260 bool is_profile_active_; | 255 bool is_profile_active_; |
| 261 | 256 |
| 262 std::vector<base::Closure> init_callbacks_; | |
| 263 | |
| 264 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; | 257 std::vector<NavigationBlockedCallback> navigation_blocked_callbacks_; |
| 265 | 258 |
| 266 // Sets a profile in elevated state for testing if set to true. | 259 // Sets a profile in elevated state for testing if set to true. |
| 267 bool elevated_for_testing_; | 260 bool elevated_for_testing_; |
| 268 | 261 |
| 269 // True only when |Shutdown()| method has been called. | 262 // True only when |Shutdown()| method has been called. |
| 270 bool did_shutdown_; | 263 bool did_shutdown_; |
| 271 | 264 |
| 272 URLFilterContext url_filter_context_; | 265 URLFilterContext url_filter_context_; |
| 273 }; | 266 }; |
| 274 | 267 |
| 275 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | 268 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ |
| OLD | NEW |