Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3127)

Unified Diff: chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc

Issue 2977033002: Mixed Licenses Enrollment (Closed)
Patch Set: Fix last nit Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
diff --git a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
index a7b968e8f750f370ea81bfa931cdfca401697563..faac174c7b35e2d52ed981be68450175edc7543f 100644
--- a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
+++ b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
@@ -152,6 +152,48 @@ EnrollmentHandlerChromeOS::~EnrollmentHandlerChromeOS() {
store_->RemoveObserver(this);
}
+void EnrollmentHandlerChromeOS::CheckAvailableLicenses(
+ const AvailableLicensesCallback& license_callback) {
+ CHECK_EQ(STEP_PENDING, enrollment_step_);
+ available_licenses_callback_ = license_callback;
+ client_->RequestAvailableLicenses(
+ auth_token_,
+ base::Bind(&EnrollmentHandlerChromeOS::HandleAvailableLicensesResult,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void EnrollmentHandlerChromeOS::HandleAvailableLicensesResult(
+ bool success,
+ const CloudPolicyClient::LicenseMap& license_map) {
+ if (!success) {
+ ReportResult(
+ EnrollmentStatus::ForStatus(EnrollmentStatus::LICENSE_REQUEST_FAILED));
+ return;
+ }
+ if (!available_licenses_callback_)
+ available_licenses_callback_.Run(license_map);
+}
+
+void EnrollmentHandlerChromeOS::StartEnrollmentWithLicense(
+ LicenseType license_type) {
+ CHECK_EQ(STEP_PENDING, enrollment_step_);
+ CHECK_NE(license_type, ::policy::LicenseType::UNKNOWN);
+ switch (license_type) {
+ case LicenseType::PERPETUAL:
+ license_type_ = ::em::LicenseType::CDM_PERPETUAL;
+ break;
+ case LicenseType::ANNUAL:
+ license_type_ = ::em::LicenseType::CDM_ANNUAL;
+ break;
+ case LicenseType::KIOSK:
+ license_type_ = ::em::LicenseType::KIOSK;
+ break;
+ case LicenseType::UNKNOWN:
+ NOTREACHED();
+ }
+ StartEnrollment();
+}
+
void EnrollmentHandlerChromeOS::StartEnrollment() {
CHECK_EQ(STEP_PENDING, enrollment_step_);
SetStep(STEP_STATE_KEYS);
@@ -322,7 +364,8 @@ void EnrollmentHandlerChromeOS::StartRegistration() {
client_->Register(
em::DeviceRegisterRequest::DEVICE,
EnrollmentModeToRegistrationFlavor(enrollment_config_.mode),
- auth_token_, client_id_, requisition_, current_state_key_);
+ license_type_, auth_token_, client_id_, requisition_,
+ current_state_key_);
}
}
@@ -344,7 +387,8 @@ void EnrollmentHandlerChromeOS::HandleRegistrationCertificateResult(
client_->RegisterWithCertificate(
em::DeviceRegisterRequest::DEVICE,
EnrollmentModeToRegistrationFlavor(enrollment_config_.mode),
- pem_certificate_chain, client_id_, requisition_, current_state_key_);
+ license_type_, pem_certificate_chain, client_id_, requisition_,
+ current_state_key_);
else
ReportResult(EnrollmentStatus::ForStatus(
EnrollmentStatus::REGISTRATION_CERT_FETCH_FAILED));
@@ -635,6 +679,7 @@ void EnrollmentHandlerChromeOS::Stop() {
SetStep(STEP_FINISHED);
weak_ptr_factory_.InvalidateWeakPtrs();
completion_callback_.Reset();
+ available_licenses_callback_.Reset();
}
void EnrollmentHandlerChromeOS::ReportResult(EnrollmentStatus status) {

Powered by Google App Engine
This is Rietveld 408576698