Chromium Code Reviews| Index: chrome/browser/policy/cloud/user_policy_signin_service.cc |
| diff --git a/chrome/browser/policy/cloud/user_policy_signin_service.cc b/chrome/browser/policy/cloud/user_policy_signin_service.cc |
| index 0a5e82188b4a3c268627c61b99829b82ba3b4a79..e7b0d2eca88393cced4ef4f8c795be2050caea0a 100644 |
| --- a/chrome/browser/policy/cloud/user_policy_signin_service.cc |
| +++ b/chrome/browser/policy/cloud/user_policy_signin_service.cc |
| @@ -71,7 +71,7 @@ void UserPolicySigninService::Shutdown() { |
| oauth2_token_service_->RemoveObserver(this); |
| } |
| -void UserPolicySigninService::RegisterForPolicy( |
| +void UserPolicySigninService::RegisterForPolicyWithLoginToken( |
| const std::string& username, |
| const std::string& oauth2_refresh_token, |
| const PolicyRegistrationCallback& callback) { |
| @@ -101,6 +101,35 @@ void UserPolicySigninService::RegisterForPolicy( |
| callback)); |
| } |
| +void UserPolicySigninService::RegisterForPolicyWithAccountId( |
| + const std::string& username, |
| + const std::string& account_id, |
| + const PolicyRegistrationCallback& callback) { |
| + DCHECK(!account_id.empty()); |
| + |
| + // Create a new CloudPolicyClient for fetching the DMToken. |
| + std::unique_ptr<CloudPolicyClient> policy_client = |
| + CreateClientForRegistrationOnly(username); |
| + if (!policy_client) { |
| + callback.Run(std::string(), std::string()); |
| + return; |
| + } |
| + |
| + // Fire off the registration process. Callback keeps the CloudPolicyClient |
| + // alive for the length of the registration process. Use the system |
| + // request context because the user is not signed in to this profile yet |
| + // (we are just doing a test registration to see if policy is supported for |
| + // this user). |
| + registration_helper_.reset(new CloudPolicyClientRegistrationHelper( |
|
pastarmovj
2017/07/05 13:56:21
nit: Modernize this and the function above to base
msarda
2017/07/05 15:53:59
Done.
|
| + policy_client.get(), |
| + enterprise_management::DeviceRegisterRequest::BROWSER)); |
| + registration_helper_->StartRegistration( |
| + oauth2_token_service_, account_id, |
| + base::Bind(&UserPolicySigninService::CallPolicyRegistrationCallback, |
| + base::Unretained(this), base::Passed(&policy_client), |
| + callback)); |
| +} |
| + |
| void UserPolicySigninService::CallPolicyRegistrationCallback( |
| std::unique_ptr<CloudPolicyClient> client, |
| PolicyRegistrationCallback callback) { |