| Index: chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher.cc
|
| diff --git a/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher.cc b/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher.cc
|
| index d882cfcbb9af4d12aa5a05768a35fcc2f379aeb4..8a3cb3a7bbed666f676792778c3370dfa2824b62 100644
|
| --- a/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher.cc
|
| +++ b/chrome/browser/chromeos/arc/auth/arc_active_directory_enrollment_token_fetcher.cc
|
| @@ -13,8 +13,15 @@
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
|
| #include "chrome/browser/chromeos/policy/dm_token_storage.h"
|
| +#include "chrome/browser/chromeos/profiles/profile_helper.h"
|
| #include "chrome/browser/chromeos/settings/install_attributes.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| #include "components/policy/core/common/cloud/device_management_service.h"
|
| +#include "components/policy/core/common/policy_pref_names.h"
|
| +#include "components/pref_registry/pref_registry_syncable.h"
|
| +#include "components/prefs/pref_service.h"
|
| +#include "components/user_manager/user.h"
|
| +#include "components/user_manager/user_manager.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
|
|
| namespace {
|
| @@ -42,6 +49,13 @@ ArcActiveDirectoryEnrollmentTokenFetcher::
|
| ArcActiveDirectoryEnrollmentTokenFetcher::
|
| ~ArcActiveDirectoryEnrollmentTokenFetcher() = default;
|
|
|
| +// static
|
| +void ArcActiveDirectoryEnrollmentTokenFetcher::RegisterProfilePrefs(
|
| + user_prefs::PrefRegistrySyncable* registry) {
|
| + registry->RegisterStringPref(policy::policy_prefs::kActiveDirectoryPlayUserId,
|
| + std::string());
|
| +}
|
| +
|
| void ArcActiveDirectoryEnrollmentTokenFetcher::Fetch(
|
| const FetchCallback& callback) {
|
| DCHECK(callback_.is_null());
|
| @@ -80,6 +94,24 @@ void ArcActiveDirectoryEnrollmentTokenFetcher::OnDMTokenAvailable(
|
| weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| +Profile* GetProfile() {
|
| + const user_manager::User* const primary_user =
|
| + user_manager::UserManager::Get()->GetPrimaryUser();
|
| + if (!primary_user)
|
| + NOTREACHED() << "No primary user is present.";
|
| + return chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user);
|
| +}
|
| +
|
| +void SavePlayUserId(const std::string& user_id) {
|
| + Profile* const profile = GetProfile();
|
| + if (!profile) {
|
| + LOG(ERROR) << "Profile is not available.";
|
| + return;
|
| + }
|
| + profile->GetPrefs()->SetString(
|
| + policy::policy_prefs::kActiveDirectoryPlayUserId, user_id);
|
| +}
|
| +
|
| void ArcActiveDirectoryEnrollmentTokenFetcher::OnFetchEnrollmentTokenCompleted(
|
| policy::DeviceManagementStatus status,
|
| int net_error,
|
| @@ -98,6 +130,9 @@ void ArcActiveDirectoryEnrollmentTokenFetcher::OnFetchEnrollmentTokenCompleted(
|
| return;
|
| }
|
|
|
| + SavePlayUserId(
|
| + response.active_directory_enroll_play_user_response().user_id());
|
| +
|
| base::ResetAndReturn(&callback_)
|
| .Run(response.active_directory_enroll_play_user_response()
|
| .enrollment_token());
|
|
|