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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 | 386 |
387 // GaiaOAuthClient::Delegate callback for OAuth2 refresh token fetched. | 387 // GaiaOAuthClient::Delegate callback for OAuth2 refresh token fetched. |
388 void EnrollmentHandlerChromeOS::OnGetTokensResponse( | 388 void EnrollmentHandlerChromeOS::OnGetTokensResponse( |
389 const std::string& refresh_token, | 389 const std::string& refresh_token, |
390 const std::string& access_token, | 390 const std::string& access_token, |
391 int expires_in_seconds) { | 391 int expires_in_seconds) { |
392 CHECK_EQ(STEP_ROBOT_AUTH_REFRESH, enrollment_step_); | 392 CHECK_EQ(STEP_ROBOT_AUTH_REFRESH, enrollment_step_); |
393 | 393 |
394 robot_refresh_token_ = refresh_token; | 394 robot_refresh_token_ = refresh_token; |
395 | 395 |
396 SetStep(STEP_SET_FWMP_DATA); | |
397 SetFwmpData(); | |
398 } | |
399 | |
400 void EnrollmentHandlerChromeOS::SetFwmpData() { | |
401 DCHECK_EQ(STEP_SET_FWMP_DATA, enrollment_step_); | |
Daniel Erat
2017/03/06 21:18:25
nit: i think the order used for DCHECK_EQ is typic
igorcov
2017/03/09 12:22:57
This would make my code inconsistent with the rest
Daniel Erat
2017/03/09 14:52:37
because they come from completely different places
| |
402 | |
403 install_attributes_->SetBlockDevmodeInTpm( | |
404 GetBlockDevmode(), base::Bind(&EnrollmentHandlerChromeOS::OnFwmpDataSet, | |
405 weak_ptr_factory_.GetWeakPtr())); | |
406 } | |
407 | |
408 void EnrollmentHandlerChromeOS::OnFwmpDataSet( | |
409 chromeos::DBusMethodCallStatus call_status, | |
410 bool result, | |
411 const cryptohome::BaseReply& reply) { | |
412 DCHECK_EQ(STEP_SET_FWMP_DATA, enrollment_step_); | |
Daniel Erat
2017/03/06 21:18:26
nit: same here
| |
413 if (!result) { | |
414 LOG(ERROR) << "Failed to update firmware management parameters in TPM"; | |
415 } | |
416 | |
417 // get devmode and set the data. | |
Daniel Erat
2017/03/06 21:18:25
nit: s/get/Get/
igorcov
2017/03/09 12:22:57
Done.
| |
396 SetStep(STEP_AD_DOMAIN_JOIN); | 418 SetStep(STEP_AD_DOMAIN_JOIN); |
397 StartJoinAdDomain(); | 419 StartJoinAdDomain(); |
398 } | 420 } |
399 | 421 |
422 bool EnrollmentHandlerChromeOS::GetBlockDevmode() { | |
423 bool block_devmode = false; | |
424 std::unique_ptr<em::PolicyData> policy_data(new em::PolicyData()); | |
Daniel Erat
2017/03/06 21:18:25
nit: use auto and MakeUnique
igorcov
2017/03/09 12:22:57
Done.
| |
425 policy_data->ParseFromString(policy_->policy_data()); | |
Daniel Erat
2017/03/06 21:18:26
shouldn't you be checking the return value here to
igorcov
2017/03/09 12:22:57
Done.
| |
426 | |
427 std::unique_ptr<em::ChromeDeviceSettingsProto> payload( | |
428 new em::ChromeDeviceSettingsProto()); | |
429 payload->ParseFromString(policy_data->policy_value()); | |
430 if (payload->has_system_settings()) { | |
431 const em::SystemSettingsProto& container(payload->system_settings()); | |
432 if (container.has_block_devmode()) { | |
433 block_devmode = container.block_devmode(); | |
434 } | |
435 } | |
436 | |
437 return block_devmode; | |
438 } | |
439 | |
400 // GaiaOAuthClient::Delegate | 440 // GaiaOAuthClient::Delegate |
401 void EnrollmentHandlerChromeOS::OnRefreshTokenResponse( | 441 void EnrollmentHandlerChromeOS::OnRefreshTokenResponse( |
402 const std::string& access_token, | 442 const std::string& access_token, |
403 int expires_in_seconds) { | 443 int expires_in_seconds) { |
404 // We never use the code that should trigger this callback. | 444 // We never use the code that should trigger this callback. |
405 LOG(FATAL) << "Unexpected callback invoked."; | 445 LOG(FATAL) << "Unexpected callback invoked."; |
406 } | 446 } |
407 | 447 |
408 // GaiaOAuthClient::Delegate OAuth2 error when fetching refresh token request. | 448 // GaiaOAuthClient::Delegate OAuth2 error when fetching refresh token request. |
409 void EnrollmentHandlerChromeOS::OnOAuthError() { | 449 void EnrollmentHandlerChromeOS::OnOAuthError() { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 callback.Run(status); | 639 callback.Run(status); |
600 } | 640 } |
601 | 641 |
602 void EnrollmentHandlerChromeOS::SetStep(EnrollmentStep step) { | 642 void EnrollmentHandlerChromeOS::SetStep(EnrollmentStep step) { |
603 DCHECK_LE(enrollment_step_, step); | 643 DCHECK_LE(enrollment_step_, step); |
604 VLOG(1) << "Step: " << step; | 644 VLOG(1) << "Step: " << step; |
605 enrollment_step_ = step; | 645 enrollment_step_ = step; |
606 } | 646 } |
607 | 647 |
608 } // namespace policy | 648 } // namespace policy |
OLD | NEW |