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

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: . Created 3 years, 7 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 HostPairingController::ENROLLMENT_STATUS_ENROLLING); 153 HostPairingController::ENROLLMENT_STATUS_ENROLLING);
153 } 154 }
154 155
155 void HostPairingScreen::OnViewDestroyed(HostPairingScreenView* view) { 156 void HostPairingScreen::OnViewDestroyed(HostPairingScreenView* view) {
156 if (view_ == view) 157 if (view_ == view)
157 view_ = NULL; 158 view_ = NULL;
158 } 159 }
159 160
160 void HostPairingScreen::OnAuthError(const GoogleServiceAuthError& error) { 161 void HostPairingScreen::OnAuthError(const GoogleServiceAuthError& error) {
161 enrollment_error_string_ = view_->GetErrorStringFromAuthError(error); 162 enrollment_error_string_ = view_->GetErrorStringFromAuthError(error);
163 enrollment_error_code_ =
164 std::stoi(std::to_string(HostPairingController::AUTH_ERROR) +
achuithb 2017/05/25 19:25:53 What's going on here?
achuithb 2017/05/25 19:27:34 I think I understand. Can't we multiply the prefi
xdai1 2017/06/08 22:18:40 Added comments in the definition in the header fil
165 std::to_string(error.state()));
162 OnAnyEnrollmentError(); 166 OnAnyEnrollmentError();
163 } 167 }
164 168
165 void HostPairingScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 169 void HostPairingScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
166 enrollment_error_string_ = view_->GetErrorStringFromEnrollmentError(status); 170 enrollment_error_string_ = view_->GetErrorStringFromEnrollmentError(status);
171 enrollment_error_code_ =
172 std::stoi(std::to_string(HostPairingController::ENROLL_ERROR) +
173 std::to_string(status.status()));
167 OnAnyEnrollmentError(); 174 OnAnyEnrollmentError();
168 } 175 }
169 176
170 void HostPairingScreen::OnOtherError( 177 void HostPairingScreen::OnOtherError(
171 EnterpriseEnrollmentHelper::OtherError error) { 178 EnterpriseEnrollmentHelper::OtherError error) {
172 enrollment_error_string_ = view_->GetErrorStringFromOtherError(error); 179 enrollment_error_string_ = view_->GetErrorStringFromOtherError(error);
180 enrollment_error_code_ =
181 std::stoi(std::to_string(HostPairingController::OTHER_ERROR) +
182 std::to_string(error));
173 OnAnyEnrollmentError(); 183 OnAnyEnrollmentError();
174 } 184 }
175 185
176 void HostPairingScreen::OnDeviceEnrolled(const std::string& additional_token) { 186 void HostPairingScreen::OnDeviceEnrolled(const std::string& additional_token) {
177 StartupUtils::MarkDeviceRegistered(base::Bind(&base::DoNothing)); 187 StartupUtils::MarkDeviceRegistered(base::Bind(&base::DoNothing));
178 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared, 188 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared,
179 weak_ptr_factory_.GetWeakPtr())); 189 weak_ptr_factory_.GetWeakPtr()));
180 190
181 policy::BrowserPolicyConnectorChromeOS* connector = 191 policy::BrowserPolicyConnectorChromeOS* connector =
182 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 192 g_browser_process->platform_part()->browser_policy_connector_chromeos();
183 const enterprise_management::PolicyData* policy = 193 const enterprise_management::PolicyData* policy =
184 connector->GetDeviceCloudPolicyManager()->core()->store()->policy(); 194 connector->GetDeviceCloudPolicyManager()->core()->store()->policy();
185 195
186 remora_controller_->SetPermanentId(policy->directory_api_id()); 196 remora_controller_->SetPermanentId(policy->directory_api_id());
187 remora_controller_->OnEnrollmentStatusChanged( 197 remora_controller_->OnEnrollmentStatusChanged(
188 HostPairingController::ENROLLMENT_STATUS_SUCCESS); 198 HostPairingController::ENROLLMENT_STATUS_SUCCESS);
189 } 199 }
190 200
191 void HostPairingScreen::OnDeviceAttributeUploadCompleted(bool success) {} 201 void HostPairingScreen::OnDeviceAttributeUploadCompleted(bool success) {}
192 202
193 void HostPairingScreen::OnDeviceAttributeUpdatePermission(bool granted) {} 203 void HostPairingScreen::OnDeviceAttributeUpdatePermission(bool granted) {}
194 204
195 void HostPairingScreen::OnAuthCleared() { 205 void HostPairingScreen::OnAuthCleared() {
196 enrollment_helper_.reset(); 206 enrollment_helper_.reset();
197 } 207 }
198 208
199 void HostPairingScreen::OnAnyEnrollmentError() { 209 void HostPairingScreen::OnAnyEnrollmentError() {
200 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared, 210 enrollment_helper_->ClearAuth(base::Bind(&HostPairingScreen::OnAuthCleared,
201 weak_ptr_factory_.GetWeakPtr())); 211 weak_ptr_factory_.GetWeakPtr()));
212 remora_controller_->SetErrorCodeAndMessage(enrollment_error_code_,
213 enrollment_error_string_);
202 remora_controller_->OnEnrollmentStatusChanged( 214 remora_controller_->OnEnrollmentStatusChanged(
203 HostPairingController::ENROLLMENT_STATUS_FAILURE); 215 HostPairingController::ENROLLMENT_STATUS_FAILURE);
204 } 216 }
205 217
206 } // namespace chromeos 218 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698