Chromium Code Reviews| Index: chrome/browser/chromeos/login/screens/host_pairing_screen.cc |
| diff --git a/chrome/browser/chromeos/login/screens/host_pairing_screen.cc b/chrome/browser/chromeos/login/screens/host_pairing_screen.cc |
| index 64b431cb67a3ffce1f09aff849ea50322e469ae2..79a8cdd79f8181a091d2d65426b4b8403de9f7fb 100644 |
| --- a/chrome/browser/chromeos/login/screens/host_pairing_screen.cc |
| +++ b/chrome/browser/chromeos/login/screens/host_pairing_screen.cc |
| @@ -11,9 +11,26 @@ |
| #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| #include "components/pairing/host_pairing_controller.h" |
| +#include "google_apis/gaia/google_service_auth_error.h" |
| namespace chromeos { |
| +namespace { |
| + |
| +// Gets the fine-grained enrollment error code. It's calculated by concatenated |
|
achuithb
2017/06/19 22:57:27
concatenating
xdai1
2017/06/19 23:45:10
Done.
|
| +// |main_error_code| and |sub_error_code| strings together. The reason that |
| +// string concatenation is preferred to arithmetic addition is the number of the |
|
achuithb
2017/06/19 22:57:27
is that the number of sub error
xdai1
2017/06/19 23:45:10
Done.
|
| +// sub error states is not necessarily a one-digit number and may have arbitrary |
| +// digits. |
| +int GetEnrollmentErrorCode( |
| + pairing_chromeos::HostPairingController::ErrorCode main_error_code, |
| + std::string sub_error_code) { |
|
achuithb
2017/06/19 22:57:27
This should be const std::string&
And we cannot u
xdai1
2017/06/19 23:45:10
Yes, you're right. int is better here. Thanks!
|
| + return std::stoi(std::to_string(static_cast<int>(main_error_code)) + |
| + sub_error_code); |
| +} |
| + |
| +} // namespace |
| + |
| using namespace host_pairing; |
| using namespace pairing_chromeos; |
| @@ -164,17 +181,25 @@ void HostPairingScreen::OnViewDestroyed(HostPairingScreenView* view) { |
| void HostPairingScreen::OnAuthError(const GoogleServiceAuthError& error) { |
| enrollment_error_string_ = view_->GetErrorStringFromAuthError(error); |
| + enrollment_error_code_ = |
| + GetEnrollmentErrorCode(HostPairingController::ErrorCode::AUTH_ERROR, |
| + std::to_string(error.state())); |
| OnAnyEnrollmentError(); |
| } |
| void HostPairingScreen::OnEnrollmentError(policy::EnrollmentStatus status) { |
| enrollment_error_string_ = view_->GetErrorStringFromEnrollmentError(status); |
| + enrollment_error_code_ = |
| + GetEnrollmentErrorCode(HostPairingController::ErrorCode::ENROLL_ERROR, |
| + std::to_string(status.status())); |
| OnAnyEnrollmentError(); |
| } |
| void HostPairingScreen::OnOtherError( |
| EnterpriseEnrollmentHelper::OtherError error) { |
| enrollment_error_string_ = view_->GetErrorStringFromOtherError(error); |
| + enrollment_error_code_ = GetEnrollmentErrorCode( |
| + HostPairingController::ErrorCode::OTHER_ERROR, std::to_string(error)); |
| OnAnyEnrollmentError(); |
| } |
| @@ -204,6 +229,8 @@ void HostPairingScreen::OnAuthCleared() { |
| void HostPairingScreen::OnAnyEnrollmentError() { |
| enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared, |
| weak_ptr_factory_.GetWeakPtr())); |
| + remora_controller_->SetErrorCodeAndMessage(enrollment_error_code_, |
| + enrollment_error_string_); |
| remora_controller_->OnEnrollmentStatusChanged( |
| HostPairingController::ENROLLMENT_STATUS_FAILURE); |
| } |