| 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/enrollment_screen.h" | 5 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
| 13 #include "base/timer/elapsed_timer.h" | 13 #include "base/timer/elapsed_timer.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_process_platform_part.h" | 15 #include "chrome/browser/browser_process_platform_part.h" |
| 16 #include "chrome/browser/chromeos/login/login_utils.h" | 16 #include "chrome/browser/chromeos/login/login_utils.h" |
| 17 #include "chrome/browser/chromeos/login/screen_manager.h" | 17 #include "chrome/browser/chromeos/login/screen_manager.h" |
| 18 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" | 18 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" |
| 19 #include "chrome/browser/chromeos/login/startup_utils.h" | 19 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 20 #include "chrome/browser/chromeos/login/wizard_controller.h" | 20 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 21 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" | 21 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" |
| 22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
| 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 25 #include "chromeos/dbus/cryptohome_client.h" | 25 #include "chromeos/dbus/cryptohome_client.h" |
| 26 #include "chromeos/dbus/dbus_method_call_status.h" | 26 #include "chromeos/dbus/dbus_method_call_status.h" |
| 27 #include "chromeos/dbus/dbus_thread_manager.h" | 27 #include "chromeos/dbus/dbus_thread_manager.h" |
| 28 #include "chromeos/dbus/session_manager_client.h" | |
| 29 #include "components/pairing/controller_pairing_controller.h" | 28 #include "components/pairing/controller_pairing_controller.h" |
| 30 #include "google_apis/gaia/gaia_auth_util.h" | 29 #include "google_apis/gaia/gaia_auth_util.h" |
| 31 #include "google_apis/gaia/google_service_auth_error.h" | 30 #include "google_apis/gaia/google_service_auth_error.h" |
| 32 #include "policy/proto/device_management_backend.pb.h" | 31 #include "policy/proto/device_management_backend.pb.h" |
| 33 | 32 |
| 34 using namespace pairing_chromeos; | 33 using namespace pairing_chromeos; |
| 35 | 34 |
| 36 // Do not change the UMA histogram parameters without renaming the histograms! | 35 // Do not change the UMA histogram parameters without renaming the histograms! |
| 37 #define UMA_ENROLLMENT_TIME(histogram_name, elapsed_timer) \ | 36 #define UMA_ENROLLMENT_TIME(histogram_name, elapsed_timer) \ |
| 38 do { \ | 37 do { \ |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 231 } |
| 233 | 232 |
| 234 if (is_auto_enrollment()) | 233 if (is_auto_enrollment()) |
| 235 policy::AutoEnrollmentClient::CancelAutoEnrollment(); | 234 policy::AutoEnrollmentClient::CancelAutoEnrollment(); |
| 236 actor_->ResetAuth( | 235 actor_->ResetAuth( |
| 237 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), | 236 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), |
| 238 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); | 237 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); |
| 239 } | 238 } |
| 240 | 239 |
| 241 void EnrollmentScreen::OnConfirmationClosed() { | 240 void EnrollmentScreen::OnConfirmationClosed() { |
| 242 // If the machine has been put in KIOSK mode we have to restart the session | |
| 243 // here to go in the proper KIOSK mode login screen. | |
| 244 policy::BrowserPolicyConnectorChromeOS* connector = | |
| 245 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 246 if (connector->GetDeviceMode() == policy::DEVICE_MODE_RETAIL_KIOSK) { | |
| 247 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); | |
| 248 return; | |
| 249 } | |
| 250 | |
| 251 if (is_auto_enrollment() && | 241 if (is_auto_enrollment() && |
| 252 !enrollment_failed_once_ && | 242 !enrollment_failed_once_ && |
| 253 !user_.empty() && | 243 !user_.empty() && |
| 254 LoginUtils::IsWhitelisted(user_, NULL)) { | 244 LoginUtils::IsWhitelisted(user_, NULL)) { |
| 255 actor_->ShowLoginSpinnerScreen(); | 245 actor_->ShowLoginSpinnerScreen(); |
| 256 Finish(BaseScreenDelegate::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); | 246 Finish(BaseScreenDelegate::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); |
| 257 } else { | 247 } else { |
| 258 actor_->ResetAuth( | 248 actor_->ResetAuth( |
| 259 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), | 249 base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), |
| 260 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); | 250 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); |
| 261 } | 251 } |
| 262 } | 252 } |
| 263 | 253 |
| 264 void EnrollmentScreen::RegisterForDevicePolicy(const std::string& token) { | 254 void EnrollmentScreen::RegisterForDevicePolicy(const std::string& token) { |
| 265 policy::BrowserPolicyConnectorChromeOS* connector = | 255 policy::BrowserPolicyConnectorChromeOS* connector = |
| 266 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 256 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 267 if (connector->IsEnterpriseManaged() && | 257 if (connector->IsEnterpriseManaged() && |
| 268 connector->GetEnterpriseDomain() != gaia::ExtractDomainName(user_)) { | 258 connector->GetEnterpriseDomain() != gaia::ExtractDomainName(user_)) { |
| 269 LOG(ERROR) << "Trying to re-enroll to a different domain than " | 259 LOG(ERROR) << "Trying to re-enroll to a different domain than " |
| 270 << connector->GetEnterpriseDomain(); | 260 << connector->GetEnterpriseDomain(); |
| 271 UMAFailure(policy::kMetricEnrollmentPrecheckDomainMismatch); | 261 UMAFailure(policy::kMetricEnrollmentPrecheckDomainMismatch); |
| 272 actor_->ShowUIError( | 262 actor_->ShowUIError( |
| 273 EnrollmentScreenActor::UI_ERROR_DOMAIN_MISMATCH); | 263 EnrollmentScreenActor::UI_ERROR_DOMAIN_MISMATCH); |
| 274 return; | 264 return; |
| 275 } | 265 } |
| 276 | 266 |
| 277 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes; | 267 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes; |
| 278 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true; | 268 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true; |
| 279 device_modes[policy::DEVICE_MODE_RETAIL_KIOSK] = | |
| 280 enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL; | |
| 281 connector->ScheduleServiceInitialization(0); | 269 connector->ScheduleServiceInitialization(0); |
| 282 | 270 |
| 283 policy::DeviceCloudPolicyInitializer* dcp_initializer = | 271 policy::DeviceCloudPolicyInitializer* dcp_initializer = |
| 284 connector->GetDeviceCloudPolicyInitializer(); | 272 connector->GetDeviceCloudPolicyInitializer(); |
| 285 CHECK(dcp_initializer); | 273 CHECK(dcp_initializer); |
| 286 dcp_initializer->StartEnrollment( | 274 dcp_initializer->StartEnrollment( |
| 287 enterprise_management::PolicyData::ENTERPRISE_MANAGED, | 275 enterprise_management::PolicyData::ENTERPRISE_MANAGED, |
| 288 connector->device_management_service(), | 276 connector->device_management_service(), |
| 289 token, is_auto_enrollment(), device_modes, | 277 token, is_auto_enrollment(), device_modes, |
| 290 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus, | 278 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 sample = policy::kMetricEnrollmentAutoFailed; | 451 sample = policy::kMetricEnrollmentAutoFailed; |
| 464 UMA(sample); | 452 UMA(sample); |
| 465 } | 453 } |
| 466 | 454 |
| 467 void EnrollmentScreen::ShowSigninScreen() { | 455 void EnrollmentScreen::ShowSigninScreen() { |
| 468 actor_->Show(); | 456 actor_->Show(); |
| 469 actor_->ShowSigninScreen(); | 457 actor_->ShowSigninScreen(); |
| 470 } | 458 } |
| 471 | 459 |
| 472 } // namespace chromeos | 460 } // namespace chromeos |
| OLD | NEW |