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/policy/enrollment_handler_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 | 154 |
155 void EnrollmentHandlerChromeOS::OnStoreLoaded(CloudPolicyStore* store) { | 155 void EnrollmentHandlerChromeOS::OnStoreLoaded(CloudPolicyStore* store) { |
156 DCHECK_EQ(store_, store); | 156 DCHECK_EQ(store_, store); |
157 | 157 |
158 if (enrollment_step_ == STEP_LOADING_STORE) { | 158 if (enrollment_step_ == STEP_LOADING_STORE) { |
159 // If the |store_| wasn't initialized when StartEnrollment() was | 159 // If the |store_| wasn't initialized when StartEnrollment() was |
160 // called, then AttemptRegistration() bails silently. This gets | 160 // called, then AttemptRegistration() bails silently. This gets |
161 // registration rolling again after the store finishes loading. | 161 // registration rolling again after the store finishes loading. |
162 AttemptRegistration(); | 162 AttemptRegistration(); |
163 } else if (enrollment_step_ == STEP_STORE_POLICY) { | 163 } else if (enrollment_step_ == STEP_STORE_POLICY) { |
164 // Store the robot API auth refresh token. | 164 chromeos::DeviceOAuth2TokenServiceFactory::Get( |
165 // Currently optional, so always return success. | 165 base::Bind(&EnrollmentHandlerChromeOS::DidGetTokenService, |
166 chromeos::DeviceOAuth2TokenService* token_service = | 166 weak_factory_.GetWeakPtr())); |
pneubeck (no reviews)
2013/10/22 09:05:03
it needs some reading of the code to see whether i
satorux1
2013/10/22 09:56:43
good point. will take another look tomorrow.
satorux1
2013/10/23 06:35:44
Took a look. It wasn't clear if it's safe to use t
| |
167 chromeos::DeviceOAuth2TokenServiceFactory::Get(); | |
168 if (token_service && !robot_refresh_token_.empty()) { | |
169 token_service->SetAndSaveRefreshToken(robot_refresh_token_); | |
170 | |
171 } | |
172 ReportResult(EnrollmentStatus::ForStatus(EnrollmentStatus::STATUS_SUCCESS)); | |
173 } | 167 } |
174 } | 168 } |
175 | 169 |
170 void EnrollmentHandlerChromeOS::DidGetTokenService( | |
171 chromeos::DeviceOAuth2TokenService* token_service) { | |
172 // Store the robot API auth refresh token. | |
173 // Currently optional, so always return success. | |
174 if (token_service && !robot_refresh_token_.empty()) { | |
175 token_service->SetAndSaveRefreshToken(robot_refresh_token_); | |
176 | |
hashimoto
2013/10/22 08:49:51
nit: No need to have a blank line here?
pneubeck (no reviews)
2013/10/22 09:05:03
nit: remove { } and empty line
satorux1
2013/10/22 09:56:43
Will fix.
satorux1
2013/10/22 09:56:43
will fix.
satorux1
2013/10/23 06:35:44
Done.
| |
177 } | |
178 ReportResult(EnrollmentStatus::ForStatus(EnrollmentStatus::STATUS_SUCCESS)); | |
179 } | |
180 | |
176 void EnrollmentHandlerChromeOS::OnStoreError(CloudPolicyStore* store) { | 181 void EnrollmentHandlerChromeOS::OnStoreError(CloudPolicyStore* store) { |
177 DCHECK_EQ(store_, store); | 182 DCHECK_EQ(store_, store); |
178 ReportResult(EnrollmentStatus::ForStoreError(store_->status(), | 183 ReportResult(EnrollmentStatus::ForStoreError(store_->status(), |
179 store_->validation_status())); | 184 store_->validation_status())); |
180 } | 185 } |
181 | 186 |
182 void EnrollmentHandlerChromeOS::AttemptRegistration() { | 187 void EnrollmentHandlerChromeOS::AttemptRegistration() { |
183 CHECK_EQ(STEP_LOADING_STORE, enrollment_step_); | 188 CHECK_EQ(STEP_LOADING_STORE, enrollment_step_); |
184 if (store_->is_initialized()) { | 189 if (store_->is_initialized()) { |
185 enrollment_step_ = STEP_REGISTRATION; | 190 enrollment_step_ = STEP_REGISTRATION; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 << " " << status.client_status() | 351 << " " << status.client_status() |
347 << " " << status.validation_status() | 352 << " " << status.validation_status() |
348 << " " << status.store_status(); | 353 << " " << status.store_status(); |
349 } | 354 } |
350 | 355 |
351 if (!callback.is_null()) | 356 if (!callback.is_null()) |
352 callback.Run(status); | 357 callback.Run(status); |
353 } | 358 } |
354 | 359 |
355 } // namespace policy | 360 } // namespace policy |
OLD | NEW |