Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / login / enrollment_screen_handler.cc
blob923c60aef75e0fe966af90b9bec996e54bd7d6a1
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
7 #include <algorithm>
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/logging.h"
12 #include "base/macros.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/values.h"
15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/browser_process_platform_part.h"
17 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
18 #include "chrome/browser/chromeos/login/screens/network_error.h"
19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
21 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
22 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
23 #include "chrome/grit/generated_resources.h"
24 #include "chromeos/network/network_state.h"
25 #include "chromeos/network/network_state_handler.h"
26 #include "components/login/localized_values_builder.h"
27 #include "components/policy/core/browser/cloud/message_util.h"
28 #include "google_apis/gaia/gaia_auth_util.h"
29 #include "google_apis/gaia/gaia_urls.h"
30 #include "google_apis/gaia/google_service_auth_error.h"
31 #include "net/url_request/url_request_context_getter.h"
32 #include "ui/base/l10n/l10n_util.h"
34 namespace chromeos {
35 namespace {
37 const char kJsScreenPath[] = "login.OAuthEnrollmentScreen";
39 // Enrollment step names.
40 const char kEnrollmentStepSignin[] = "signin";
41 const char kEnrollmentStepSuccess[] = "success";
42 const char kEnrollmentStepWorking[] = "working";
44 // Enrollment mode constants used in the UI. This needs to be kept in sync with
45 // oobe_screen_oauth_enrollment.js.
46 const char kEnrollmentModeUIForced[] = "forced";
47 const char kEnrollmentModeUIManual[] = "manual";
48 const char kEnrollmentModeUIRecovery[] = "recovery";
50 // Converts |mode| to a mode identifier for the UI.
51 std::string EnrollmentModeToUIMode(policy::EnrollmentConfig::Mode mode) {
52 switch (mode) {
53 case policy::EnrollmentConfig::MODE_NONE:
54 break;
55 case policy::EnrollmentConfig::MODE_MANUAL:
56 case policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT:
57 case policy::EnrollmentConfig::MODE_LOCAL_ADVERTISED:
58 case policy::EnrollmentConfig::MODE_SERVER_ADVERTISED:
59 return kEnrollmentModeUIManual;
60 case policy::EnrollmentConfig::MODE_LOCAL_FORCED:
61 case policy::EnrollmentConfig::MODE_SERVER_FORCED:
62 return kEnrollmentModeUIForced;
63 case policy::EnrollmentConfig::MODE_RECOVERY:
64 return kEnrollmentModeUIRecovery;
67 NOTREACHED() << "Bad enrollment mode " << mode;
68 return kEnrollmentModeUIManual;
71 // Returns network name by service path.
72 std::string GetNetworkName(const std::string& service_path) {
73 const NetworkState* network =
74 NetworkHandler::Get()->network_state_handler()->GetNetworkState(
75 service_path);
76 if (!network)
77 return std::string();
78 return network->name();
81 bool IsBehindCaptivePortal(NetworkStateInformer::State state,
82 NetworkError::ErrorReason reason) {
83 return state == NetworkStateInformer::CAPTIVE_PORTAL ||
84 reason == NetworkError::ERROR_REASON_PORTAL_DETECTED;
87 bool IsProxyError(NetworkStateInformer::State state,
88 NetworkError::ErrorReason reason) {
89 return state == NetworkStateInformer::PROXY_AUTH_REQUIRED ||
90 reason == NetworkError::ERROR_REASON_PROXY_AUTH_CANCELLED ||
91 reason == NetworkError::ERROR_REASON_PROXY_CONNECTION_FAILED;
94 } // namespace
96 // EnrollmentScreenHandler, public ------------------------------
98 EnrollmentScreenHandler::EnrollmentScreenHandler(
99 const scoped_refptr<NetworkStateInformer>& network_state_informer,
100 NetworkErrorModel* network_error_model)
101 : BaseScreenHandler(kJsScreenPath),
102 controller_(NULL),
103 show_on_init_(false),
104 frame_error_(net::OK),
105 first_show_(true),
106 observe_network_failure_(false),
107 network_state_informer_(network_state_informer),
108 network_error_model_(network_error_model),
109 histogram_helper_(new ErrorScreensHistogramHelper("Enrollment")),
110 weak_ptr_factory_(this) {
111 set_async_assets_load_id(OobeUI::kScreenOobeEnrollment);
112 DCHECK(network_state_informer_.get());
113 DCHECK(network_error_model_);
114 network_state_informer_->AddObserver(this);
116 if (chromeos::LoginDisplayHostImpl::default_host()) {
117 chromeos::WebUILoginView* login_view =
118 chromeos::LoginDisplayHostImpl::default_host()->GetWebUILoginView();
119 if (login_view)
120 login_view->AddFrameObserver(this);
124 EnrollmentScreenHandler::~EnrollmentScreenHandler() {
125 network_state_informer_->RemoveObserver(this);
127 if (chromeos::LoginDisplayHostImpl::default_host()) {
128 chromeos::WebUILoginView* login_view =
129 chromeos::LoginDisplayHostImpl::default_host()->GetWebUILoginView();
130 if (login_view)
131 login_view->RemoveFrameObserver(this);
135 // EnrollmentScreenHandler, WebUIMessageHandler implementation --
137 void EnrollmentScreenHandler::RegisterMessages() {
138 AddCallback("oauthEnrollClose",
139 &EnrollmentScreenHandler::HandleClose);
140 AddCallback("oauthEnrollCompleteLogin",
141 &EnrollmentScreenHandler::HandleCompleteLogin);
142 AddCallback("oauthEnrollRetry",
143 &EnrollmentScreenHandler::HandleRetry);
144 AddCallback("frameLoadingCompleted",
145 &EnrollmentScreenHandler::HandleFrameLoadingCompleted);
146 AddCallback("oauthEnrollAttributes",
147 &EnrollmentScreenHandler::HandleDeviceAttributesProvided);
148 AddCallback("oauthEnrollOnLearnMore",
149 &EnrollmentScreenHandler::HandleOnLearnMore);
152 // EnrollmentScreenHandler
153 // EnrollmentScreenActor implementation -----------------------------------
155 void EnrollmentScreenHandler::SetParameters(
156 Controller* controller,
157 const policy::EnrollmentConfig& config) {
158 CHECK_NE(policy::EnrollmentConfig::MODE_NONE, config.mode);
159 controller_ = controller;
160 config_ = config;
163 void EnrollmentScreenHandler::PrepareToShow() {
166 void EnrollmentScreenHandler::Show() {
167 if (!page_is_ready())
168 show_on_init_ = true;
169 else
170 DoShow();
173 void EnrollmentScreenHandler::Hide() {
176 void EnrollmentScreenHandler::ShowSigninScreen() {
177 observe_network_failure_ = true;
178 ShowStep(kEnrollmentStepSignin);
181 void EnrollmentScreenHandler::ShowAttributePromptScreen(
182 const std::string& asset_id,
183 const std::string& location) {
184 CallJS("showAttributePromptStep", asset_id, location);
187 void EnrollmentScreenHandler::ShowEnrollmentSpinnerScreen() {
188 ShowStep(kEnrollmentStepWorking);
191 void EnrollmentScreenHandler::ShowAuthError(
192 const GoogleServiceAuthError& error) {
193 switch (error.state()) {
194 case GoogleServiceAuthError::NONE:
195 case GoogleServiceAuthError::CAPTCHA_REQUIRED:
196 case GoogleServiceAuthError::TWO_FACTOR:
197 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED:
198 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
199 case GoogleServiceAuthError::REQUEST_CANCELED:
200 case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE:
201 case GoogleServiceAuthError::SERVICE_ERROR:
202 case GoogleServiceAuthError::WEB_LOGIN_REQUIRED:
203 ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_FATAL_ERROR, false);
204 return;
205 case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
206 case GoogleServiceAuthError::ACCOUNT_DELETED:
207 case GoogleServiceAuthError::ACCOUNT_DISABLED:
208 ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_ACCOUNT_ERROR, true);
209 return;
210 case GoogleServiceAuthError::CONNECTION_FAILED:
211 case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
212 ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_NETWORK_ERROR, true);
213 return;
214 case GoogleServiceAuthError::NUM_STATES:
215 break;
217 NOTREACHED();
220 void EnrollmentScreenHandler::ShowOtherError(
221 EnterpriseEnrollmentHelper::OtherError error) {
222 switch (error) {
223 case EnterpriseEnrollmentHelper::OTHER_ERROR_DOMAIN_MISMATCH:
224 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_USER, true);
225 return;
226 case EnterpriseEnrollmentHelper::OTHER_ERROR_FATAL:
227 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR, true);
228 return;
230 NOTREACHED();
233 void EnrollmentScreenHandler::ShowEnrollmentStatus(
234 policy::EnrollmentStatus status) {
235 switch (status.status()) {
236 case policy::EnrollmentStatus::STATUS_SUCCESS:
237 ShowStep(kEnrollmentStepSuccess);
238 return;
239 case policy::EnrollmentStatus::STATUS_NO_STATE_KEYS:
240 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_NO_STATE_KEYS, false);
241 return;
242 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED:
243 // Some special cases for generating a nicer message that's more helpful.
244 switch (status.client_status()) {
245 case policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED:
246 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR, true);
247 break;
248 case policy::DM_STATUS_SERVICE_MISSING_LICENSES:
249 ShowError(IDS_ENTERPRISE_ENROLLMENT_MISSING_LICENSES_ERROR, true);
250 break;
251 case policy::DM_STATUS_SERVICE_DEPROVISIONED:
252 ShowError(IDS_ENTERPRISE_ENROLLMENT_DEPROVISIONED_ERROR, true);
253 break;
254 case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH:
255 ShowError(IDS_ENTERPRISE_ENROLLMENT_DOMAIN_MISMATCH_ERROR, true);
256 break;
257 default:
258 ShowErrorMessage(
259 l10n_util::GetStringFUTF8(
260 IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_FAILED,
261 policy::FormatDeviceManagementStatus(status.client_status())),
262 true);
264 return;
265 case policy::EnrollmentStatus::STATUS_ROBOT_AUTH_FETCH_FAILED:
266 ShowError(IDS_ENTERPRISE_ENROLLMENT_ROBOT_AUTH_FETCH_FAILED, true);
267 return;
268 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_FETCH_FAILED:
269 ShowError(IDS_ENTERPRISE_ENROLLMENT_ROBOT_REFRESH_FETCH_FAILED, true);
270 return;
271 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED:
272 ShowError(IDS_ENTERPRISE_ENROLLMENT_ROBOT_REFRESH_STORE_FAILED, true);
273 return;
274 case policy::EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE:
275 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_BAD_MODE, false);
276 return;
277 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED:
278 ShowErrorMessage(
279 l10n_util::GetStringFUTF8(
280 IDS_ENTERPRISE_ENROLLMENT_STATUS_POLICY_FETCH_FAILED,
281 policy::FormatDeviceManagementStatus(status.client_status())),
282 true);
283 return;
284 case policy::EnrollmentStatus::STATUS_VALIDATION_FAILED:
285 ShowErrorMessage(
286 l10n_util::GetStringFUTF8(
287 IDS_ENTERPRISE_ENROLLMENT_STATUS_VALIDATION_FAILED,
288 policy::FormatValidationStatus(status.validation_status())),
289 true);
290 return;
291 case policy::EnrollmentStatus::STATUS_LOCK_ERROR:
292 switch (status.lock_status()) {
293 case policy::EnterpriseInstallAttributes::LOCK_SUCCESS:
294 case policy::EnterpriseInstallAttributes::LOCK_NOT_READY:
295 // LOCK_SUCCESS is in contradiction of STATUS_LOCK_ERROR.
296 // LOCK_NOT_READY is transient, if retries are given up, LOCK_TIMEOUT
297 // is reported instead. This piece of code is unreached.
298 LOG(FATAL) << "Invalid lock status.";
299 return;
300 case policy::EnterpriseInstallAttributes::LOCK_TIMEOUT:
301 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_TIMEOUT, false);
302 return;
303 case policy::EnterpriseInstallAttributes::LOCK_BACKEND_INVALID:
304 case policy::EnterpriseInstallAttributes::LOCK_ALREADY_LOCKED:
305 case policy::EnterpriseInstallAttributes::LOCK_SET_ERROR:
306 case policy::EnterpriseInstallAttributes::LOCK_FINALIZE_ERROR:
307 case policy::EnterpriseInstallAttributes::LOCK_READBACK_ERROR:
308 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_ERROR, false);
309 return;
310 case policy::EnterpriseInstallAttributes::LOCK_WRONG_DOMAIN:
311 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_USER, true);
312 return;
313 case policy::EnterpriseInstallAttributes::LOCK_WRONG_MODE:
314 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_MODE, true);
315 return;
317 NOTREACHED();
318 return;
319 case policy::EnrollmentStatus::STATUS_STORE_ERROR:
320 ShowErrorMessage(
321 l10n_util::GetStringFUTF8(
322 IDS_ENTERPRISE_ENROLLMENT_STATUS_STORE_ERROR,
323 policy::FormatStoreStatus(status.store_status(),
324 status.validation_status())),
325 true);
326 return;
327 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED:
328 // This error should not happen for enterprise enrollment.
329 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_STORE_TOKEN_AND_ID_FAILED,
330 true);
331 NOTREACHED();
332 return;
333 case policy::EnrollmentStatus::STATUS_ATTRIBUTE_UPDATE_FAILED:
334 ShowError(IDS_ENTERPRISE_ENROLLMENT_ATTRIBUTE_ERROR, false);
335 return;
337 NOTREACHED();
340 // EnrollmentScreenHandler BaseScreenHandler implementation -----
342 void EnrollmentScreenHandler::Initialize() {
343 if (show_on_init_) {
344 Show();
345 show_on_init_ = false;
349 void EnrollmentScreenHandler::DeclareLocalizedValues(
350 ::login::LocalizedValuesBuilder* builder) {
351 builder->Add("oauthEnrollScreenTitle",
352 IDS_ENTERPRISE_ENROLLMENT_SCREEN_TITLE);
353 builder->Add("oauthEnrollRetry", IDS_ENTERPRISE_ENROLLMENT_RETRY);
354 builder->Add("oauthEnrollDone", IDS_ENTERPRISE_ENROLLMENT_DONE);
355 builder->Add("oauthEnrollNextBtn", IDS_NEWGAIA_OFFLINE_NEXT_BUTTON_TEXT);
356 builder->Add("oauthEnrollSkip", IDS_ENTERPRISE_ENROLLMENT_SKIP);
357 builder->Add("oauthEnrollSuccess", IDS_ENTERPRISE_ENROLLMENT_SUCCESS);
358 builder->Add("oauthEnrollDeviceInformation",
359 IDS_ENTERPRISE_ENROLLMENT_DEVICE_INFORMATION);
360 builder->Add("oauthEnrollExplaneAttributeLink",
361 IDS_ENTERPRISE_ENROLLMENT_EXPLAIN_ATTRIBUTE_LINK);
362 builder->Add("oauthEnrollAttributeExplanation",
363 IDS_ENTERPRISE_ENROLLMENT_ATTRIBUTE_EXPLANATION);
364 builder->Add("oauthEnrollAssetIdLabel",
365 IDS_ENTERPRISE_ENROLLMENT_ASSET_ID_LABEL);
366 builder->Add("oauthEnrollLocationLabel",
367 IDS_ENTERPRISE_ENROLLMENT_LOCATION_LABEL);
370 OobeUI::Screen EnrollmentScreenHandler::GetCurrentScreen() const {
371 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN;
372 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController());
373 if (oobe_ui)
374 screen = oobe_ui->current_screen();
375 return screen;
378 bool EnrollmentScreenHandler::IsOnEnrollmentScreen() const {
379 return (GetCurrentScreen() == OobeUI::SCREEN_OOBE_ENROLLMENT);
382 bool EnrollmentScreenHandler::IsEnrollmentScreenHiddenByError() const {
383 return (GetCurrentScreen() == OobeUI::SCREEN_ERROR_MESSAGE &&
384 network_error_model_->GetParentScreen() ==
385 OobeUI::SCREEN_OOBE_ENROLLMENT);
388 void EnrollmentScreenHandler::UpdateState(NetworkError::ErrorReason reason) {
389 UpdateStateInternal(reason, false);
392 // TODO(rsorokin): This function is mostly copied from SigninScreenHandler and
393 // should be refactored in the future.
394 void EnrollmentScreenHandler::UpdateStateInternal(
395 NetworkError::ErrorReason reason,
396 bool force_update) {
397 if (!force_update && !IsOnEnrollmentScreen() &&
398 !IsEnrollmentScreenHiddenByError()) {
399 return;
402 if (!force_update && !observe_network_failure_)
403 return;
405 NetworkStateInformer::State state = network_state_informer_->state();
406 const std::string network_path = network_state_informer_->network_path();
407 const bool is_online = (state == NetworkStateInformer::ONLINE);
408 const bool is_behind_captive_portal =
409 (state == NetworkStateInformer::CAPTIVE_PORTAL);
410 const bool is_frame_error =
411 (frame_error() != net::OK) ||
412 (reason == NetworkError::ERROR_REASON_FRAME_ERROR);
414 LOG(WARNING) << "EnrollmentScreenHandler::UpdateState(): "
415 << "state=" << NetworkStateInformer::StatusString(state) << ", "
416 << "reason=" << NetworkError::ErrorReasonString(reason);
418 if (is_online || !is_behind_captive_portal)
419 network_error_model_->HideCaptivePortal();
421 if (is_frame_error) {
422 LOG(WARNING) << "Retry page load";
423 // TODO(rsorokin): Too many consecutive reloads.
424 CallJS("doReload");
427 if (!is_online || is_frame_error)
428 SetupAndShowOfflineMessage(state, reason);
429 else
430 HideOfflineMessage(state, reason);
433 void EnrollmentScreenHandler::SetupAndShowOfflineMessage(
434 NetworkStateInformer::State state,
435 NetworkError::ErrorReason reason) {
436 const std::string network_path = network_state_informer_->network_path();
437 const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason);
438 const bool is_proxy_error = IsProxyError(state, reason);
439 const bool is_frame_error =
440 (frame_error() != net::OK) ||
441 (reason == NetworkError::ERROR_REASON_FRAME_ERROR);
443 if (is_proxy_error) {
444 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_PROXY,
445 std::string());
446 } else if (is_behind_captive_portal) {
447 // Do not bother a user with obsessive captive portal showing. This
448 // check makes captive portal being shown only once: either when error
449 // screen is shown for the first time or when switching from another
450 // error screen (offline, proxy).
451 if (IsOnEnrollmentScreen() || (network_error_model_->GetErrorState() !=
452 NetworkError::ERROR_STATE_PORTAL)) {
453 network_error_model_->FixCaptivePortal();
455 const std::string network_name = GetNetworkName(network_path);
456 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_PORTAL,
457 network_name);
458 } else if (is_frame_error) {
459 network_error_model_->SetErrorState(
460 NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT, std::string());
461 } else {
462 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_OFFLINE,
463 std::string());
466 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) {
467 const std::string network_type = network_state_informer_->network_type();
468 network_error_model_->SetUIState(NetworkError::UI_STATE_SIGNIN);
469 network_error_model_->SetParentScreen(OobeUI::SCREEN_OOBE_ENROLLMENT);
470 network_error_model_->SetHideCallback(base::Bind(
471 &EnrollmentScreenHandler::DoShow, weak_ptr_factory_.GetWeakPtr()));
472 network_error_model_->Show();
473 histogram_helper_->OnErrorShow(network_error_model_->GetErrorState());
477 void EnrollmentScreenHandler::HideOfflineMessage(
478 NetworkStateInformer::State state,
479 NetworkError::ErrorReason reason) {
480 if (IsEnrollmentScreenHiddenByError())
481 network_error_model_->Hide();
482 histogram_helper_->OnErrorHide();
485 void EnrollmentScreenHandler::OnFrameError(
486 const std::string& frame_unique_name) {
487 if (frame_unique_name == "oauth-enroll-signin-frame") {
488 HandleFrameLoadingCompleted(net::ERR_FAILED);
491 // EnrollmentScreenHandler, private -----------------------------
493 void EnrollmentScreenHandler::HandleClose(const std::string& reason) {
494 DCHECK(controller_);
496 if (reason == "cancel")
497 controller_->OnCancel();
498 else if (reason == "done")
499 controller_->OnConfirmationClosed();
500 else
501 NOTREACHED();
504 void EnrollmentScreenHandler::HandleCompleteLogin(
505 const std::string& user,
506 const std::string& auth_code) {
507 observe_network_failure_ = false;
508 DCHECK(controller_);
509 controller_->OnLoginDone(gaia::SanitizeEmail(user), auth_code);
512 void EnrollmentScreenHandler::HandleRetry() {
513 DCHECK(controller_);
514 controller_->OnRetry();
517 void EnrollmentScreenHandler::HandleFrameLoadingCompleted(int status) {
518 const net::Error frame_error = static_cast<net::Error>(status);
519 frame_error_ = frame_error;
521 if (network_state_informer_->state() != NetworkStateInformer::ONLINE)
522 return;
523 if (frame_error_)
524 UpdateState(NetworkError::ERROR_REASON_FRAME_ERROR);
525 else
526 UpdateState(NetworkError::ERROR_REASON_UPDATE);
529 void EnrollmentScreenHandler::HandleDeviceAttributesProvided(
530 const std::string& asset_id,
531 const std::string& location) {
532 controller_->OnDeviceAttributeProvided(asset_id, location);
535 void EnrollmentScreenHandler::HandleOnLearnMore() {
536 if (!help_app_.get())
537 help_app_ = new HelpAppLauncher(GetNativeWindow());
538 help_app_->ShowHelpTopic(HelpAppLauncher::HELP_DEVICE_ATTRIBUTES);
541 void EnrollmentScreenHandler::ShowStep(const char* step) {
542 CallJS("showStep", std::string(step));
545 void EnrollmentScreenHandler::ShowError(int message_id, bool retry) {
546 ShowErrorMessage(l10n_util::GetStringUTF8(message_id), retry);
549 void EnrollmentScreenHandler::ShowErrorMessage(const std::string& message,
550 bool retry) {
551 CallJS("showError", message, retry);
554 void EnrollmentScreenHandler::DoShow() {
555 base::DictionaryValue screen_data;
556 screen_data.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
557 screen_data.SetString("clientId",
558 GaiaUrls::GetInstance()->oauth2_chrome_client_id());
559 screen_data.SetString("enrollment_mode",
560 EnrollmentModeToUIMode(config_.mode));
561 screen_data.SetString("management_domain", config_.management_domain);
563 const bool cfm = g_browser_process->platform_part()
564 ->browser_policy_connector_chromeos()
565 ->GetDeviceCloudPolicyManager()
566 ->IsRemoraRequisition();
567 screen_data.SetString("flow", cfm ? "cfm" : "enterprise");
569 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data);
570 if (first_show_) {
571 first_show_ = false;
572 UpdateStateInternal(NetworkError::ERROR_REASON_UPDATE, true);
574 histogram_helper_->OnScreenShow();
577 } // namespace chromeos