Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: chrome/browser/chromeos/login/screens/host_pairing_screen.cc

Issue 2890383003: Bootstrapping: Send meaningful error code/message from Slave to Master (Closed)
Patch Set: Address achuith@'s comments. Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/screens/host_pairing_screen.h" 5 #include "chrome/browser/chromeos/login/screens/host_pairing_screen.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/login/startup_utils.h" 9 #include "chrome/browser/chromeos/login/startup_utils.h"
10 #include "chrome/browser/chromeos/login/wizard_controller.h" 10 #include "chrome/browser/chromeos/login/wizard_controller.h"
11 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 11 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
12 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" 12 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
13 #include "components/pairing/host_pairing_controller.h" 13 #include "components/pairing/host_pairing_controller.h"
14 #include "google_apis/gaia/google_service_auth_error.h"
14 15
15 namespace chromeos { 16 namespace chromeos {
16 17
18 namespace {
19
20 // 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.
21 // |main_error_code| and |sub_error_code| strings together. The reason that
22 // 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.
23 // sub error states is not necessarily a one-digit number and may have arbitrary
24 // digits.
25 int GetEnrollmentErrorCode(
26 pairing_chromeos::HostPairingController::ErrorCode main_error_code,
27 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!
28 return std::stoi(std::to_string(static_cast<int>(main_error_code)) +
29 sub_error_code);
30 }
31
32 } // namespace
33
17 using namespace host_pairing; 34 using namespace host_pairing;
18 using namespace pairing_chromeos; 35 using namespace pairing_chromeos;
19 36
20 HostPairingScreen::HostPairingScreen( 37 HostPairingScreen::HostPairingScreen(
21 BaseScreenDelegate* base_screen_delegate, 38 BaseScreenDelegate* base_screen_delegate,
22 Delegate* delegate, 39 Delegate* delegate,
23 HostPairingScreenView* view, 40 HostPairingScreenView* view,
24 pairing_chromeos::HostPairingController* remora_controller) 41 pairing_chromeos::HostPairingController* remora_controller)
25 : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_HOST_PAIRING), 42 : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_HOST_PAIRING),
26 delegate_(delegate), 43 delegate_(delegate),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 delegate_->RebootHostRequested(); 174 delegate_->RebootHostRequested();
158 } 175 }
159 176
160 void HostPairingScreen::OnViewDestroyed(HostPairingScreenView* view) { 177 void HostPairingScreen::OnViewDestroyed(HostPairingScreenView* view) {
161 if (view_ == view) 178 if (view_ == view)
162 view_ = NULL; 179 view_ = NULL;
163 } 180 }
164 181
165 void HostPairingScreen::OnAuthError(const GoogleServiceAuthError& error) { 182 void HostPairingScreen::OnAuthError(const GoogleServiceAuthError& error) {
166 enrollment_error_string_ = view_->GetErrorStringFromAuthError(error); 183 enrollment_error_string_ = view_->GetErrorStringFromAuthError(error);
184 enrollment_error_code_ =
185 GetEnrollmentErrorCode(HostPairingController::ErrorCode::AUTH_ERROR,
186 std::to_string(error.state()));
167 OnAnyEnrollmentError(); 187 OnAnyEnrollmentError();
168 } 188 }
169 189
170 void HostPairingScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 190 void HostPairingScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
171 enrollment_error_string_ = view_->GetErrorStringFromEnrollmentError(status); 191 enrollment_error_string_ = view_->GetErrorStringFromEnrollmentError(status);
192 enrollment_error_code_ =
193 GetEnrollmentErrorCode(HostPairingController::ErrorCode::ENROLL_ERROR,
194 std::to_string(status.status()));
172 OnAnyEnrollmentError(); 195 OnAnyEnrollmentError();
173 } 196 }
174 197
175 void HostPairingScreen::OnOtherError( 198 void HostPairingScreen::OnOtherError(
176 EnterpriseEnrollmentHelper::OtherError error) { 199 EnterpriseEnrollmentHelper::OtherError error) {
177 enrollment_error_string_ = view_->GetErrorStringFromOtherError(error); 200 enrollment_error_string_ = view_->GetErrorStringFromOtherError(error);
201 enrollment_error_code_ = GetEnrollmentErrorCode(
202 HostPairingController::ErrorCode::OTHER_ERROR, std::to_string(error));
178 OnAnyEnrollmentError(); 203 OnAnyEnrollmentError();
179 } 204 }
180 205
181 void HostPairingScreen::OnDeviceEnrolled(const std::string& additional_token) { 206 void HostPairingScreen::OnDeviceEnrolled(const std::string& additional_token) {
182 StartupUtils::MarkDeviceRegistered(base::Bind(&base::DoNothing)); 207 StartupUtils::MarkDeviceRegistered(base::Bind(&base::DoNothing));
183 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared, 208 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared,
184 weak_ptr_factory_.GetWeakPtr())); 209 weak_ptr_factory_.GetWeakPtr()));
185 210
186 policy::BrowserPolicyConnectorChromeOS* connector = 211 policy::BrowserPolicyConnectorChromeOS* connector =
187 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 212 g_browser_process->platform_part()->browser_policy_connector_chromeos();
188 const enterprise_management::PolicyData* policy = 213 const enterprise_management::PolicyData* policy =
189 connector->GetDeviceCloudPolicyManager()->core()->store()->policy(); 214 connector->GetDeviceCloudPolicyManager()->core()->store()->policy();
190 215
191 remora_controller_->SetPermanentId(policy->directory_api_id()); 216 remora_controller_->SetPermanentId(policy->directory_api_id());
192 remora_controller_->OnEnrollmentStatusChanged( 217 remora_controller_->OnEnrollmentStatusChanged(
193 HostPairingController::ENROLLMENT_STATUS_SUCCESS); 218 HostPairingController::ENROLLMENT_STATUS_SUCCESS);
194 } 219 }
195 220
196 void HostPairingScreen::OnDeviceAttributeUploadCompleted(bool success) {} 221 void HostPairingScreen::OnDeviceAttributeUploadCompleted(bool success) {}
197 222
198 void HostPairingScreen::OnDeviceAttributeUpdatePermission(bool granted) {} 223 void HostPairingScreen::OnDeviceAttributeUpdatePermission(bool granted) {}
199 224
200 void HostPairingScreen::OnAuthCleared() { 225 void HostPairingScreen::OnAuthCleared() {
201 enrollment_helper_.reset(); 226 enrollment_helper_.reset();
202 } 227 }
203 228
204 void HostPairingScreen::OnAnyEnrollmentError() { 229 void HostPairingScreen::OnAnyEnrollmentError() {
205 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared, 230 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared,
206 weak_ptr_factory_.GetWeakPtr())); 231 weak_ptr_factory_.GetWeakPtr()));
232 remora_controller_->SetErrorCodeAndMessage(enrollment_error_code_,
233 enrollment_error_string_);
207 remora_controller_->OnEnrollmentStatusChanged( 234 remora_controller_->OnEnrollmentStatusChanged(
208 HostPairingController::ENROLLMENT_STATUS_FAILURE); 235 HostPairingController::ENROLLMENT_STATUS_FAILURE);
209 } 236 }
210 237
211 } // namespace chromeos 238 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screens/host_pairing_screen.h ('k') | chrome/browser/chromeos/login/screens/network_screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698