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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_ANDROID_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_ANDROID_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h"
17 class ProfileOAuth2TokenService
;
21 class URLRequestContextGetter
;
26 class CloudPolicyClientRegistrationHelper
;
28 // A specialization of the UserPolicySigninServiceBase for Android.
29 class UserPolicySigninService
: public UserPolicySigninServiceBase
{
31 // Creates a UserPolicySigninService associated with the passed |profile|.
32 UserPolicySigninService(
34 PrefService
* local_state
,
35 DeviceManagementService
* device_management_service
,
36 UserCloudPolicyManager
* policy_manager
,
37 SigninManager
* signin_manager
,
38 scoped_refptr
<net::URLRequestContextGetter
> system_request_context
,
39 ProfileOAuth2TokenService
* token_service
);
40 virtual ~UserPolicySigninService();
42 // Registers a CloudPolicyClient for fetching policy for |username|.
43 // This requests an OAuth2 token for the services involved, and contacts
44 // the policy service if the account has management enabled.
45 // |callback| is invoked once we have registered this device to fetch policy,
46 // or once it is determined that |username| is not a managed account.
47 void RegisterForPolicy(const std::string
& username
,
48 const PolicyRegistrationCallback
& callback
);
51 void CallPolicyRegistrationCallback(scoped_ptr
<CloudPolicyClient
> client
,
52 PolicyRegistrationCallback callback
);
54 // BrowserContextKeyedService implementation:
55 virtual void Shutdown() OVERRIDE
;
57 // CloudPolicyService::Observer implementation:
58 virtual void OnInitializationCompleted(CloudPolicyService
* service
) OVERRIDE
;
60 // Registers for cloud policy for an already signed-in user.
61 void RegisterCloudPolicyService();
63 // Cancels a pending cloud policy registration attempt.
64 void CancelPendingRegistration();
66 void OnRegistrationDone();
68 scoped_ptr
<CloudPolicyClientRegistrationHelper
> registration_helper_
;
69 base::WeakPtrFactory
<UserPolicySigninService
> weak_factory_
;
71 // Weak pointer to the token service used to authenticate the
72 // CloudPolicyClient during registration.
73 ProfileOAuth2TokenService
* oauth2_token_service_
;
75 // The PrefService associated with the profile.
76 PrefService
* profile_prefs_
;
78 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService
);
83 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_ANDROID_H_