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

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

Issue 2977033002: Mixed Licenses Enrollment (Closed)
Patch Set: 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..edcf862030e413c2f8298a95290f399012db1165 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_(enterprise_management::LicenseType::UNDEFINED),
emaxx 2017/07/21 12:57:30 nit: s/enterprise_management/em/
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:06 Done.
enrollment_step_(STEP_PENDING),
weak_ptr_factory_(this) {
CHECK(!client_->is_registered());
@@ -152,6 +153,48 @@ EnrollmentHandlerChromeOS::~EnrollmentHandlerChromeOS() {
store_->RemoveObserver(this);
}
+void EnrollmentHandlerChromeOS::CheckAvailableLicenses(
+ const LicenseSelectionCallback& license_callback) {
+ CHECK_EQ(STEP_PENDING, enrollment_step_);
+ license_selection_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 (!license_selection_callback_.is_null()) {
emaxx 2017/07/21 12:57:30 nit: It's possible to write it simply as: if (li
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:06 Done.
+ license_selection_callback_.Run(license_map);
+ }
+}
+
+void EnrollmentHandlerChromeOS::StartEnrollmentWithLicense(
+ ::policy::LicenseType license_type) {
+ CHECK_EQ(STEP_PENDING, enrollment_step_);
+ CHECK(license_type != ::policy::LicenseType::UNKNOWN);
emaxx 2017/07/21 12:57:30 nit: Use CHECK_NE?
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:06 Done.
+ switch (license_type) {
+ case ::policy::LicenseType::PERPETUAL:
+ license_type_ = ::enterprise_management::LicenseType::CDM_PERPETUAL;
emaxx 2017/07/21 12:57:30 nit: s/enterprise_management/em/
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:06 Done.
+ return;
emaxx 2017/07/21 12:57:30 This method is called "StartEnrollment...", but do
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:06 Done.
+ case ::policy::LicenseType::ANNUAL:
+ license_type_ = ::enterprise_management::LicenseType::CDM_ANNUAL;
+ return;
+ case ::policy::LicenseType::KIOSK:
+ license_type_ = ::enterprise_management::LicenseType::KIOSK;
+ return;
+ case ::policy::LicenseType::UNKNOWN:
+ NOTREACHED();
+ }
+}
+
void EnrollmentHandlerChromeOS::StartEnrollment() {
CHECK_EQ(STEP_PENDING, enrollment_step_);
SetStep(STEP_STATE_KEYS);
@@ -322,7 +365,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 +388,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 +680,7 @@ void EnrollmentHandlerChromeOS::Stop() {
SetStep(STEP_FINISHED);
weak_ptr_factory_.InvalidateWeakPtrs();
completion_callback_.Reset();
+ license_selection_callback_.Reset();
}
void EnrollmentHandlerChromeOS::ReportResult(EnrollmentStatus status) {

Powered by Google App Engine
This is Rietveld 408576698