Commit 104a2ebe authored by Denis Kuznetsov's avatar Denis Kuznetsov Committed by Commit Bot

[Usb enrollment] Apply configuration, part 2

All Non-AD enrollment steps, except for authentication:
Device requisition, License type, device attributes

Bug: 854101
Change-Id: I36eb5abae6865f3a7b5c73ada4620fbb6a70d352
Reviewed-on: https://chromium-review.googlesource.com/1120527Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Commit-Queue: Denis Kuznetsov <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589149}
parent 84e2037b
......@@ -44,6 +44,27 @@ const char kUpdateSkipUpdate[] = "updateSkip";
// enrollment at appropriate moment.
const char kWizardAutoEnroll[] = "wizardAutoEnroll";
// String value, containing device requisition parameter.
const char kDeviceRequisition[] = "deviceRequisition";
// == Enrollment screen
// String value indicating which license type should automatically be used if
// license selection is done on a client side.
const char kEnrollmentLicenseType[] = "enrollmentLicenseType";
// String value indicating what value would be propagated to Asset ID field
// on Device Attributes step.
const char kEnrollmentAssetId[] = "enrollmentAssetId";
// String value indicating what value would be propagated to Location field
// on Device Attributes step.
const char kEnrollmentLocation[] = "enrollmentLocation";
// Boolean value, controls if device attributes step should proceed with preset
// values.
const char kEnrollmentAutoAttributes[] = "enrollmentAutoAttributes";
using ValueType = base::Value::Type;
constexpr struct {
......@@ -61,6 +82,14 @@ constexpr struct {
ConfigurationHandlerSide::HANDLER_CPP},
{kWizardAutoEnroll, ValueType::BOOLEAN,
ConfigurationHandlerSide::HANDLER_CPP},
{kDeviceRequisition, ValueType::STRING,
ConfigurationHandlerSide::HANDLER_CPP},
{kEnrollmentLicenseType, ValueType::STRING,
ConfigurationHandlerSide::HANDLER_CPP},
{kEnrollmentLocation, ValueType::STRING,
ConfigurationHandlerSide::HANDLER_CPP},
{kEnrollmentLocation, ValueType::BOOLEAN,
ConfigurationHandlerSide::HANDLER_CPP},
{"desc", ValueType::STRING, ConfigurationHandlerSide::HANDLER_DOC},
{"testValue", ValueType::STRING, ConfigurationHandlerSide::HANDLER_BOTH},
};
......
......@@ -16,14 +16,20 @@ extern const char kWelcomeNext[];
extern const char kNetworkSelectGUID[];
extern const char kEULASendUsageStatistics[];
extern const char kDeviceRequisition[];
extern const char kEULASendUsageStatistics[];
extern const char kEULAAutoAccept[];
extern const char kUpdateSkipUpdate[];
extern const char kWizardAutoEnroll[];
extern const char kEnrollmentLicenseType[];
extern const char kEnrollmentAssetId[];
extern const char kEnrollmentLocation[];
extern const char kEnrollmentAutoAttributes[];
enum class ConfigurationHandlerSide : unsigned int {
HANDLER_JS, // Handled by JS code
HANDLER_CPP, // Handled by C++ code
......@@ -40,7 +46,6 @@ bool ValidateConfiguration(const base::Value& configuration);
void FilterConfiguration(const base::Value& configuration,
ConfigurationHandlerSide side,
base::Value& filtered_result);
} // namespace configuration
} // namespace chromeos
......
......@@ -12,6 +12,7 @@
#include "base/timer/elapsed_timer.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/login/configuration_keys.h"
#include "chrome/browser/chromeos/login/enrollment/enrollment_uma.h"
#include "chrome/browser/chromeos/login/screen_manager.h"
#include "chrome/browser/chromeos/login/screens/base_screen_delegate.h"
......@@ -313,6 +314,22 @@ void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
void EnrollmentScreen::OnMultipleLicensesAvailable(
const EnrollmentLicenseMap& licenses) {
if (GetConfiguration()) {
auto* license_type_value = GetConfiguration()->FindKeyOfType(
configuration::kEnrollmentLicenseType, base::Value::Type::STRING);
if (license_type_value) {
const std::string& license_type = license_type_value->GetString();
for (const auto& it : licenses) {
if (license_type == GetLicenseIdByType(it.first) && it.second > 0) {
VLOG(1) << "Using License type from configuration " << license_type;
OnLicenseTypeSelected(license_type);
return;
}
}
VLOG(1) << "No licenses for License type from configuration "
<< license_type;
}
}
base::DictionaryValue license_dict;
for (const auto& it : licenses)
license_dict.SetInteger(GetLicenseIdByType(it.first), it.second);
......@@ -402,12 +419,45 @@ void EnrollmentScreen::ShowAttributePromptScreen() {
policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
connector->GetDeviceCloudPolicyManager();
std::string asset_id;
std::string location;
if (GetConfiguration()) {
auto* asset_id_value = GetConfiguration()->FindKeyOfType(
configuration::kEnrollmentAssetId, base::Value::Type::STRING);
if (asset_id_value) {
VLOG(1) << "Using Asset ID from configuration "
<< asset_id_value->GetString();
asset_id = asset_id_value->GetString();
}
auto* location_value = GetConfiguration()->FindKeyOfType(
configuration::kEnrollmentLocation, base::Value::Type::STRING);
if (location_value) {
VLOG(1) << "Using Location from configuration "
<< location_value->GetString();
location = location_value->GetString();
}
}
policy::CloudPolicyStore* store = policy_manager->core()->store();
const enterprise_management::PolicyData* policy = store->policy();
std::string asset_id = policy ? policy->annotated_asset_id() : std::string();
std::string location = policy ? policy->annotated_location() : std::string();
if (policy) {
asset_id = policy->annotated_asset_id();
location = policy->annotated_location();
}
if (GetConfiguration()) {
auto* auto_attributes = GetConfiguration()->FindKeyOfType(
configuration::kEnrollmentAutoAttributes, base::Value::Type::BOOLEAN);
if (auto_attributes && auto_attributes->GetBool()) {
VLOG(1) << "Automatically accept attributes";
OnDeviceAttributeProvided(asset_id, location);
return;
}
}
view_->ShowAttributePromptScreen(asset_id, location);
}
......
......@@ -4,6 +4,7 @@
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
#include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper.h"
#include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_impl.h"
......@@ -15,6 +16,7 @@
#include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
#include "chromeos/chromeos_test_utils.h"
#include "chromeos/dbus/dbus_switches.h"
......@@ -744,4 +746,19 @@ IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentConfigurationTest, TestSkipUpdate) {
// We have to remove the enrollment_helper before the dtor gets called.
ResetHelper();
}
// Check that when configuration has requisition, it gets applied at the
// beginning.
IN_PROC_BROWSER_TEST_F(EnterpriseEnrollmentConfigurationTest,
TestDeviceRequisition) {
StartWizard();
LoadConfiguration();
OobeScreenWaiter(OobeScreen::SCREEN_OOBE_EULA).Wait();
auto* policy_manager = g_browser_process->platform_part()
->browser_policy_connector_chromeos()
->GetDeviceCloudPolicyManager();
EXPECT_EQ(policy_manager->GetDeviceRequisition(), "some_requisition");
// We have to remove the enrollment_helper before the dtor gets called.
ResetHelper();
}
} // namespace chromeos
......@@ -320,8 +320,8 @@ WizardController::WizardController()
base::Bind(&WizardController::OnAccessibilityStatusChanged,
weak_factory_.GetWeakPtr()));
}
oobe_configuration_ = OobeConfiguration::Get()->GetConfiguration().Clone();
OobeConfiguration::Get()->AddObserver(this);
OnOobeConfigurationChanged();
}
WizardController::~WizardController() {
......@@ -1431,6 +1431,18 @@ void WizardController::OnOobeConfigurationChanged() {
if (current_screen_) {
current_screen_->SetConfiguration(&oobe_configuration_, true /*notify */);
}
auto* requisition_value = oobe_configuration_.FindKeyOfType(
configuration::kDeviceRequisition, base::Value::Type::STRING);
if (requisition_value) {
auto* policy_manager = g_browser_process->platform_part()
->browser_policy_connector_chromeos()
->GetDeviceCloudPolicyManager();
if (policy_manager) {
VLOG(1) << "Using Device Requisition from configuration"
<< requisition_value->GetString();
policy_manager->SetDeviceRequisition(requisition_value->GetString());
}
}
}
void WizardController::AdvanceToScreen(OobeScreen screen) {
......
{
"welcomeNext": true,
"networkSelectGuid": "eth1_guid",
"deviceRequisition": "some_requisition",
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment