| Index: chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc
|
| diff --git a/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc b/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc
|
| index 22605cc8b20186210c7737d3b914575504a0ac9b..a149d0940e8b127900d290ce9cfdbee70c019360 100644
|
| --- a/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc
|
| +++ b/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc
|
| @@ -17,7 +17,6 @@
|
| #include "chrome/browser/chromeos/login/wizard_controller.h"
|
| #include "chrome/browser/policy/auto_enrollment_client.h"
|
| #include "chrome/browser/policy/browser_policy_connector.h"
|
| -#include "chrome/browser/policy/cloud_policy_data_store.h"
|
| #include "chrome/browser/policy/device_cloud_policy_manager_chromeos.h"
|
| #include "chrome/browser/policy/enterprise_metrics.h"
|
| #include "chromeos/dbus/dbus_thread_manager.h"
|
| @@ -29,11 +28,6 @@ namespace chromeos {
|
|
|
| namespace {
|
|
|
| -// Retry for InstallAttrs initialization every 500ms.
|
| -const int kLockRetryIntervalMs = 500;
|
| -// Maximum time to retry InstallAttrs initialization before we give up.
|
| -const int kLockRetryTimeoutMs = 10 * 60 * 1000; // 10 minutes.
|
| -
|
| void UMA(int sample) {
|
| UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
|
| sample,
|
| @@ -188,95 +182,6 @@ void EnterpriseEnrollmentScreen::OnConfirmationClosed() {
|
| }
|
| }
|
|
|
| -void EnterpriseEnrollmentScreen::OnPolicyStateChanged(
|
| - policy::CloudPolicySubsystem::PolicySubsystemState state,
|
| - policy::CloudPolicySubsystem::ErrorDetails error_details) {
|
| -
|
| - switch (state) {
|
| - case policy::CloudPolicySubsystem::UNENROLLED:
|
| - switch (error_details) {
|
| - case policy::CloudPolicySubsystem::BAD_SERIAL_NUMBER:
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForRegistrationError(
|
| - policy::DM_STATUS_SERVICE_INVALID_SERIAL_NUMBER));
|
| - break;
|
| - case policy::CloudPolicySubsystem::BAD_ENROLLMENT_MODE:
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForStatus(
|
| - policy::EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE));
|
| - break;
|
| - case policy::CloudPolicySubsystem::MISSING_LICENSES:
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForRegistrationError(
|
| - policy::DM_STATUS_SERVICE_MISSING_LICENSES));
|
| - break;
|
| - default: // Still working...
|
| - return;
|
| - }
|
| - break;
|
| - case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN:
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForRegistrationError(
|
| - policy::DM_STATUS_SERVICE_MANAGEMENT_TOKEN_INVALID));
|
| - break;
|
| - case policy::CloudPolicySubsystem::LOCAL_ERROR:
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForStoreError(
|
| - policy::CloudPolicyStore::STATUS_STORE_ERROR,
|
| - policy::CloudPolicyValidatorBase::VALIDATION_OK));
|
| - break;
|
| - case policy::CloudPolicySubsystem::UNMANAGED:
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForRegistrationError(
|
| - policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED));
|
| - break;
|
| - case policy::CloudPolicySubsystem::NETWORK_ERROR:
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForRegistrationError(
|
| - policy::DM_STATUS_REQUEST_FAILED));
|
| - break;
|
| - case policy::CloudPolicySubsystem::TOKEN_FETCHED:
|
| - if (!is_auto_enrollment_ ||
|
| - g_browser_process->browser_policy_connector()->
|
| - GetDeviceCloudPolicyDataStore()->device_mode() ==
|
| - policy::DEVICE_MODE_ENTERPRISE) {
|
| - WriteInstallAttributesData();
|
| - return;
|
| - } else {
|
| - LOG(ERROR) << "Enrollment cannot proceed because Auto-enrollment is "
|
| - << "not supported for non-enterprise enrollment modes.";
|
| - policy::AutoEnrollmentClient::CancelAutoEnrollment();
|
| - is_auto_enrollment_ = false;
|
| - UMAFailure(policy::kMetricEnrollmentAutoEnrollmentNotSupported);
|
| - actor_->ShowUIError(
|
| - EnterpriseEnrollmentScreenActor::UI_ERROR_AUTO_ENROLLMENT_BAD_MODE);
|
| - NotifyTestingObservers(false);
|
| - // Set the error state to something distinguishable in the logs.
|
| - state = policy::CloudPolicySubsystem::LOCAL_ERROR;
|
| - error_details = policy::CloudPolicySubsystem::AUTO_ENROLLMENT_ERROR;
|
| - }
|
| - break;
|
| - case policy::CloudPolicySubsystem::SUCCESS:
|
| - // Success!
|
| - registrar_.reset();
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForStatus(
|
| - policy::EnrollmentStatus::STATUS_SUCCESS));
|
| - return;
|
| - }
|
| -
|
| - // We have an error.
|
| - if (!is_auto_enrollment_)
|
| - UMAFailure(policy::kMetricEnrollmentPolicyFailed);
|
| -
|
| - LOG(WARNING) << "Policy subsystem error during enrollment: " << state
|
| - << " details: " << error_details;
|
| -
|
| - // Stop the policy infrastructure.
|
| - registrar_.reset();
|
| - g_browser_process->browser_policy_connector()->ResetDevicePolicy();
|
| -}
|
| -
|
| void EnterpriseEnrollmentScreen::AddTestingObserver(TestingObserver* observer) {
|
| observers_.AddObserver(observer);
|
| }
|
| @@ -286,60 +191,6 @@ void EnterpriseEnrollmentScreen::RemoveTestingObserver(
|
| observers_.RemoveObserver(observer);
|
| }
|
|
|
| -void EnterpriseEnrollmentScreen::WriteInstallAttributesData() {
|
| - // Since this method is also called directly.
|
| - weak_ptr_factory_.InvalidateWeakPtrs();
|
| -
|
| - switch (g_browser_process->browser_policy_connector()->LockDevice(user_)) {
|
| - case policy::EnterpriseInstallAttributes::LOCK_SUCCESS: {
|
| - // Proceed with policy fetch.
|
| - policy::BrowserPolicyConnector* connector =
|
| - g_browser_process->browser_policy_connector();
|
| - connector->FetchCloudPolicy();
|
| - return;
|
| - }
|
| - case policy::EnterpriseInstallAttributes::LOCK_NOT_READY: {
|
| - // We wait up to |kLockRetryTimeoutMs| milliseconds and if it hasn't
|
| - // succeeded by then show an error to the user and stop the enrollment.
|
| - if (lockbox_init_duration_ < kLockRetryTimeoutMs) {
|
| - // InstallAttributes not ready yet, retry later.
|
| - LOG(WARNING) << "Install Attributes not ready yet will retry in "
|
| - << kLockRetryIntervalMs << "ms.";
|
| - MessageLoop::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&EnterpriseEnrollmentScreen::WriteInstallAttributesData,
|
| - weak_ptr_factory_.GetWeakPtr()),
|
| - base::TimeDelta::FromMilliseconds(kLockRetryIntervalMs));
|
| - lockbox_init_duration_ += kLockRetryIntervalMs;
|
| - } else {
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForStatus(
|
| - policy::EnrollmentStatus::STATUS_LOCK_TIMEOUT));
|
| - }
|
| - return;
|
| - }
|
| - case policy::EnterpriseInstallAttributes::LOCK_BACKEND_ERROR: {
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForStatus(
|
| - policy::EnrollmentStatus::STATUS_LOCK_ERROR));
|
| - return;
|
| - }
|
| - case policy::EnterpriseInstallAttributes::LOCK_WRONG_USER: {
|
| - LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs "
|
| - << "has been locked already!";
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForStatus(
|
| - policy::EnrollmentStatus::STATUS_LOCK_WRONG_USER));
|
| - return;
|
| - }
|
| - }
|
| -
|
| - NOTREACHED();
|
| - ReportEnrollmentStatus(
|
| - policy::EnrollmentStatus::ForStatus(
|
| - policy::EnrollmentStatus::STATUS_LOCK_ERROR));
|
| -}
|
| -
|
| void EnterpriseEnrollmentScreen::RegisterForDevicePolicy(
|
| const std::string& token) {
|
| policy::BrowserPolicyConnector* connector =
|
| @@ -355,43 +206,14 @@ void EnterpriseEnrollmentScreen::RegisterForDevicePolicy(
|
| return;
|
| }
|
|
|
| - // If a device cloud policy manager instance is available (i.e. new-style
|
| - // policy is switched on), use that path.
|
| - // TODO(mnissler): Remove the old-style enrollment code path once the code has
|
| - // switched to the new policy code by default.
|
| - if (connector->GetDeviceCloudPolicyManager()) {
|
| - policy::DeviceCloudPolicyManagerChromeOS::AllowedDeviceModes modes;
|
| - modes[policy::DEVICE_MODE_ENTERPRISE] = true;
|
| - modes[policy::DEVICE_MODE_KIOSK] = !is_auto_enrollment_;
|
| - connector->ScheduleServiceInitialization(0);
|
| - connector->GetDeviceCloudPolicyManager()->StartEnrollment(
|
| - token, is_auto_enrollment_, modes,
|
| - base::Bind(&EnterpriseEnrollmentScreen::ReportEnrollmentStatus,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| - return;
|
| - } else if (!connector->device_cloud_policy_subsystem()) {
|
| - LOG(ERROR) << "Cloud policy subsystem not initialized.";
|
| - } else if (connector->device_cloud_policy_subsystem()->state() ==
|
| - policy::CloudPolicySubsystem::SUCCESS) {
|
| - LOG(ERROR) << "A previous enrollment already succeeded!";
|
| - } else {
|
| - // Make sure the device policy subsystem is in a clean slate.
|
| - connector->ResetDevicePolicy();
|
| - connector->ScheduleServiceInitialization(0);
|
| - registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar(
|
| - connector->device_cloud_policy_subsystem(), this));
|
| - // Push the credentials to the policy infrastructure. It'll start enrollment
|
| - // and notify us of progress through CloudPolicySubsystem::Observer.
|
| - connector->RegisterForDevicePolicy(user_, token,
|
| - is_auto_enrollment_,
|
| - connector->IsEnterpriseManaged());
|
| - return;
|
| - }
|
| -
|
| - NOTREACHED();
|
| - UMAFailure(policy::kMetricEnrollmentOtherFailed);
|
| - actor_->ShowUIError(EnterpriseEnrollmentScreenActor::UI_ERROR_FATAL);
|
| - NotifyTestingObservers(false);
|
| + policy::DeviceCloudPolicyManagerChromeOS::AllowedDeviceModes modes;
|
| + modes[policy::DEVICE_MODE_ENTERPRISE] = true;
|
| + modes[policy::DEVICE_MODE_KIOSK] = !is_auto_enrollment_;
|
| + connector->ScheduleServiceInitialization(0);
|
| + connector->GetDeviceCloudPolicyManager()->StartEnrollment(
|
| + token, is_auto_enrollment_, modes,
|
| + base::Bind(&EnterpriseEnrollmentScreen::ReportEnrollmentStatus,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| void EnterpriseEnrollmentScreen::ReportEnrollmentStatus(
|
|
|