Chromium Code Reviews| Index: chrome/browser/policy/user_policy_signin_service.h |
| diff --git a/chrome/browser/policy/user_policy_signin_service.h b/chrome/browser/policy/user_policy_signin_service.h |
| index 4906f126b7197f2b8c9ed974204397e6620ca3c6..f1902ee6b72b1b350069e20f48bde6538e050497 100644 |
| --- a/chrome/browser/policy/user_policy_signin_service.h |
| +++ b/chrome/browser/policy/user_policy_signin_service.h |
| @@ -13,9 +13,7 @@ |
| #include "chrome/browser/profiles/profile_keyed_service.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| -#include "google_apis/gaia/oauth2_access_token_consumer.h" |
| -class OAuth2AccessTokenFetcher; |
| class Profile; |
| namespace base { |
| @@ -24,6 +22,8 @@ class Time; |
| namespace policy { |
| +class CloudPolicyClientRegistrationHelper; |
| +class CloudPolicyClient; |
| class UserCloudPolicyManager; |
| // The UserPolicySigninService is responsible for interacting with the policy |
| @@ -40,12 +40,14 @@ class UserCloudPolicyManager; |
| // the policy infrastructure to ensure that any cached policy is cleared. |
| class UserPolicySigninService |
| : public ProfileKeyedService, |
| - public OAuth2AccessTokenConsumer, |
| public CloudPolicyService::Observer, |
| - public CloudPolicyClient::Observer, |
| - public UserInfoFetcher::Delegate, |
| public content::NotificationObserver { |
| public: |
| + // The callback invoked once policy registration is complete. Passed |
| + // CloudPolicyClient parameter is null if DMToken fetch failed. |
| + typedef base::Callback<void(scoped_ptr<CloudPolicyClient>)> |
|
Joao da Silva
2013/02/07 23:01:25
#include "base/callback.h"
Andrew T Wilson (Slow)
2013/02/08 10:48:07
Done.
|
| + PolicyRegistrationCallback; |
| + |
| // The callback invoked once policy fetch is complete. Passed boolean |
| // parameter is set to true if the policy fetch succeeded. |
| typedef base::Callback<void(bool)> PolicyFetchCallback; |
| @@ -54,12 +56,19 @@ class UserPolicySigninService |
| explicit UserPolicySigninService(Profile* profile); |
| virtual ~UserPolicySigninService(); |
| - // Initiates a policy fetch as part of user signin. The |oauth2_access_token| |
| - // is explicitly passed because TokenService does not have the token yet |
| - // (to prevent services from using it until after we've fetched policy). |
| - // |callback| is invoked once the policy fetch is complete, passing true if |
| - // the policy fetch succeeded. |
| - void FetchPolicyForSignedInUser(const std::string& oauth2_access_token, |
| + // Returns a DMToken for fetching policy for a user. The |
|
Joao da Silva
2013/02/07 23:01:25
I guess this passes a CloudPolicyClient to the cal
Andrew T Wilson (Slow)
2013/02/08 10:48:07
Done.
|
| + // |oauth2_login_token| and |username| are explicitly passed because |
| + // the user is not signed in yet (TokenService does not have any tokens yet |
| + // to prevent services from using it until after we've fetched policy). |
| + void RegisterPolicyClient(const std::string& username, |
| + const std::string& oauth2_login_token, |
| + const PolicyRegistrationCallback& callback); |
| + |
| + // Initiates a policy fetch as part of user signin, using a CloudPolicyClient |
| + // previously initialized via RegisterPolicyClient. |callback| is invoked |
| + // once the policy fetch is complete, passing true if the policy fetch |
| + // succeeded. |
| + void FetchPolicyForSignedInUser(scoped_ptr<CloudPolicyClient> client, |
| const PolicyFetchCallback& callback); |
| // content::NotificationObserver implementation. |
| @@ -70,33 +79,21 @@ class UserPolicySigninService |
| // CloudPolicyService::Observer implementation. |
| virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; |
| - // CloudPolicyClient::Observer implementation. |
| - virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; |
| - virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; |
| - virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; |
| - |
| - // OAuth2AccessTokenConsumer implementation. |
| - virtual void OnGetTokenSuccess(const std::string& access_token, |
| - const base::Time& expiration_time) OVERRIDE; |
| - virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
| - |
| // ProfileKeyedService implementation: |
| virtual void Shutdown() OVERRIDE; |
| - // UserInfoFetcher::Delegate implementation: |
| - virtual void OnGetUserInfoSuccess(const DictionaryValue* response) OVERRIDE; |
| - virtual void OnGetUserInfoFailure( |
| - const GoogleServiceAuthError& error) OVERRIDE; |
| - |
| private: |
| - // Returns false if cloud policy is disabled or if the currently signed-in |
| - // user is definitely not from a hosted domain (according to the blacklist in |
| + // Returns false if cloud policy is disabled or if the passed |email_address| |
| + // is definitely not from a hosted domain (according to the blacklist in |
| // BrowserPolicyConnector::IsNonEnterpriseUser()). |
| - bool ShouldLoadPolicyForSignedInUser(); |
| + bool ShouldLoadPolicyForUser(const std::string& email_address); |
| - // Initializes the UserCloudPolicyManager to reflect the currently-signed-in |
| - // user. |
| - void InitializeUserCloudPolicyManager(); |
| + // Initializes the UserCloudPolicyManager using the passed CloudPolicyClient. |
| + void InitializeUserCloudPolicyManager(scoped_ptr<CloudPolicyClient> client); |
| + |
| + // Initializes the UserCloudPolicyManager with policy for the currently |
| + // signed-in user. |
| + void InitializeForSignedInUser(); |
| // Fetches an OAuth token to allow the cloud policy service to register with |
| // the cloud policy server. |oauth_login_token| should contain an OAuth login |
| @@ -104,19 +101,22 @@ class UserPolicySigninService |
| // device_management service. |
| void RegisterCloudPolicyService(std::string oauth_login_token); |
| + // Callback invoked when policy registration has finished. |
| + void OnRegistrationComplete(); |
| + |
| // Helper routines to (un)register for CloudPolicyService and |
| // CloudPolicyClient notifications. |
| void StartObserving(); |
| void StopObserving(); |
| - // If a policy fetch was requested, invokes the callback passing through the |
| - // |success| flag. |
| - void NotifyPendingFetchCallback(bool success); |
| - |
| // Shuts down the UserCloudPolicyManager (for example, after the user signs |
| // out) and deletes any cached policy. |
| void ShutdownUserCloudPolicyManager(); |
| + // Invoked when a policy registration request is complete. |
| + void CallPolicyRegistrationCallback(scoped_ptr<CloudPolicyClient> client, |
| + PolicyRegistrationCallback callback); |
| + |
| // Convenience helper to get the UserCloudPolicyManager for |profile_|. |
| UserCloudPolicyManager* GetManager(); |
| @@ -126,25 +126,9 @@ class UserPolicySigninService |
| // Weak pointer to the profile this service is associated with. |
| Profile* profile_; |
| - // If true, we have a pending fetch so notify the callback the next time |
| - // the appropriate notification is delivered from CloudPolicyService/Client. |
| - bool pending_fetch_; |
| - |
| - // The callback to invoke when the pending policy fetch is completed. |
| - PolicyFetchCallback pending_fetch_callback_; |
| - |
| content::NotificationRegistrar registrar_; |
| - // Fetcher used while obtaining an OAuth token for client registration. |
| - scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_; |
| - |
| - // Helper class for fetching information from GAIA about the currently |
| - // signed-in user. |
| - scoped_ptr<UserInfoFetcher> user_info_fetcher_; |
| - |
| - // Access token used to register the CloudPolicyClient and also access |
| - // GAIA to get information about the signed in user. |
| - std::string oauth_access_token_; |
| + scoped_ptr<CloudPolicyClientRegistrationHelper> registration_helper_; |
| DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); |
| }; |