Chromium Code Reviews| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 | 112 |
| 113 void EnterpriseEnrollmentScreen::OnPolicyStateChanged( | 113 void EnterpriseEnrollmentScreen::OnPolicyStateChanged( |
| 114 policy::CloudPolicySubsystem::PolicySubsystemState state, | 114 policy::CloudPolicySubsystem::PolicySubsystemState state, |
| 115 policy::CloudPolicySubsystem::ErrorDetails error_details) { | 115 policy::CloudPolicySubsystem::ErrorDetails error_details) { |
| 116 | 116 |
| 117 if (is_showing_) { | 117 if (is_showing_) { |
| 118 switch (state) { | 118 switch (state) { |
| 119 case policy::CloudPolicySubsystem::UNENROLLED: | 119 case policy::CloudPolicySubsystem::UNENROLLED: |
| 120 switch (error_details) { | 120 switch (error_details) { |
| 121 case policy::CloudPolicySubsystem::BAD_SERIAL_NUMBER: | 121 case policy::CloudPolicySubsystem::BAD_SERIAL_NUMBER: |
| 122 actor_->ShowSerialNumberError(); | 122 actor_->ShowEnrollmentError( |
| 123 EnterpriseEnrollmentScreenActor::SERIAL_NUMBER_ERROR); | |
| 123 break; | 124 break; |
| 124 case policy::CloudPolicySubsystem::BAD_ENROLLMENT_MODE: | 125 case policy::CloudPolicySubsystem::BAD_ENROLLMENT_MODE: |
| 125 actor_->ShowEnrollmentModeError(); | 126 actor_->ShowEnrollmentError( |
| 127 EnterpriseEnrollmentScreenActor::ENROLLMENT_MODE_ERROR); | |
| 128 break; | |
| 129 case policy::CloudPolicySubsystem::MISSING_LICENSES: | |
| 130 actor_->ShowEnrollmentError( | |
| 131 EnterpriseEnrollmentScreenActor::MISSING_LICESES_ERROR); | |
|
Mattias Nissler (ping if slow)
2012/06/26 09:19:34
Eclipse auto-complete strikes again.
pastarmovj
2012/06/26 16:59:29
Prolly :) Fixed.
| |
| 126 break; | 132 break; |
| 127 default: // Still working... | 133 default: // Still working... |
| 128 return; | 134 return; |
| 129 } | 135 } |
| 130 break; | 136 break; |
| 131 case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN: | 137 case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN: |
| 132 case policy::CloudPolicySubsystem::LOCAL_ERROR: | 138 case policy::CloudPolicySubsystem::LOCAL_ERROR: |
| 133 actor_->ShowFatalEnrollmentError(); | 139 actor_->ShowEnrollmentError( |
| 140 EnterpriseEnrollmentScreenActor::FATAL_ENROLLMENT_ERROR); | |
| 134 break; | 141 break; |
| 135 case policy::CloudPolicySubsystem::UNMANAGED: | 142 case policy::CloudPolicySubsystem::UNMANAGED: |
| 136 actor_->ShowAccountError(); | 143 actor_->ShowEnrollmentError( |
| 144 EnterpriseEnrollmentScreenActor::ACCOUNT_ERROR); | |
| 137 break; | 145 break; |
| 138 case policy::CloudPolicySubsystem::NETWORK_ERROR: | 146 case policy::CloudPolicySubsystem::NETWORK_ERROR: |
| 139 actor_->ShowNetworkEnrollmentError(); | 147 actor_->ShowEnrollmentError( |
| 148 EnterpriseEnrollmentScreenActor::NETWORK_ENROLLMENT_ERROR); | |
| 140 break; | 149 break; |
| 141 case policy::CloudPolicySubsystem::TOKEN_FETCHED: | 150 case policy::CloudPolicySubsystem::TOKEN_FETCHED: |
| 142 if (!is_auto_enrollment_ || | 151 if (!is_auto_enrollment_ || |
| 143 g_browser_process->browser_policy_connector()-> | 152 g_browser_process->browser_policy_connector()-> |
| 144 GetDeviceCloudPolicyDataStore()->device_mode() == | 153 GetDeviceCloudPolicyDataStore()->device_mode() == |
| 145 policy::DEVICE_MODE_ENTERPRISE) { | 154 policy::DEVICE_MODE_ENTERPRISE) { |
| 146 WriteInstallAttributesData(); | 155 WriteInstallAttributesData(); |
| 147 return; | 156 return; |
| 148 } else { | 157 } else { |
| 149 LOG(ERROR) << "Enrollment can not proceed because Auto-enrollment is " | 158 LOG(ERROR) << "Enrollment can not proceed because Auto-enrollment is " |
| 150 << "not supported for non-enterprise enrollment modes."; | 159 << "not supported for non-enterprise enrollment modes."; |
| 151 policy::AutoEnrollmentClient::CancelAutoEnrollment(); | 160 policy::AutoEnrollmentClient::CancelAutoEnrollment(); |
| 152 is_auto_enrollment_ = false; | 161 is_auto_enrollment_ = false; |
| 153 actor_->ShowAutoEnrollmentError(); | 162 actor_->ShowEnrollmentError( |
| 163 EnterpriseEnrollmentScreenActor::AUTO_ENROLLMENT_ERROR); | |
| 154 // Set the error state to something distinguishable in the logs. | 164 // Set the error state to something distinguishable in the logs. |
| 155 state = policy::CloudPolicySubsystem::LOCAL_ERROR; | 165 state = policy::CloudPolicySubsystem::LOCAL_ERROR; |
| 156 error_details = policy::CloudPolicySubsystem::AUTO_ENROLLMENT_ERROR; | 166 error_details = policy::CloudPolicySubsystem::AUTO_ENROLLMENT_ERROR; |
| 157 } | 167 } |
| 158 break; | 168 break; |
| 159 case policy::CloudPolicySubsystem::SUCCESS: | 169 case policy::CloudPolicySubsystem::SUCCESS: |
| 160 // Success! | 170 // Success! |
| 161 registrar_.reset(); | 171 registrar_.reset(); |
| 162 actor_->ShowConfirmationScreen(); | 172 actor_->ShowConfirmationScreen(); |
| 163 return; | 173 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 // InstallAttributes not ready yet, retry later. | 206 // InstallAttributes not ready yet, retry later. |
| 197 LOG(WARNING) << "Install Attributes not ready yet will retry in " | 207 LOG(WARNING) << "Install Attributes not ready yet will retry in " |
| 198 << kLockRetryIntervalMs << "ms."; | 208 << kLockRetryIntervalMs << "ms."; |
| 199 MessageLoop::current()->PostDelayedTask( | 209 MessageLoop::current()->PostDelayedTask( |
| 200 FROM_HERE, | 210 FROM_HERE, |
| 201 base::Bind(&EnterpriseEnrollmentScreen::WriteInstallAttributesData, | 211 base::Bind(&EnterpriseEnrollmentScreen::WriteInstallAttributesData, |
| 202 weak_ptr_factory_.GetWeakPtr()), | 212 weak_ptr_factory_.GetWeakPtr()), |
| 203 base::TimeDelta::FromMilliseconds(kLockRetryIntervalMs)); | 213 base::TimeDelta::FromMilliseconds(kLockRetryIntervalMs)); |
| 204 lockbox_init_duration_ += kLockRetryIntervalMs; | 214 lockbox_init_duration_ += kLockRetryIntervalMs; |
| 205 } else { | 215 } else { |
| 206 actor_->ShowLockboxTimeoutError(); | 216 actor_->ShowEnrollmentError( |
| 217 EnterpriseEnrollmentScreenActor::LOCKBOX_TIMEOUT_ERROR); | |
| 207 } | 218 } |
| 208 return; | 219 return; |
| 209 } | 220 } |
| 210 case policy::EnterpriseInstallAttributes::LOCK_BACKEND_ERROR: { | 221 case policy::EnterpriseInstallAttributes::LOCK_BACKEND_ERROR: { |
| 211 actor_->ShowFatalEnrollmentError(); | 222 actor_->ShowEnrollmentError( |
| 223 EnterpriseEnrollmentScreenActor::FATAL_ENROLLMENT_ERROR); | |
| 212 return; | 224 return; |
| 213 } | 225 } |
| 214 case policy::EnterpriseInstallAttributes::LOCK_WRONG_USER: { | 226 case policy::EnterpriseInstallAttributes::LOCK_WRONG_USER: { |
| 215 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs " | 227 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs " |
| 216 << "has been locked already!"; | 228 << "has been locked already!"; |
| 217 actor_->ShowFatalEnrollmentError(); | 229 actor_->ShowEnrollmentError( |
| 230 EnterpriseEnrollmentScreenActor::FATAL_ENROLLMENT_ERROR); | |
| 218 return; | 231 return; |
| 219 } | 232 } |
| 220 } | 233 } |
| 221 | 234 |
| 222 NOTREACHED(); | 235 NOTREACHED(); |
| 223 } | 236 } |
| 224 | 237 |
| 225 void EnterpriseEnrollmentScreen::RegisterForDevicePolicy( | 238 void EnterpriseEnrollmentScreen::RegisterForDevicePolicy( |
| 226 const std::string& token) { | 239 const std::string& token) { |
| 227 policy::BrowserPolicyConnector* connector = | 240 policy::BrowserPolicyConnector* connector = |
| 228 g_browser_process->browser_policy_connector(); | 241 g_browser_process->browser_policy_connector(); |
| 229 if (!connector->device_cloud_policy_subsystem()) { | 242 if (!connector->device_cloud_policy_subsystem()) { |
| 230 LOG(ERROR) << "Cloud policy subsystem not initialized."; | 243 LOG(ERROR) << "Cloud policy subsystem not initialized."; |
| 231 } else if (connector->device_cloud_policy_subsystem()->state() == | 244 } else if (connector->device_cloud_policy_subsystem()->state() == |
| 232 policy::CloudPolicySubsystem::SUCCESS) { | 245 policy::CloudPolicySubsystem::SUCCESS) { |
| 233 LOG(ERROR) << "A previous enrollment already succeeded!"; | 246 LOG(ERROR) << "A previous enrollment already succeeded!"; |
| 234 } else { | 247 } else { |
| 235 if (connector->IsEnterpriseManaged() && | 248 if (connector->IsEnterpriseManaged() && |
| 236 connector->GetEnterpriseDomain() != gaia::ExtractDomainName(user_)) { | 249 connector->GetEnterpriseDomain() != gaia::ExtractDomainName(user_)) { |
| 237 LOG(ERROR) << "Trying to re-enroll to a different domain than " | 250 LOG(ERROR) << "Trying to re-enroll to a different domain than " |
| 238 << connector->GetEnterpriseDomain(); | 251 << connector->GetEnterpriseDomain(); |
| 239 if (is_showing_) | 252 if (is_showing_) |
|
Mattias Nissler (ping if slow)
2012/06/26 09:19:34
curlies
pastarmovj
2012/06/26 16:59:29
Done.
| |
| 240 actor_->ShowDomainMismatchError(); | 253 actor_->ShowEnrollmentError( |
| 254 EnterpriseEnrollmentScreenActor::DOMAIN_MISMATCH_ERROR); | |
| 241 return; | 255 return; |
| 242 } | 256 } |
| 243 // Make sure the device policy subsystem is in a clean slate. | 257 // Make sure the device policy subsystem is in a clean slate. |
| 244 connector->ResetDevicePolicy(); | 258 connector->ResetDevicePolicy(); |
| 245 connector->ScheduleServiceInitialization(0); | 259 connector->ScheduleServiceInitialization(0); |
| 246 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar( | 260 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar( |
| 247 connector->device_cloud_policy_subsystem(), this)); | 261 connector->device_cloud_policy_subsystem(), this)); |
| 248 // Push the credentials to the policy infrastructure. It'll start enrollment | 262 // Push the credentials to the policy infrastructure. It'll start enrollment |
| 249 // and notify us of progress through CloudPolicySubsystem::Observer. | 263 // and notify us of progress through CloudPolicySubsystem::Observer. |
| 250 connector->RegisterForDevicePolicy(user_, token, | 264 connector->RegisterForDevicePolicy(user_, token, |
| 251 is_auto_enrollment_, | 265 is_auto_enrollment_, |
| 252 connector->IsEnterpriseManaged()); | 266 connector->IsEnterpriseManaged()); |
| 253 return; | 267 return; |
| 254 } | 268 } |
| 255 NOTREACHED(); | 269 NOTREACHED(); |
| 256 if (is_showing_) | 270 if (is_showing_) |
|
Mattias Nissler (ping if slow)
2012/06/26 09:19:34
curlies
pastarmovj
2012/06/26 16:59:29
Done.
| |
| 257 actor_->ShowFatalEnrollmentError(); | 271 actor_->ShowEnrollmentError( |
| 272 EnterpriseEnrollmentScreenActor::FATAL_ENROLLMENT_ERROR); | |
| 258 } | 273 } |
| 259 | 274 |
| 260 } // namespace chromeos | 275 } // namespace chromeos |
| OLD | NEW |