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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/browser_process_platform_part.h" | 12 #include "chrome/browser/browser_process_platform_part.h" |
13 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
14 #include "chrome/browser/chromeos/login/enrollment/enrollment_uma.h" | 14 #include "chrome/browser/chromeos/login/enrollment/enrollment_uma.h" |
15 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 15 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
16 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 16 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
17 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" | 17 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
20 #include "google_apis/gaia/gaia_auth_consumer.h" | 20 #include "google_apis/gaia/gaia_auth_consumer.h" |
21 #include "google_apis/gaia/gaia_auth_fetcher.h" | 21 #include "google_apis/gaia/gaia_auth_fetcher.h" |
22 #include "google_apis/gaia/gaia_auth_util.h" | 22 #include "google_apis/gaia/gaia_auth_util.h" |
23 #include "google_apis/gaia/gaia_constants.h" | 23 #include "google_apis/gaia/gaia_constants.h" |
24 #include "policy/proto/device_management_backend.pb.h" | |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 // A helper class that takes care of asynchronously revoking a given token. | 27 // A helper class that takes care of asynchronously revoking a given token. |
29 class TokenRevoker : public GaiaAuthConsumer { | 28 class TokenRevoker : public GaiaAuthConsumer { |
30 public: | 29 public: |
31 TokenRevoker(); | 30 TokenRevoker(); |
32 virtual ~TokenRevoker(); | 31 virtual ~TokenRevoker(); |
33 | 32 |
34 void Start(const std::string& token); | 33 void Start(const std::string& token); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 159 } |
161 | 160 |
162 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes; | 161 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes; |
163 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true; | 162 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true; |
164 connector->ScheduleServiceInitialization(0); | 163 connector->ScheduleServiceInitialization(0); |
165 | 164 |
166 policy::DeviceCloudPolicyInitializer* dcp_initializer = | 165 policy::DeviceCloudPolicyInitializer* dcp_initializer = |
167 connector->GetDeviceCloudPolicyInitializer(); | 166 connector->GetDeviceCloudPolicyInitializer(); |
168 CHECK(dcp_initializer); | 167 CHECK(dcp_initializer); |
169 dcp_initializer->StartEnrollment( | 168 dcp_initializer->StartEnrollment( |
170 enterprise_management::PolicyData::ENTERPRISE_MANAGED, | 169 policy::MANAGEMENT_MODE_ENTERPRISE_MANAGED, |
171 connector->device_management_service(), | 170 connector->device_management_service(), |
172 token, | 171 token, |
173 is_auto_enrollment(), | 172 is_auto_enrollment(), |
174 device_modes, | 173 device_modes, |
175 base::Bind(&EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished, | 174 base::Bind(&EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished, |
176 weak_ptr_factory_.GetWeakPtr())); | 175 weak_ptr_factory_.GetWeakPtr())); |
177 } | 176 } |
178 | 177 |
179 void EnterpriseEnrollmentHelperImpl::OnTokenFetched( | 178 void EnterpriseEnrollmentHelperImpl::OnTokenFetched( |
180 size_t fetcher_index, | 179 size_t fetcher_index, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 std::vector<base::Closure> callbacks_to_run; | 386 std::vector<base::Closure> callbacks_to_run; |
388 callbacks_to_run.swap(auth_clear_callbacks_); | 387 callbacks_to_run.swap(auth_clear_callbacks_); |
389 for (std::vector<base::Closure>::iterator callback(callbacks_to_run.begin()); | 388 for (std::vector<base::Closure>::iterator callback(callbacks_to_run.begin()); |
390 callback != callbacks_to_run.end(); | 389 callback != callbacks_to_run.end(); |
391 ++callback) { | 390 ++callback) { |
392 callback->Run(); | 391 callback->Run(); |
393 } | 392 } |
394 } | 393 } |
395 | 394 |
396 } // namespace chromeos | 395 } // namespace chromeos |
OLD | NEW |