| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_helper_
impl.h" | 5 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_
impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void TokenRevoker::OnOAuth2RevokeTokenCompleted() { | 60 void TokenRevoker::OnOAuth2RevokeTokenCompleted() { |
| 61 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 61 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 namespace chromeos { | 66 namespace chromeos { |
| 67 | 67 |
| 68 EnterpriseEnrollmentHelperImpl::EnterpriseEnrollmentHelperImpl( | 68 EnterpriseEnrollmentHelperImpl::EnterpriseEnrollmentHelperImpl( |
| 69 EnrollmentStatusConsumer* status_consumer, | 69 EnrollmentStatusConsumer* status_consumer, |
| 70 ActiveDirectoryJoinDelegate* join_delegate, |
| 70 const policy::EnrollmentConfig& enrollment_config, | 71 const policy::EnrollmentConfig& enrollment_config, |
| 71 const std::string& enrolling_user_domain) | 72 const std::string& enrolling_user_domain) |
| 72 : EnterpriseEnrollmentHelper(status_consumer), | 73 : EnterpriseEnrollmentHelper(status_consumer), |
| 73 enrollment_config_(enrollment_config), | 74 enrollment_config_(enrollment_config), |
| 74 enrolling_user_domain_(enrolling_user_domain), | 75 enrolling_user_domain_(enrolling_user_domain), |
| 76 join_delegate_(join_delegate), |
| 75 weak_ptr_factory_(this) { | 77 weak_ptr_factory_(this) { |
| 76 // Init the TPM if it has not been done until now (in debug build we might | 78 // Init the TPM if it has not been done until now (in debug build we might |
| 77 // have not done that yet). | 79 // have not done that yet). |
| 78 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership( | 80 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership( |
| 79 EmptyVoidDBusMethodCallback()); | 81 EmptyVoidDBusMethodCallback()); |
| 80 } | 82 } |
| 81 | 83 |
| 82 EnterpriseEnrollmentHelperImpl::~EnterpriseEnrollmentHelperImpl() { | 84 EnterpriseEnrollmentHelperImpl::~EnterpriseEnrollmentHelperImpl() { |
| 83 DCHECK( | 85 DCHECK( |
| 84 g_browser_process->IsShuttingDown() || | 86 g_browser_process->IsShuttingDown() || |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 oauth_status_ = OAUTH_FINISHED; | 158 oauth_status_ = OAUTH_FINISHED; |
| 157 status_consumer()->OnOtherError(OTHER_ERROR_DOMAIN_MISMATCH); | 159 status_consumer()->OnOtherError(OTHER_ERROR_DOMAIN_MISMATCH); |
| 158 return; | 160 return; |
| 159 } | 161 } |
| 160 | 162 |
| 161 connector->ScheduleServiceInitialization(0); | 163 connector->ScheduleServiceInitialization(0); |
| 162 policy::DeviceCloudPolicyInitializer* dcp_initializer = | 164 policy::DeviceCloudPolicyInitializer* dcp_initializer = |
| 163 connector->GetDeviceCloudPolicyInitializer(); | 165 connector->GetDeviceCloudPolicyInitializer(); |
| 164 CHECK(dcp_initializer); | 166 CHECK(dcp_initializer); |
| 165 dcp_initializer->StartEnrollment( | 167 dcp_initializer->StartEnrollment( |
| 166 connector->device_management_service(), enrollment_config_, token, | 168 connector->device_management_service(), join_delegate_, |
| 169 enrollment_config_, token, |
| 167 base::Bind(&EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished, | 170 base::Bind(&EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished, |
| 168 weak_ptr_factory_.GetWeakPtr())); | 171 weak_ptr_factory_.GetWeakPtr())); |
| 169 } | 172 } |
| 170 | 173 |
| 171 void EnterpriseEnrollmentHelperImpl::GetDeviceAttributeUpdatePermission() { | 174 void EnterpriseEnrollmentHelperImpl::GetDeviceAttributeUpdatePermission() { |
| 172 // Don't update device attributes for Active Directory management. | |
| 173 if (!enrollment_config_.management_realm.empty()) { | |
| 174 OnDeviceAttributeUpdatePermission(false); | |
| 175 return; | |
| 176 } | |
| 177 | |
| 178 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. | 175 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. |
| 179 LOG(WARNING) << "Get device attribute update permission"; | 176 LOG(WARNING) << "Get device attribute update permission"; |
| 180 policy::BrowserPolicyConnectorChromeOS* connector = | 177 policy::BrowserPolicyConnectorChromeOS* connector = |
| 181 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 178 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 179 // Don't update device attributes for Active Directory management. |
| 180 if (connector->IsActiveDirectoryManaged()) { |
| 181 OnDeviceAttributeUpdatePermission(false); |
| 182 return; |
| 183 } |
| 182 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 184 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 183 connector->GetDeviceCloudPolicyManager(); | 185 connector->GetDeviceCloudPolicyManager(); |
| 184 policy::CloudPolicyClient* client = policy_manager->core()->client(); | 186 policy::CloudPolicyClient* client = policy_manager->core()->client(); |
| 185 | 187 |
| 186 client->GetDeviceAttributeUpdatePermission( | 188 client->GetDeviceAttributeUpdatePermission( |
| 187 oauth_token_, | 189 oauth_token_, |
| 188 base::Bind( | 190 base::Bind( |
| 189 &EnterpriseEnrollmentHelperImpl::OnDeviceAttributeUpdatePermission, | 191 &EnterpriseEnrollmentHelperImpl::OnDeviceAttributeUpdatePermission, |
| 190 weak_ptr_factory_.GetWeakPtr())); | 192 weak_ptr_factory_.GetWeakPtr())); |
| 191 } | 193 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 EnrollmentUMA(sample, enrollment_config_.mode); | 436 EnrollmentUMA(sample, enrollment_config_.mode); |
| 435 } | 437 } |
| 436 | 438 |
| 437 void EnterpriseEnrollmentHelperImpl::OnSigninProfileCleared( | 439 void EnterpriseEnrollmentHelperImpl::OnSigninProfileCleared( |
| 438 const base::Closure& callback) { | 440 const base::Closure& callback) { |
| 439 oauth_data_cleared_ = true; | 441 oauth_data_cleared_ = true; |
| 440 callback.Run(); | 442 callback.Run(); |
| 441 } | 443 } |
| 442 | 444 |
| 443 } // namespace chromeos | 445 } // namespace chromeos |
| OLD | NEW |