| 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..ee16133e7ee8c23bc47ed401307adfb9730ac6e7 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) {
|
| @@ -90,9 +90,9 @@ void UserPolicySigninService::RegisterForPolicy(
|
| // 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(
|
| + registration_helper_ = base::MakeUnique<CloudPolicyClientRegistrationHelper>(
|
| policy_client.get(),
|
| - enterprise_management::DeviceRegisterRequest::BROWSER));
|
| + enterprise_management::DeviceRegisterRequest::BROWSER);
|
| registration_helper_->StartRegistrationWithLoginToken(
|
| oauth2_refresh_token,
|
| base::Bind(&UserPolicySigninService::CallPolicyRegistrationCallback,
|
| @@ -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_ = base::MakeUnique<CloudPolicyClientRegistrationHelper>(
|
| + 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) {
|
|
|