| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_BASE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_BASE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_BASE_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_BASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chrome/browser/signin/signin_manager.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 17 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 18 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 18 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
| 19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 21 | 22 |
| 22 class PrefService; | 23 class PrefService; |
| 23 class Profile; | 24 class Profile; |
| 24 class SigninManager; | |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 class URLRequestContextGetter; | 27 class URLRequestContextGetter; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace policy { | 30 namespace policy { |
| 31 | 31 |
| 32 class DeviceManagementService; | 32 class DeviceManagementService; |
| 33 class UserCloudPolicyManager; | 33 class UserCloudPolicyManager; |
| 34 | 34 |
| 35 // The UserPolicySigninService is responsible for interacting with the policy | 35 // The UserPolicySigninService is responsible for interacting with the policy |
| 36 // infrastructure (mainly UserCloudPolicyManager) to load policy for the signed | 36 // infrastructure (mainly UserCloudPolicyManager) to load policy for the signed |
| 37 // in user. This is the base class that contains shared behavior. | 37 // in user. This is the base class that contains shared behavior. |
| 38 // | 38 // |
| 39 // At signin time, this class initializes the UCPM and loads policy before any | 39 // At signin time, this class initializes the UCPM and loads policy before any |
| 40 // other signed in services are initialized. After each restart, this class | 40 // other signed in services are initialized. After each restart, this class |
| 41 // ensures that the CloudPolicyClient is registered (in case the policy server | 41 // ensures that the CloudPolicyClient is registered (in case the policy server |
| 42 // was offline during the initial policy fetch) and if not it initiates a fresh | 42 // was offline during the initial policy fetch) and if not it initiates a fresh |
| 43 // registration process. | 43 // registration process. |
| 44 // | 44 // |
| 45 // Finally, if the user signs out, this class is responsible for shutting down | 45 // Finally, if the user signs out, this class is responsible for shutting down |
| 46 // the policy infrastructure to ensure that any cached policy is cleared. | 46 // the policy infrastructure to ensure that any cached policy is cleared. |
| 47 class UserPolicySigninServiceBase : public KeyedService, | 47 class UserPolicySigninServiceBase : public KeyedService, |
| 48 public CloudPolicyClient::Observer, | 48 public CloudPolicyClient::Observer, |
| 49 public CloudPolicyService::Observer, | 49 public CloudPolicyService::Observer, |
| 50 public content::NotificationObserver { | 50 public content::NotificationObserver, |
| 51 public SigninManagerBase::Observer { |
| 51 public: | 52 public: |
| 52 // The callback invoked once policy registration is complete. Passed | 53 // The callback invoked once policy registration is complete. Passed |
| 53 // |dm_token| and |client_id| parameters are empty if policy registration | 54 // |dm_token| and |client_id| parameters are empty if policy registration |
| 54 // failed. | 55 // failed. |
| 55 typedef base::Callback<void(const std::string& dm_token, | 56 typedef base::Callback<void(const std::string& dm_token, |
| 56 const std::string& client_id)> | 57 const std::string& client_id)> |
| 57 PolicyRegistrationCallback; | 58 PolicyRegistrationCallback; |
| 58 | 59 |
| 59 // The callback invoked once policy fetch is complete. Passed boolean | 60 // The callback invoked once policy fetch is complete. Passed boolean |
| 60 // parameter is set to true if the policy fetch succeeded. | 61 // parameter is set to true if the policy fetch succeeded. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 // |client_id| fetched via RegisterForPolicy(). |callback| is invoked | 75 // |client_id| fetched via RegisterForPolicy(). |callback| is invoked |
| 75 // once the policy fetch is complete, passing true if the policy fetch | 76 // once the policy fetch is complete, passing true if the policy fetch |
| 76 // succeeded. | 77 // succeeded. |
| 77 void FetchPolicyForSignedInUser( | 78 void FetchPolicyForSignedInUser( |
| 78 const std::string& username, | 79 const std::string& username, |
| 79 const std::string& dm_token, | 80 const std::string& dm_token, |
| 80 const std::string& client_id, | 81 const std::string& client_id, |
| 81 scoped_refptr<net::URLRequestContextGetter> profile_request_context, | 82 scoped_refptr<net::URLRequestContextGetter> profile_request_context, |
| 82 const PolicyFetchCallback& callback); | 83 const PolicyFetchCallback& callback); |
| 83 | 84 |
| 85 // SigninManagerBase::Observer implementation: |
| 86 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; |
| 87 |
| 84 // content::NotificationObserver implementation: | 88 // content::NotificationObserver implementation: |
| 85 virtual void Observe(int type, | 89 virtual void Observe(int type, |
| 86 const content::NotificationSource& source, | 90 const content::NotificationSource& source, |
| 87 const content::NotificationDetails& details) OVERRIDE; | 91 const content::NotificationDetails& details) OVERRIDE; |
| 88 | 92 |
| 89 // CloudPolicyService::Observer implementation: | 93 // CloudPolicyService::Observer implementation: |
| 90 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; | 94 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; |
| 91 | 95 |
| 92 // CloudPolicyClient::Observer implementation: | 96 // CloudPolicyClient::Observer implementation: |
| 93 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; | 97 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 scoped_refptr<net::URLRequestContextGetter> system_request_context_; | 175 scoped_refptr<net::URLRequestContextGetter> system_request_context_; |
| 172 | 176 |
| 173 base::WeakPtrFactory<UserPolicySigninServiceBase> weak_factory_; | 177 base::WeakPtrFactory<UserPolicySigninServiceBase> weak_factory_; |
| 174 | 178 |
| 175 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninServiceBase); | 179 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninServiceBase); |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 } // namespace policy | 182 } // namespace policy |
| 179 | 183 |
| 180 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_BASE_H_ | 184 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_BASE_H_ |
| OLD | NEW |