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

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

Issue 2977033002: Mixed Licenses Enrollment (Closed)
Patch Set: Fix CloudPolicyClientTest Created 3 years, 5 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..e1dee6fd60193608a449fcd6848ec012c256311d 100644
--- a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
+++ b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
@@ -131,6 +131,7 @@ EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS(
client_id_(client_id),
requisition_(requisition),
completion_callback_(completion_callback),
+ license_type_(em::LicenseType::UNDEFINED),
achuithb 2017/07/31 21:03:23 Initialize in header
Denis Kuznetsov (DE-MUC) 2017/08/01 10:50:54 Done.
enrollment_step_(STEP_PENDING),
weak_ptr_factory_(this) {
CHECK(!client_->is_registered());
@@ -152,6 +153,49 @@ 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 policy::CloudPolicyClient::LicenseMap& license_map) {
+ if (!success) {
+ ReportResult(
+ EnrollmentStatus::ForStatus(EnrollmentStatus::LICENSE_REQUEST_FAILED));
+ return;
+ }
+ if (!available_licenses_callback_) {
achuithb 2017/07/31 21:03:23 Drop {} is_null?
Denis Kuznetsov (DE-MUC) 2017/08/01 10:50:54 Done
+ 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 ::policy::LicenseType::PERPETUAL:
+ license_type_ = ::em::LicenseType::CDM_PERPETUAL;
+ return;
+ case ::policy::LicenseType::ANNUAL:
+ license_type_ = ::em::LicenseType::CDM_ANNUAL;
+ return;
+ case ::policy::LicenseType::KIOSK:
+ license_type_ = ::em::LicenseType::KIOSK;
+ return;
+ case ::policy::LicenseType::UNKNOWN:
+ NOTREACHED();
+ }
+ StartEnrollment();
+}
+
void EnrollmentHandlerChromeOS::StartEnrollment() {
CHECK_EQ(STEP_PENDING, enrollment_step_);
SetStep(STEP_STATE_KEYS);
@@ -322,7 +366,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 +389,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 +681,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