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

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

Issue 10664017: Introduce a new error code from the DM server - 402 - missing licenses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/serials/licenses// Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/enterprise_oauth_enrollment_scr een_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_scr een_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void EnterpriseOAuthEnrollmentScreenHandler::ShowAuthError( 162 void EnterpriseOAuthEnrollmentScreenHandler::ShowAuthError(
163 const GoogleServiceAuthError& error) { 163 const GoogleServiceAuthError& error) {
164 switch (error.state()) { 164 switch (error.state()) {
165 case GoogleServiceAuthError::NONE: 165 case GoogleServiceAuthError::NONE:
166 case GoogleServiceAuthError::CAPTCHA_REQUIRED: 166 case GoogleServiceAuthError::CAPTCHA_REQUIRED:
167 case GoogleServiceAuthError::TWO_FACTOR: 167 case GoogleServiceAuthError::TWO_FACTOR:
168 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: 168 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED:
169 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: 169 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
170 case GoogleServiceAuthError::REQUEST_CANCELED: 170 case GoogleServiceAuthError::REQUEST_CANCELED:
171 LOG(ERROR) << "Auth error " << error.state(); 171 LOG(ERROR) << "Auth error " << error.state();
172 ShowFatalAuthError(); 172 ShowEnrollmentError(FATAL_AUTH_ERROR);
173 return; 173 return;
174 case GoogleServiceAuthError::USER_NOT_SIGNED_UP: 174 case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
175 case GoogleServiceAuthError::ACCOUNT_DELETED: 175 case GoogleServiceAuthError::ACCOUNT_DELETED:
176 case GoogleServiceAuthError::ACCOUNT_DISABLED: 176 case GoogleServiceAuthError::ACCOUNT_DISABLED:
177 LOG(ERROR) << "Account error " << error.state(); 177 LOG(ERROR) << "Account error " << error.state();
178 ShowAccountError(); 178 ShowEnrollmentError(ACCOUNT_ERROR);
179 return; 179 return;
180 case GoogleServiceAuthError::CONNECTION_FAILED: 180 case GoogleServiceAuthError::CONNECTION_FAILED:
181 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: 181 case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
182 LOG(WARNING) << "Network error " << error.state(); 182 LOG(WARNING) << "Network error " << error.state();
183 ShowNetworkEnrollmentError(); 183 ShowEnrollmentError(NETWORK_ERROR);
184 return; 184 return;
185 } 185 }
186 UMAFailure(policy::kMetricEnrollmentOtherFailed); 186 UMAFailure(policy::kMetricEnrollmentOtherFailed);
187 NOTREACHED(); 187 NOTREACHED();
188 } 188 }
189 189
190 void EnterpriseOAuthEnrollmentScreenHandler::ShowAccountError() { 190 void EnterpriseOAuthEnrollmentScreenHandler::ShowEnrollmentError(
191 UMAFailure(policy::kMetricEnrollmentNotSupported); 191 EnrollmentError error_code) {
192 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR, true); 192 switch (error_code) {
193 case ACCOUNT_ERROR:
194 UMAFailure(policy::kMetricEnrollmentNotSupported);
195 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR, true);
196 break;
197 case SERIAL_NUMBER_ERROR:
198 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber);
199 ShowError(IDS_ENTERPRISE_ENROLLMENT_SERIAL_NUMBER_ERROR, true);
200 break;
201 case ENROLLMENT_MODE_ERROR:
202 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode);
203 ShowError(IDS_ENTERPRISE_ENROLLMENT_MODE_ERROR, false);
204 break;
205 case FATAL_AUTH_ERROR:
206 UMAFailure(policy::kMetricEnrollmentLoginFailed);
207 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR, false);
208 break;
209 case AUTO_ENROLLMENT_ERROR: {
210 UMAFailure(policy::kMetricEnrollmentAutoEnrollmentNotSupported);
211 // The reason for showing this error is that we have been trying to
212 // auto-enroll and this failed, so we have to verify whether
213 // auto-enrollment is on, and if so switch it off, update the UI
214 // accordingly and show the error message.
215 std::string user;
216 is_auto_enrollment_ = controller_ && controller_->IsAutoEnrollment(&user);
217 base::FundamentalValue value(is_auto_enrollment_);
218 web_ui()->CallJavascriptFunction(
219 "oobe.OAuthEnrollmentScreen.setIsAutoEnrollment", value);
220
221 ShowError(IDS_ENTERPRISE_AUTO_ENROLLMENT_ERROR, false);
222 break;
223 }
224 case NETWORK_ERROR:
225 UMAFailure(policy::kMetricEnrollmentNetworkFailed);
226 ShowError(IDS_ENTERPRISE_ENROLLMENT_NETWORK_ENROLLMENT_ERROR, true);
227 break;
228 case LOCKBOX_TIMEOUT_ERROR:
229 UMAFailure(policy::kMetricLockboxTimeoutError);
230 ShowError(IDS_ENTERPRISE_LOCKBOX_TIMEOUT_ERROR, true);
231 break;
232 case DOMAIN_MISMATCH_ERROR:
233 UMAFailure(policy::kMetricEnrollmentWrongUserError);
234 ShowError(IDS_ENTERPRISE_ENROLLMENT_DOMAIN_MISMATCH_ERROR, true);
235 break;
236 case MISSING_LICENSES_ERROR:
237 UMAFailure(policy::kMetricMissingLicensesError);
238 ShowError(IDS_ENTERPRISE_ENROLLMENT_MISSING_LICENSES_ERROR, true);
239 break;
240 case FATAL_ERROR:
241 default:
242 UMAFailure(policy::kMetricEnrollmentOtherFailed);
243 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR, false);
244 }
193 NotifyObservers(false); 245 NotifyObservers(false);
194 } 246 }
195 247
196 void EnterpriseOAuthEnrollmentScreenHandler::ShowSerialNumberError() {
197 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber);
198 ShowError(IDS_ENTERPRISE_ENROLLMENT_SERIAL_NUMBER_ERROR, true);
199 NotifyObservers(false);
200 }
201
202 void EnterpriseOAuthEnrollmentScreenHandler::ShowEnrollmentModeError() {
203 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode);
204 ShowError(IDS_ENTERPRISE_ENROLLMENT_MODE_ERROR, false);
205 NotifyObservers(false);
206 }
207
208 void EnterpriseOAuthEnrollmentScreenHandler::ShowFatalAuthError() {
209 UMAFailure(policy::kMetricEnrollmentLoginFailed);
210 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR, false);
211 NotifyObservers(false);
212 }
213
214 void EnterpriseOAuthEnrollmentScreenHandler::ShowFatalEnrollmentError() {
215 UMAFailure(policy::kMetricEnrollmentOtherFailed);
216 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR, false);
217 NotifyObservers(false);
218 }
219
220 void EnterpriseOAuthEnrollmentScreenHandler::ShowAutoEnrollmentError() {
221 UMAFailure(policy::kMetricEnrollmentAutoEnrollmentNotSupported);
222 // The reason for showing this error is that we have been trying to
223 // auto-enroll and this failed, so we have to verify whether auto-enrollment
224 // is on, and if so switch it off, update the UI accordingly and show the
225 // error message.
226 std::string user;
227 is_auto_enrollment_ = controller_ && controller_->IsAutoEnrollment(&user);
228 base::FundamentalValue value(is_auto_enrollment_);
229 web_ui()->CallJavascriptFunction(
230 "oobe.OAuthEnrollmentScreen.setIsAutoEnrollment", value);
231
232 ShowError(IDS_ENTERPRISE_AUTO_ENROLLMENT_ERROR, false);
233 NotifyObservers(false);
234 }
235
236 void EnterpriseOAuthEnrollmentScreenHandler::ShowNetworkEnrollmentError() {
237 UMAFailure(policy::kMetricEnrollmentNetworkFailed);
238 ShowError(IDS_ENTERPRISE_ENROLLMENT_NETWORK_ENROLLMENT_ERROR, true);
239 NotifyObservers(false);
240 }
241
242 void EnterpriseOAuthEnrollmentScreenHandler::ShowLockboxTimeoutError() {
243 UMAFailure(policy::kMetricLockboxTimeoutError);
244 ShowError(IDS_ENTERPRISE_LOCKBOX_TIMEOUT_ERROR, true);
245 NotifyObservers(false);
246 }
247
248 void EnterpriseOAuthEnrollmentScreenHandler::ShowDomainMismatchError() {
249 UMAFailure(policy::kMetricEnrollmentWrongUserError);
250 ShowError(IDS_ENTERPRISE_ENROLLMENT_DOMAIN_MISMATCH_ERROR, true);
251 NotifyObservers(false);
252 }
253
254 void EnterpriseOAuthEnrollmentScreenHandler::SubmitTestCredentials( 248 void EnterpriseOAuthEnrollmentScreenHandler::SubmitTestCredentials(
255 const std::string& email, 249 const std::string& email,
256 const std::string& password) { 250 const std::string& password) {
257 test_email_ = email; 251 test_email_ = email;
258 test_password_ = password; 252 test_password_ = password;
259 DoShow(); 253 DoShow();
260 } 254 }
261 255
262 // EnterpriseOAuthEnrollmentScreenHandler BaseScreenHandler implementation ----- 256 // EnterpriseOAuthEnrollmentScreenHandler BaseScreenHandler implementation -----
263 257
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 localized_strings->SetString( 297 localized_strings->SetString(
304 "oauthEnrollCancelAutoEnrollmentConfirm", 298 "oauthEnrollCancelAutoEnrollmentConfirm",
305 l10n_util::GetStringUTF16(IDS_ENTERPRISE_ENROLLMENT_CANCEL_AUTO_CONFIRM)); 299 l10n_util::GetStringUTF16(IDS_ENTERPRISE_ENROLLMENT_CANCEL_AUTO_CONFIRM));
306 localized_strings->SetString( 300 localized_strings->SetString(
307 "oauthEnrollCancelAutoEnrollmentGoBack", 301 "oauthEnrollCancelAutoEnrollmentGoBack",
308 l10n_util::GetStringUTF16(IDS_ENTERPRISE_ENROLLMENT_CANCEL_AUTO_GO_BACK)); 302 l10n_util::GetStringUTF16(IDS_ENTERPRISE_ENROLLMENT_CANCEL_AUTO_GO_BACK));
309 } 303 }
310 304
311 void EnterpriseOAuthEnrollmentScreenHandler::OnGetOAuthTokenFailure( 305 void EnterpriseOAuthEnrollmentScreenHandler::OnGetOAuthTokenFailure(
312 const GoogleServiceAuthError& error) { 306 const GoogleServiceAuthError& error) {
313 ShowFatalAuthError(); 307 ShowEnrollmentError(FATAL_AUTH_ERROR);
314 } 308 }
315 309
316 void EnterpriseOAuthEnrollmentScreenHandler::OnOAuthGetAccessTokenSuccess( 310 void EnterpriseOAuthEnrollmentScreenHandler::OnOAuthGetAccessTokenSuccess(
317 const std::string& token, 311 const std::string& token,
318 const std::string& secret) { 312 const std::string& secret) {
319 access_token_ = token; 313 access_token_ = token;
320 access_token_secret_ = secret; 314 access_token_secret_ = secret;
321 } 315 }
322 316
323 void EnterpriseOAuthEnrollmentScreenHandler::OnOAuthGetAccessTokenFailure( 317 void EnterpriseOAuthEnrollmentScreenHandler::OnOAuthGetAccessTokenFailure(
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 controller_->OnConfirmationClosed(back_to_signin); 553 controller_->OnConfirmationClosed(back_to_signin);
560 } 554 }
561 555
562 void EnterpriseOAuthEnrollmentScreenHandler::UMAFailure(int sample) { 556 void EnterpriseOAuthEnrollmentScreenHandler::UMAFailure(int sample) {
563 if (is_auto_enrollment_) 557 if (is_auto_enrollment_)
564 sample = policy::kMetricEnrollmentAutoFailed; 558 sample = policy::kMetricEnrollmentAutoFailed;
565 UMA(sample); 559 UMA(sample);
566 } 560 }
567 561
568 } // namespace chromeos 562 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_screen_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698