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_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_IOS_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_IOS_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_IOS_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_IOS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
9 | 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h" | 16 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h" |
16 | 17 |
17 class ProfileOAuth2TokenService; | 18 class ProfileOAuth2TokenService; |
18 class Profile; | 19 class Profile; |
(...skipping 21 matching lines...) Expand all Loading... |
40 Profile* profile, | 41 Profile* profile, |
41 PrefService* local_state, | 42 PrefService* local_state, |
42 DeviceManagementService* device_management_service, | 43 DeviceManagementService* device_management_service, |
43 UserCloudPolicyManager* policy_manager, | 44 UserCloudPolicyManager* policy_manager, |
44 SigninManager* signin_manager, | 45 SigninManager* signin_manager, |
45 scoped_refptr<net::URLRequestContextGetter> system_request_context, | 46 scoped_refptr<net::URLRequestContextGetter> system_request_context, |
46 ProfileOAuth2TokenService* token_service); | 47 ProfileOAuth2TokenService* token_service); |
47 virtual ~UserPolicySigninService(); | 48 virtual ~UserPolicySigninService(); |
48 | 49 |
49 // Registers a CloudPolicyClient for fetching policy for |username|. | 50 // Registers a CloudPolicyClient for fetching policy for |username|. |
50 // This requests an OAuth2 token for the services involved, and contacts | 51 // This requires a valid OAuth access token for the scopes returned by the |
51 // the policy service if the account has management enabled. | 52 // |GetScopes| static function. |callback| is invoked once we have |
52 // |callback| is invoked once we have registered this device to fetch policy, | 53 // registered this device to fetch policy, or once it is determined that |
53 // or once it is determined that |username| is not a managed account. | 54 // |username| is not a managed account. |
54 void RegisterForPolicy(const std::string& username, | 55 void RegisterForPolicy(const std::string& username, |
| 56 const std::string& access_token, |
55 PolicyRegistrationBlockCallback callback); | 57 PolicyRegistrationBlockCallback callback); |
56 | 58 |
| 59 static std::vector<std::string> GetScopes(); |
| 60 |
57 // Wrapper for FetchPolicyForSignedInUser that uses a block instead of | 61 // Wrapper for FetchPolicyForSignedInUser that uses a block instead of |
58 // a base::Callback. | 62 // a base::Callback. |
59 void FetchPolicy( | 63 void FetchPolicy( |
60 const std::string& username, | 64 const std::string& username, |
61 const std::string& dm_token, | 65 const std::string& dm_token, |
62 const std::string& client_id, | 66 const std::string& client_id, |
63 scoped_refptr<net::URLRequestContextGetter> profile_request_context, | 67 scoped_refptr<net::URLRequestContextGetter> profile_request_context, |
64 PolicyFetchBlockCallback callback); | 68 PolicyFetchBlockCallback callback); |
65 | 69 |
66 private: | 70 private: |
67 void CallPolicyRegistrationCallback(scoped_ptr<CloudPolicyClient> client, | 71 void CallPolicyRegistrationCallback(scoped_ptr<CloudPolicyClient> client, |
68 PolicyRegistrationBlockCallback callback); | 72 PolicyRegistrationBlockCallback callback); |
69 | 73 |
70 void CallPolicyFetchCallback(PolicyFetchBlockCallback callback, | 74 void CallPolicyFetchCallback(PolicyFetchBlockCallback callback, |
71 bool succeeded); | 75 bool succeeded); |
72 | 76 |
73 // KeyedService implementation: | 77 // KeyedService implementation: |
74 virtual void Shutdown() OVERRIDE; | 78 virtual void Shutdown() OVERRIDE; |
75 | 79 |
76 // CloudPolicyService::Observer implementation: | 80 // CloudPolicyService::Observer implementation: |
77 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; | 81 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; |
78 | 82 |
79 // Cancels a pending cloud policy registration attempt. | 83 // Cancels a pending cloud policy registration attempt. |
80 void CancelPendingRegistration(); | 84 void CancelPendingRegistration(); |
81 | 85 |
82 scoped_ptr<CloudPolicyClientRegistrationHelper> registration_helper_; | 86 scoped_ptr<CloudPolicyClientRegistrationHelper> registration_helper_; |
83 base::WeakPtrFactory<UserPolicySigninService> weak_factory_; | 87 base::WeakPtrFactory<UserPolicySigninService> weak_factory_; |
84 | 88 |
85 // Weak pointer to the token service used to authenticate the | |
86 // CloudPolicyClient during registration. | |
87 ProfileOAuth2TokenService* oauth2_token_service_; | |
88 | |
89 // The PrefService associated with the profile. | 89 // The PrefService associated with the profile. |
90 PrefService* profile_prefs_; | 90 PrefService* profile_prefs_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); | 92 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); |
93 }; | 93 }; |
94 | 94 |
95 } // namespace policy | 95 } // namespace policy |
96 | 96 |
97 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_IOS_H_ | 97 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_IOS_H_ |
OLD | NEW |