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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc

Issue 2771623002: Bootstrapping: Display meaningful enrollment error message on Slave device. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/webui/chromeos/login/host_pairing_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/browser/chromeos/login/oobe_screen.h" 9 #include "chrome/browser/chromeos/login/oobe_screen.h"
10 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
10 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
11 #include "chromeos/chromeos_switches.h" 12 #include "chromeos/chromeos_switches.h"
12 #include "components/login/localized_values_builder.h" 13 #include "components/login/localized_values_builder.h"
14 #include "components/policy/core/browser/cloud/message_util.h"
15 #include "google_apis/gaia/google_service_auth_error.h"
16 #include "ui/base/l10n/l10n_util.h"
13 17
14 namespace chromeos { 18 namespace chromeos {
15 19
16 namespace { 20 namespace {
17 21
18 const char kJsScreenPath[] = "login.HostPairingScreen"; 22 const char kJsScreenPath[] = "login.HostPairingScreen";
19 23
20 const char kMethodContextChanged[] = "contextChanged"; 24 const char kMethodContextChanged[] = "contextChanged";
21 25
22 // Sent from JS when screen is ready to receive context updates. 26 // Sent from JS when screen is ready to receive context updates.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 114
111 void HostPairingScreenHandler::OnContextChanged( 115 void HostPairingScreenHandler::OnContextChanged(
112 const base::DictionaryValue& diff) { 116 const base::DictionaryValue& diff) {
113 if (!js_context_ready_) { 117 if (!js_context_ready_) {
114 context_cache_.ApplyChanges(diff, NULL); 118 context_cache_.ApplyChanges(diff, NULL);
115 return; 119 return;
116 } 120 }
117 CallJS(kMethodContextChanged, diff); 121 CallJS(kMethodContextChanged, diff);
118 } 122 }
119 123
124 std::string HostPairingScreenHandler::GetErrorStringFromAuthError(
125 const GoogleServiceAuthError& error) {
126 switch (error.state()) {
127 case GoogleServiceAuthError::NONE:
128 case GoogleServiceAuthError::CAPTCHA_REQUIRED:
129 case GoogleServiceAuthError::TWO_FACTOR:
130 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
131 case GoogleServiceAuthError::REQUEST_CANCELED:
132 case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE:
133 case GoogleServiceAuthError::SERVICE_ERROR:
134 case GoogleServiceAuthError::WEB_LOGIN_REQUIRED:
135 return l10n_util::GetStringUTF8(
136 IDS_ENTERPRISE_ENROLLMENT_AUTH_FATAL_ERROR);
137 case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
138 case GoogleServiceAuthError::ACCOUNT_DELETED:
139 case GoogleServiceAuthError::ACCOUNT_DISABLED:
140 return l10n_util::GetStringUTF8(
141 IDS_ENTERPRISE_ENROLLMENT_AUTH_ACCOUNT_ERROR);
142 case GoogleServiceAuthError::CONNECTION_FAILED:
143 case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
144 return l10n_util::GetStringUTF8(
145 IDS_ENTERPRISE_ENROLLMENT_AUTH_NETWORK_ERROR);
146 default:
147 return std::string();
148 }
149 }
150
151 std::string HostPairingScreenHandler::GetErrorStringFromEnrollmentError(
152 policy::EnrollmentStatus status) {
153 switch (status.status()) {
154 case policy::EnrollmentStatus::NO_STATE_KEYS:
155 return l10n_util::GetStringUTF8(
156 IDS_ENTERPRISE_ENROLLMENT_STATUS_NO_STATE_KEYS);
157 case policy::EnrollmentStatus::REGISTRATION_FAILED:
158 switch (status.client_status()) {
159 case policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED:
160 return l10n_util::GetStringUTF8(
161 IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR);
162 case policy::DM_STATUS_SERVICE_MISSING_LICENSES:
163 return l10n_util::GetStringUTF8(
164 IDS_ENTERPRISE_ENROLLMENT_MISSING_LICENSES_ERROR);
165 case policy::DM_STATUS_SERVICE_DEPROVISIONED:
166 return l10n_util::GetStringUTF8(
167 IDS_ENTERPRISE_ENROLLMENT_DEPROVISIONED_ERROR);
168 case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH:
169 return l10n_util::GetStringUTF8(
170 IDS_ENTERPRISE_ENROLLMENT_DOMAIN_MISMATCH_ERROR);
171 default:
172 return l10n_util::GetStringFUTF8(
173 IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_FAILED,
174 policy::FormatDeviceManagementStatus(status.client_status()));
175 }
176 case policy::EnrollmentStatus::ROBOT_AUTH_FETCH_FAILED:
177 return l10n_util::GetStringUTF8(
178 IDS_ENTERPRISE_ENROLLMENT_ROBOT_AUTH_FETCH_FAILED);
179 case policy::EnrollmentStatus::ROBOT_REFRESH_FETCH_FAILED:
180 return l10n_util::GetStringUTF8(
181 IDS_ENTERPRISE_ENROLLMENT_ROBOT_REFRESH_FETCH_FAILED);
182 case policy::EnrollmentStatus::ROBOT_REFRESH_STORE_FAILED:
183 return l10n_util::GetStringUTF8(
184 IDS_ENTERPRISE_ENROLLMENT_ROBOT_REFRESH_STORE_FAILED);
185 case policy::EnrollmentStatus::REGISTRATION_BAD_MODE:
186 return l10n_util::GetStringUTF8(
187 IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_BAD_MODE);
188 case policy::EnrollmentStatus::REGISTRATION_CERT_FETCH_FAILED:
189 return l10n_util::GetStringUTF8(
190 IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_CERT_FETCH_FAILED);
191 case policy::EnrollmentStatus::POLICY_FETCH_FAILED:
192 return l10n_util::GetStringFUTF8(
193 IDS_ENTERPRISE_ENROLLMENT_STATUS_POLICY_FETCH_FAILED,
194 policy::FormatDeviceManagementStatus(status.client_status()));
195 case policy::EnrollmentStatus::VALIDATION_FAILED:
196 return l10n_util::GetStringFUTF8(
197 IDS_ENTERPRISE_ENROLLMENT_STATUS_VALIDATION_FAILED,
198 policy::FormatValidationStatus(status.validation_status()));
199 case policy::EnrollmentStatus::LOCK_ERROR:
200 switch (status.lock_status()) {
201 case InstallAttributes::LOCK_TIMEOUT:
202 return l10n_util::GetStringUTF8(
203 IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_TIMEOUT);
204 case InstallAttributes::LOCK_BACKEND_INVALID:
205 case InstallAttributes::LOCK_ALREADY_LOCKED:
206 case InstallAttributes::LOCK_SET_ERROR:
207 case InstallAttributes::LOCK_FINALIZE_ERROR:
208 case InstallAttributes::LOCK_READBACK_ERROR:
209 return l10n_util::GetStringUTF8(
210 IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_ERROR);
211 case InstallAttributes::LOCK_WRONG_DOMAIN:
212 return l10n_util::GetStringUTF8(
213 IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_USER);
214 case InstallAttributes::LOCK_WRONG_MODE:
215 return l10n_util::GetStringUTF8(
216 IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_MODE);
217 default:
218 return std::string();
219 }
220 case policy::EnrollmentStatus::STORE_ERROR:
221 return l10n_util::GetStringFUTF8(
222 IDS_ENTERPRISE_ENROLLMENT_STATUS_STORE_ERROR,
223 policy::FormatStoreStatus(status.store_status(),
224 status.validation_status()));
225 case policy::EnrollmentStatus::ATTRIBUTE_UPDATE_FAILED:
226 return l10n_util::GetStringUTF8(
227 IDS_ENTERPRISE_ENROLLMENT_ATTRIBUTE_ERROR);
228 case policy::EnrollmentStatus::NO_MACHINE_IDENTIFICATION:
229 return l10n_util::GetStringUTF8(
230 IDS_ENTERPRISE_ENROLLMENT_STATUS_NO_MACHINE_IDENTIFICATION);
231 case policy::EnrollmentStatus::ACTIVE_DIRECTORY_POLICY_FETCH_FAILED:
232 return l10n_util::GetStringUTF8(
233 IDS_ENTERPRISE_ENROLLMENT_ERROR_ACTIVE_DIRECTORY_POLICY_FETCH);
234 case policy::EnrollmentStatus::DM_TOKEN_STORE_FAILED:
235 return l10n_util::GetStringUTF8(
236 IDS_ENTERPRISE_ENROLLMENT_ERROR_SAVE_DEVICE_CONFIGURATION);
237 default:
238 return std::string();
239 }
240 }
241
242 std::string HostPairingScreenHandler::GetErrorStringFromOtherError(
243 EnterpriseEnrollmentHelper::OtherError error) {
244 switch (error) {
245 case EnterpriseEnrollmentHelper::OTHER_ERROR_DOMAIN_MISMATCH:
246 return l10n_util::GetStringUTF8(
247 IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_USER);
248 case EnterpriseEnrollmentHelper::OTHER_ERROR_FATAL:
249 return l10n_util::GetStringUTF8(
250 IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR);
251 default:
252 return std::string();
253 }
254 }
255
120 } // namespace chromeos 256 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698