| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.
h" | 5 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.
h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 NOTREACHED(); | 222 NOTREACHED(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void EnterpriseEnrollmentScreen::RegisterForDevicePolicy( | 225 void EnterpriseEnrollmentScreen::RegisterForDevicePolicy( |
| 226 const std::string& token) { | 226 const std::string& token) { |
| 227 policy::BrowserPolicyConnector* connector = | 227 policy::BrowserPolicyConnector* connector = |
| 228 g_browser_process->browser_policy_connector(); | 228 g_browser_process->browser_policy_connector(); |
| 229 if (!connector->device_cloud_policy_subsystem()) { | 229 if (!connector->device_cloud_policy_subsystem()) { |
| 230 LOG(ERROR) << "Cloud policy subsystem not initialized."; | 230 LOG(ERROR) << "Cloud policy subsystem not initialized."; |
| 231 } else if (connector->IsEnterpriseManaged()) { | |
| 232 LOG(ERROR) << "Device is already enterprise managed!"; | |
| 233 } else if (connector->device_cloud_policy_subsystem()->state() == | 231 } else if (connector->device_cloud_policy_subsystem()->state() == |
| 234 policy::CloudPolicySubsystem::SUCCESS) { | 232 policy::CloudPolicySubsystem::SUCCESS) { |
| 235 LOG(ERROR) << "A previous enrollment already succeeded!"; | 233 LOG(ERROR) << "A previous enrollment already succeeded!"; |
| 236 } else { | 234 } else { |
| 235 if (connector->IsEnterpriseManaged() && |
| 236 connector->GetEnterpriseDomain() != |
| 237 chromeos::Authenticator::ExtractDomainName(user_)) { |
| 238 LOG(ERROR) << "Trying to re-enroll to a different domain than " |
| 239 << connector->GetEnterpriseDomain(); |
| 240 if (is_showing_) |
| 241 actor_->ShowDomainMismatchError(); |
| 242 return; |
| 243 } |
| 237 // Make sure the device policy subsystem is in a clean slate. | 244 // Make sure the device policy subsystem is in a clean slate. |
| 238 connector->ResetDevicePolicy(); | 245 connector->ResetDevicePolicy(); |
| 239 connector->ScheduleServiceInitialization(0); | 246 connector->ScheduleServiceInitialization(0); |
| 240 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar( | 247 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar( |
| 241 connector->device_cloud_policy_subsystem(), this)); | 248 connector->device_cloud_policy_subsystem(), this)); |
| 242 // Push the credentials to the policy infrastructure. It'll start enrollment | 249 // Push the credentials to the policy infrastructure. It'll start enrollment |
| 243 // and notify us of progress through CloudPolicySubsystem::Observer. | 250 // and notify us of progress through CloudPolicySubsystem::Observer. |
| 244 connector->RegisterForDevicePolicy(user_, token, is_auto_enrollment_); | 251 connector->RegisterForDevicePolicy(user_, token, is_auto_enrollment_); |
| 245 return; | 252 return; |
| 246 } | 253 } |
| 247 NOTREACHED(); | 254 NOTREACHED(); |
| 248 if (is_showing_) | 255 if (is_showing_) |
| 249 actor_->ShowFatalEnrollmentError(); | 256 actor_->ShowFatalEnrollmentError(); |
| 250 } | 257 } |
| 251 | 258 |
| 252 } // namespace chromeos | 259 } // namespace chromeos |
| OLD | NEW |