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

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: Rebase. Address achuith@'s comments. 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
17 using namespace host_pairing; 18 using namespace host_pairing;
18 using namespace pairing_chromeos; 19 using namespace pairing_chromeos;
19 20
20 HostPairingScreen::HostPairingScreen( 21 HostPairingScreen::HostPairingScreen(
21 BaseScreenDelegate* base_screen_delegate, 22 BaseScreenDelegate* base_screen_delegate,
22 Delegate* delegate, 23 Delegate* delegate,
23 HostPairingScreenView* view, 24 HostPairingScreenView* view,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 delegate_->RebootHostRequested(); 158 delegate_->RebootHostRequested();
158 } 159 }
159 160
160 void HostPairingScreen::OnViewDestroyed(HostPairingScreenView* view) { 161 void HostPairingScreen::OnViewDestroyed(HostPairingScreenView* view) {
161 if (view_ == view) 162 if (view_ == view)
162 view_ = NULL; 163 view_ = NULL;
163 } 164 }
164 165
165 void HostPairingScreen::OnAuthError(const GoogleServiceAuthError& error) { 166 void HostPairingScreen::OnAuthError(const GoogleServiceAuthError& error) {
166 enrollment_error_string_ = view_->GetErrorStringFromAuthError(error); 167 enrollment_error_string_ = view_->GetErrorStringFromAuthError(error);
168 enrollment_error_code_ =
169 std::stoi(std::to_string(static_cast<int>(
achuithb 2017/06/17 00:11:59 As per offline discussion, pull this out into a ut
xdai1 2017/06/19 18:14:59 Done.
170 HostPairingController::ErrorCode::AUTH_ERROR)) +
171 std::to_string(error.state()));
167 OnAnyEnrollmentError(); 172 OnAnyEnrollmentError();
168 } 173 }
169 174
170 void HostPairingScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 175 void HostPairingScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
171 enrollment_error_string_ = view_->GetErrorStringFromEnrollmentError(status); 176 enrollment_error_string_ = view_->GetErrorStringFromEnrollmentError(status);
177 enrollment_error_code_ =
178 std::stoi(std::to_string(static_cast<int>(
179 HostPairingController::ErrorCode::ENROLL_ERROR)) +
180 std::to_string(status.status()));
172 OnAnyEnrollmentError(); 181 OnAnyEnrollmentError();
173 } 182 }
174 183
175 void HostPairingScreen::OnOtherError( 184 void HostPairingScreen::OnOtherError(
176 EnterpriseEnrollmentHelper::OtherError error) { 185 EnterpriseEnrollmentHelper::OtherError error) {
177 enrollment_error_string_ = view_->GetErrorStringFromOtherError(error); 186 enrollment_error_string_ = view_->GetErrorStringFromOtherError(error);
187 enrollment_error_code_ =
188 std::stoi(std::to_string(static_cast<int>(
189 HostPairingController::ErrorCode::OTHER_ERROR)) +
190 std::to_string(error));
178 OnAnyEnrollmentError(); 191 OnAnyEnrollmentError();
179 } 192 }
180 193
181 void HostPairingScreen::OnDeviceEnrolled(const std::string& additional_token) { 194 void HostPairingScreen::OnDeviceEnrolled(const std::string& additional_token) {
182 StartupUtils::MarkDeviceRegistered(base::Bind(&base::DoNothing)); 195 StartupUtils::MarkDeviceRegistered(base::Bind(&base::DoNothing));
183 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared, 196 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared,
184 weak_ptr_factory_.GetWeakPtr())); 197 weak_ptr_factory_.GetWeakPtr()));
185 198
186 policy::BrowserPolicyConnectorChromeOS* connector = 199 policy::BrowserPolicyConnectorChromeOS* connector =
187 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 200 g_browser_process->platform_part()->browser_policy_connector_chromeos();
188 const enterprise_management::PolicyData* policy = 201 const enterprise_management::PolicyData* policy =
189 connector->GetDeviceCloudPolicyManager()->core()->store()->policy(); 202 connector->GetDeviceCloudPolicyManager()->core()->store()->policy();
190 203
191 remora_controller_->SetPermanentId(policy->directory_api_id()); 204 remora_controller_->SetPermanentId(policy->directory_api_id());
192 remora_controller_->OnEnrollmentStatusChanged( 205 remora_controller_->OnEnrollmentStatusChanged(
193 HostPairingController::ENROLLMENT_STATUS_SUCCESS); 206 HostPairingController::ENROLLMENT_STATUS_SUCCESS);
194 } 207 }
195 208
196 void HostPairingScreen::OnDeviceAttributeUploadCompleted(bool success) {} 209 void HostPairingScreen::OnDeviceAttributeUploadCompleted(bool success) {}
197 210
198 void HostPairingScreen::OnDeviceAttributeUpdatePermission(bool granted) {} 211 void HostPairingScreen::OnDeviceAttributeUpdatePermission(bool granted) {}
199 212
200 void HostPairingScreen::OnAuthCleared() { 213 void HostPairingScreen::OnAuthCleared() {
201 enrollment_helper_.reset(); 214 enrollment_helper_.reset();
202 } 215 }
203 216
204 void HostPairingScreen::OnAnyEnrollmentError() { 217 void HostPairingScreen::OnAnyEnrollmentError() {
205 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared, 218 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared,
206 weak_ptr_factory_.GetWeakPtr())); 219 weak_ptr_factory_.GetWeakPtr()));
220 remora_controller_->SetErrorCodeAndMessage(enrollment_error_code_,
221 enrollment_error_string_);
207 remora_controller_->OnEnrollmentStatusChanged( 222 remora_controller_->OnEnrollmentStatusChanged(
208 HostPairingController::ENROLLMENT_STATUS_FAILURE); 223 HostPairingController::ENROLLMENT_STATUS_FAILURE);
209 } 224 }
210 225
211 } // namespace chromeos 226 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698