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"
10 #include "base/bind_helpers.h"
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h"
16 #include "base/values.h"
17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/browsing_data/browsing_data_helper.h"
19 #include "chrome/browser/browsing_data/browsing_data_remover.h"
20 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
21 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h"
22 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h"
23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retriever.h"
25 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
26 #include "chrome/grit/generated_resources.h"
27 #include "chromeos/network/network_state.h"
28 #include "chromeos/network/network_state_handler.h"
29 #include "components/policy/core/browser/cloud/message_util.h"
30 #include "content/public/browser/web_contents.h"
31 #include "google_apis/gaia/gaia_auth_fetcher.h"
32 #include "google_apis/gaia/gaia_auth_util.h"
33 #include "google_apis/gaia/gaia_constants.h"
34 #include "google_apis/gaia/gaia_urls.h"
35 #include "google_apis/gaia/google_service_auth_error.h"
36 #include "net/url_request/url_request_context_getter.h"
37 #include "ui/base/l10n/l10n_util.h"
42 const char kJsScreenPath[] = "login.OAuthEnrollmentScreen";
44 // Enrollment step names.
45 const char kEnrollmentStepSignin[] = "signin";
46 const char kEnrollmentStepSuccess[] = "success";
48 // Enrollment mode strings.
49 const char* const kModeStrings[EnrollmentScreenActor::ENROLLMENT_MODE_COUNT] =
50 { "manual", "forced", "auto", "recovery" };
52 std::string EnrollmentModeToString(EnrollmentScreenActor::EnrollmentMode mode) {
53 CHECK(0 <= mode && mode < EnrollmentScreenActor::ENROLLMENT_MODE_COUNT);
54 return kModeStrings[mode];
57 // A helper class that takes care of asynchronously revoking a given token.
58 class TokenRevoker : public GaiaAuthConsumer {
62 GaiaConstants::kChromeOSSource,
63 g_browser_process->system_request_context()) {}
64 virtual ~TokenRevoker() {}
66 void Start(const std::string& token) {
67 gaia_fetcher_.StartRevokeOAuth2Token(token);
71 virtual void OnOAuth2RevokeTokenCompleted() OVERRIDE {
72 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
76 GaiaAuthFetcher gaia_fetcher_;
78 DISALLOW_COPY_AND_ASSIGN(TokenRevoker);
81 // Returns network name by service path.
82 std::string GetNetworkName(const std::string& service_path) {
83 const NetworkState* network =
84 NetworkHandler::Get()->network_state_handler()->GetNetworkState(
88 return network->name();
91 bool IsBehindCaptivePortal(NetworkStateInformer::State state,
92 ErrorScreenActor::ErrorReason reason) {
93 return state == NetworkStateInformer::CAPTIVE_PORTAL ||
94 reason == ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED;
97 bool IsProxyError(NetworkStateInformer::State state,
98 ErrorScreenActor::ErrorReason reason) {
99 return state == NetworkStateInformer::PROXY_AUTH_REQUIRED ||
100 reason == ErrorScreenActor::ERROR_REASON_PROXY_AUTH_CANCELLED ||
101 reason == ErrorScreenActor::ERROR_REASON_PROXY_CONNECTION_FAILED;
106 // EnrollmentScreenHandler, public ------------------------------
108 EnrollmentScreenHandler::EnrollmentScreenHandler(
109 const scoped_refptr<NetworkStateInformer>& network_state_informer,
110 ErrorScreenActor* error_screen_actor)
111 : BaseScreenHandler(kJsScreenPath),
113 show_on_init_(false),
114 enrollment_mode_(ENROLLMENT_MODE_MANUAL),
115 browsing_data_remover_(NULL),
116 frame_error_(net::OK),
117 network_state_informer_(network_state_informer),
118 error_screen_actor_(error_screen_actor),
119 weak_ptr_factory_(this) {
120 set_async_assets_load_id(OobeUI::kScreenOobeEnrollment);
121 DCHECK(network_state_informer_.get());
122 DCHECK(error_screen_actor_);
123 network_state_informer_->AddObserver(this);
125 if (chromeos::LoginDisplayHostImpl::default_host()) {
126 chromeos::WebUILoginView* login_view =
127 chromeos::LoginDisplayHostImpl::default_host()->GetWebUILoginView();
129 login_view->AddFrameObserver(this);
133 EnrollmentScreenHandler::~EnrollmentScreenHandler() {
134 if (browsing_data_remover_)
135 browsing_data_remover_->RemoveObserver(this);
136 network_state_informer_->RemoveObserver(this);
138 if (chromeos::LoginDisplayHostImpl::default_host()) {
139 chromeos::WebUILoginView* login_view =
140 chromeos::LoginDisplayHostImpl::default_host()->GetWebUILoginView();
142 login_view->RemoveFrameObserver(this);
146 // EnrollmentScreenHandler, WebUIMessageHandler implementation --
148 void EnrollmentScreenHandler::RegisterMessages() {
149 AddCallback("oauthEnrollRetrieveAuthenticatedUserEmail",
150 &EnrollmentScreenHandler::HandleRetrieveAuthenticatedUserEmail);
151 AddCallback("oauthEnrollClose",
152 &EnrollmentScreenHandler::HandleClose);
153 AddCallback("oauthEnrollCompleteLogin",
154 &EnrollmentScreenHandler::HandleCompleteLogin);
155 AddCallback("oauthEnrollRetry",
156 &EnrollmentScreenHandler::HandleRetry);
157 AddCallback("frameLoadingCompleted",
158 &EnrollmentScreenHandler::HandleFrameLoadingCompleted);
161 // EnrollmentScreenHandler
162 // EnrollmentScreenActor implementation -----------------------------------
164 void EnrollmentScreenHandler::SetParameters(
165 Controller* controller,
166 EnrollmentMode enrollment_mode,
167 const std::string& management_domain) {
168 controller_ = controller;
169 enrollment_mode_ = enrollment_mode;
170 management_domain_ = management_domain;
173 void EnrollmentScreenHandler::PrepareToShow() {
176 void EnrollmentScreenHandler::Show() {
177 if (!page_is_ready())
178 show_on_init_ = true;
183 void EnrollmentScreenHandler::Hide() {
186 void EnrollmentScreenHandler::FetchOAuthToken() {
187 Profile* profile = Profile::FromWebUI(web_ui());
188 oauth_fetcher_.reset(
189 new policy::PolicyOAuth2TokenFetcher(
190 profile->GetRequestContext(),
191 g_browser_process->system_request_context(),
192 base::Bind(&EnrollmentScreenHandler::OnTokenFetched,
193 base::Unretained(this))));
194 oauth_fetcher_->Start();
197 void EnrollmentScreenHandler::ResetAuth(const base::Closure& callback) {
198 auth_reset_callbacks_.push_back(callback);
199 if (browsing_data_remover_)
202 if (oauth_fetcher_) {
203 if (!oauth_fetcher_->oauth2_access_token().empty())
204 (new TokenRevoker())->Start(oauth_fetcher_->oauth2_access_token());
206 if (!oauth_fetcher_->oauth2_refresh_token().empty())
207 (new TokenRevoker())->Start(oauth_fetcher_->oauth2_refresh_token());
210 Profile* profile = Profile::FromBrowserContext(
211 web_ui()->GetWebContents()->GetBrowserContext());
212 browsing_data_remover_ =
213 BrowsingDataRemover::CreateForUnboundedRange(profile);
214 browsing_data_remover_->AddObserver(this);
215 browsing_data_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA,
216 BrowsingDataHelper::UNPROTECTED_WEB);
219 void EnrollmentScreenHandler::ShowSigninScreen() {
220 ShowStep(kEnrollmentStepSignin);
223 void EnrollmentScreenHandler::ShowEnrollmentSpinnerScreen() {
224 ShowWorking(IDS_ENTERPRISE_ENROLLMENT_WORKING);
227 void EnrollmentScreenHandler::ShowLoginSpinnerScreen() {
228 ShowWorking(IDS_ENTERPRISE_ENROLLMENT_RESUMING_LOGIN);
231 void EnrollmentScreenHandler::ShowAuthError(
232 const GoogleServiceAuthError& error) {
233 switch (error.state()) {
234 case GoogleServiceAuthError::NONE:
235 case GoogleServiceAuthError::CAPTCHA_REQUIRED:
236 case GoogleServiceAuthError::TWO_FACTOR:
237 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED:
238 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
239 case GoogleServiceAuthError::REQUEST_CANCELED:
240 case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE:
241 case GoogleServiceAuthError::SERVICE_ERROR:
242 ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_FATAL_ERROR, false);
244 case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
245 case GoogleServiceAuthError::ACCOUNT_DELETED:
246 case GoogleServiceAuthError::ACCOUNT_DISABLED:
247 ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_ACCOUNT_ERROR, true);
249 case GoogleServiceAuthError::CONNECTION_FAILED:
250 case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
251 ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_NETWORK_ERROR, true);
253 case GoogleServiceAuthError::NUM_STATES:
259 void EnrollmentScreenHandler::ShowUIError(UIError error) {
261 case UI_ERROR_DOMAIN_MISMATCH:
262 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_USER, true);
264 case UI_ERROR_AUTO_ENROLLMENT_BAD_MODE:
265 ShowError(IDS_ENTERPRISE_AUTO_ENROLLMENT_BAD_MODE, true);
268 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR, true);
274 void EnrollmentScreenHandler::ShowEnrollmentStatus(
275 policy::EnrollmentStatus status) {
276 switch (status.status()) {
277 case policy::EnrollmentStatus::STATUS_SUCCESS:
278 ShowStep(kEnrollmentStepSuccess);
280 case policy::EnrollmentStatus::STATUS_NO_STATE_KEYS:
281 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_NO_STATE_KEYS, false);
283 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED:
284 // Some special cases for generating a nicer message that's more helpful.
285 switch (status.client_status()) {
286 case policy::DM_STATUS_SERVICE_MANAGEMENT_NOT_SUPPORTED:
287 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR, true);
289 case policy::DM_STATUS_SERVICE_MISSING_LICENSES:
290 ShowError(IDS_ENTERPRISE_ENROLLMENT_MISSING_LICENSES_ERROR, true);
292 case policy::DM_STATUS_SERVICE_DEPROVISIONED:
293 ShowError(IDS_ENTERPRISE_ENROLLMENT_DEPROVISIONED_ERROR, true);
295 case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH:
296 ShowError(IDS_ENTERPRISE_ENROLLMENT_DOMAIN_MISMATCH_ERROR, true);
300 l10n_util::GetStringFUTF8(
301 IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_FAILED,
302 policy::FormatDeviceManagementStatus(status.client_status())),
306 case policy::EnrollmentStatus::STATUS_ROBOT_AUTH_FETCH_FAILED:
307 ShowError(IDS_ENTERPRISE_ENROLLMENT_ROBOT_AUTH_FETCH_FAILED, true);
309 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_FETCH_FAILED:
310 ShowError(IDS_ENTERPRISE_ENROLLMENT_ROBOT_REFRESH_FETCH_FAILED, true);
312 case policy::EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED:
313 ShowError(IDS_ENTERPRISE_ENROLLMENT_ROBOT_REFRESH_STORE_FAILED, true);
315 case policy::EnrollmentStatus::STATUS_REGISTRATION_BAD_MODE:
316 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_BAD_MODE, false);
318 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED:
320 l10n_util::GetStringFUTF8(
321 IDS_ENTERPRISE_ENROLLMENT_STATUS_POLICY_FETCH_FAILED,
322 policy::FormatDeviceManagementStatus(status.client_status())),
325 case policy::EnrollmentStatus::STATUS_VALIDATION_FAILED:
327 l10n_util::GetStringFUTF8(
328 IDS_ENTERPRISE_ENROLLMENT_STATUS_VALIDATION_FAILED,
329 policy::FormatValidationStatus(status.validation_status())),
332 case policy::EnrollmentStatus::STATUS_LOCK_ERROR:
333 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_ERROR, false);
335 case policy::EnrollmentStatus::STATUS_LOCK_TIMEOUT:
336 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_TIMEOUT, false);
338 case policy::EnrollmentStatus::STATUS_LOCK_WRONG_USER:
339 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_LOCK_WRONG_USER, true);
341 case policy::EnrollmentStatus::STATUS_STORE_ERROR:
343 l10n_util::GetStringFUTF8(
344 IDS_ENTERPRISE_ENROLLMENT_STATUS_STORE_ERROR,
345 policy::FormatStoreStatus(status.store_status(),
346 status.validation_status())),
349 case policy::EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED:
350 // This error should not happen for enterprise enrollment.
351 ShowError(IDS_ENTERPRISE_ENROLLMENT_STATUS_STORE_TOKEN_AND_ID_FAILED,
359 // EnrollmentScreenHandler BaseScreenHandler implementation -----
361 void EnrollmentScreenHandler::Initialize() {
364 show_on_init_ = false;
368 void EnrollmentScreenHandler::DeclareLocalizedValues(
369 LocalizedValuesBuilder* builder) {
370 builder->Add("oauthEnrollScreenTitle",
371 IDS_ENTERPRISE_ENROLLMENT_SCREEN_TITLE);
372 builder->Add("oauthEnrollDescription", IDS_ENTERPRISE_ENROLLMENT_DESCRIPTION);
373 builder->Add("oauthEnrollReEnrollmentText",
374 IDS_ENTERPRISE_ENROLLMENT_RE_ENROLLMENT_TEXT);
375 builder->Add("oauthEnrollRetry", IDS_ENTERPRISE_ENROLLMENT_RETRY);
376 builder->Add("oauthEnrollCancel", IDS_ENTERPRISE_ENROLLMENT_CANCEL);
377 builder->Add("oauthEnrollDone", IDS_ENTERPRISE_ENROLLMENT_DONE);
378 builder->Add("oauthEnrollSuccess", IDS_ENTERPRISE_ENROLLMENT_SUCCESS);
379 builder->Add("oauthEnrollExplain", IDS_ENTERPRISE_ENROLLMENT_EXPLAIN);
380 builder->Add("oauthEnrollExplainLink",
381 IDS_ENTERPRISE_ENROLLMENT_EXPLAIN_LINK);
382 builder->Add("oauthEnrollExplainButton",
383 IDS_ENTERPRISE_ENROLLMENT_EXPLAIN_BUTTON);
384 builder->Add("oauthEnrollCancelAutoEnrollmentReally",
385 IDS_ENTERPRISE_ENROLLMENT_CANCEL_AUTO_REALLY);
386 builder->Add("oauthEnrollCancelAutoEnrollmentConfirm",
387 IDS_ENTERPRISE_ENROLLMENT_CANCEL_AUTO_CONFIRM);
388 builder->Add("oauthEnrollCancelAutoEnrollmentGoBack",
389 IDS_ENTERPRISE_ENROLLMENT_CANCEL_AUTO_GO_BACK);
392 void EnrollmentScreenHandler::OnBrowsingDataRemoverDone() {
393 browsing_data_remover_->RemoveObserver(this);
394 browsing_data_remover_ = NULL;
396 std::vector<base::Closure> callbacks_to_run;
397 callbacks_to_run.swap(auth_reset_callbacks_);
398 for (std::vector<base::Closure>::iterator callback(callbacks_to_run.begin());
399 callback != callbacks_to_run.end(); ++callback) {
404 OobeUI::Screen EnrollmentScreenHandler::GetCurrentScreen() const {
405 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN;
406 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController());
408 screen = oobe_ui->current_screen();
412 bool EnrollmentScreenHandler::IsOnEnrollmentScreen() const {
413 return (GetCurrentScreen() == OobeUI::SCREEN_OOBE_ENROLLMENT);
416 bool EnrollmentScreenHandler::IsEnrollmentScreenHiddenByError() const {
417 return (GetCurrentScreen() == OobeUI::SCREEN_ERROR_MESSAGE &&
418 error_screen_actor_->parent_screen() ==
419 OobeUI::SCREEN_OOBE_ENROLLMENT);
422 // TODO(rsorokin): This function is mostly copied from SigninScreenHandler and
423 // should be refactored in the future.
424 void EnrollmentScreenHandler::UpdateState(
425 ErrorScreenActor::ErrorReason reason) {
426 if (!IsOnEnrollmentScreen() && !IsEnrollmentScreenHiddenByError())
429 NetworkStateInformer::State state = network_state_informer_->state();
430 const std::string network_path = network_state_informer_->network_path();
431 const bool is_online = (state == NetworkStateInformer::ONLINE);
432 const bool is_behind_captive_portal =
433 (state == NetworkStateInformer::CAPTIVE_PORTAL);
434 const bool is_frame_error =
435 (frame_error() != net::OK) ||
436 (reason == ErrorScreenActor::ERROR_REASON_FRAME_ERROR);
438 LOG(WARNING) << "EnrollmentScreenHandler::UpdateState(): "
439 << "state=" << NetworkStateInformer::StatusString(state) << ", "
440 << "reason=" << ErrorScreenActor::ErrorReasonString(reason);
442 if (is_online || !is_behind_captive_portal)
443 error_screen_actor_->HideCaptivePortal();
445 if (is_frame_error) {
446 LOG(WARNING) << "Retry page load";
447 // TODO(rsorokin): Too many consecutive reloads.
451 if (!is_online || is_frame_error)
452 SetupAndShowOfflineMessage(state, reason);
454 HideOfflineMessage(state, reason);
457 void EnrollmentScreenHandler::SetupAndShowOfflineMessage(
458 NetworkStateInformer::State state,
459 ErrorScreenActor::ErrorReason reason) {
460 const std::string network_path = network_state_informer_->network_path();
461 const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason);
462 const bool is_proxy_error = IsProxyError(state, reason);
463 const bool is_frame_error =
464 (frame_error() != net::OK) ||
465 (reason == ErrorScreenActor::ERROR_REASON_FRAME_ERROR);
467 if (is_proxy_error) {
468 error_screen_actor_->SetErrorState(ErrorScreen::ERROR_STATE_PROXY,
470 } else if (is_behind_captive_portal) {
471 // Do not bother a user with obsessive captive portal showing. This
472 // check makes captive portal being shown only once: either when error
473 // screen is shown for the first time or when switching from another
474 // error screen (offline, proxy).
475 if (IsOnEnrollmentScreen() || (error_screen_actor_->error_state() !=
476 ErrorScreen::ERROR_STATE_PORTAL)) {
477 error_screen_actor_->FixCaptivePortal();
479 const std::string network_name = GetNetworkName(network_path);
480 error_screen_actor_->SetErrorState(ErrorScreen::ERROR_STATE_PORTAL,
482 } else if (is_frame_error) {
483 error_screen_actor_->SetErrorState(
484 ErrorScreen::ERROR_STATE_AUTH_EXT_TIMEOUT, std::string());
486 error_screen_actor_->SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE,
490 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) {
491 base::DictionaryValue params;
492 const std::string network_type = network_state_informer_->network_type();
493 params.SetString("lastNetworkType", network_type);
494 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_SIGNIN);
495 error_screen_actor_->Show(OobeUI::SCREEN_OOBE_ENROLLMENT,
497 base::Bind(&EnrollmentScreenHandler::DoShow,
498 weak_ptr_factory_.GetWeakPtr()));
502 void EnrollmentScreenHandler::HideOfflineMessage(
503 NetworkStateInformer::State state,
504 ErrorScreenActor::ErrorReason reason) {
505 if (IsEnrollmentScreenHiddenByError())
506 error_screen_actor_->Hide();
509 void EnrollmentScreenHandler::OnFrameError(
510 const std::string& frame_unique_name) {
511 if (frame_unique_name == "oauth-enroll-signin-frame") {
512 HandleFrameLoadingCompleted(net::ERR_FAILED);
515 // EnrollmentScreenHandler, private -----------------------------
517 void EnrollmentScreenHandler::HandleRetrieveAuthenticatedUserEmail(
518 double attempt_token) {
519 email_retriever_.reset(new AuthenticatedUserEmailRetriever(
520 base::Bind(&EnrollmentScreenHandler::CallJS<double, std::string>,
521 base::Unretained(this),
522 "setAuthenticatedUserEmail",
524 Profile::FromWebUI(web_ui())->GetRequestContext()));
527 void EnrollmentScreenHandler::HandleClose(const std::string& reason) {
530 if (reason == "cancel" || reason == "autocancel")
531 controller_->OnCancel();
532 else if (reason == "done")
533 controller_->OnConfirmationClosed();
538 void EnrollmentScreenHandler::HandleCompleteLogin(const std::string& user) {
540 controller_->OnLoginDone(gaia::SanitizeEmail(user));
543 void EnrollmentScreenHandler::HandleRetry() {
545 controller_->OnRetry();
548 void EnrollmentScreenHandler::HandleFrameLoadingCompleted(int status) {
549 const net::Error frame_error = static_cast<net::Error>(status);
550 frame_error_ = frame_error;
552 if (network_state_informer_->state() != NetworkStateInformer::ONLINE)
555 UpdateState(ErrorScreenActor::ERROR_REASON_FRAME_ERROR);
557 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE);
560 void EnrollmentScreenHandler::ShowStep(const char* step) {
561 CallJS("showStep", std::string(step));
564 void EnrollmentScreenHandler::ShowError(int message_id, bool retry) {
565 ShowErrorMessage(l10n_util::GetStringUTF8(message_id), retry);
568 void EnrollmentScreenHandler::ShowErrorMessage(const std::string& message,
570 CallJS("showError", message, retry);
573 void EnrollmentScreenHandler::ShowWorking(int message_id) {
574 CallJS("showWorking", l10n_util::GetStringUTF16(message_id));
577 void EnrollmentScreenHandler::OnTokenFetched(
578 const std::string& token,
579 const GoogleServiceAuthError& error) {
583 if (error.state() != GoogleServiceAuthError::NONE)
584 controller_->OnAuthError(error);
586 controller_->OnOAuthTokenAvailable(token);
589 void EnrollmentScreenHandler::DoShow() {
590 base::DictionaryValue screen_data;
591 screen_data.SetString(
593 base::StringPrintf("%s/main.html", extensions::kGaiaAuthExtensionOrigin));
594 screen_data.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
595 screen_data.SetString("enrollment_mode",
596 EnrollmentModeToString(enrollment_mode_));
597 screen_data.SetString("management_domain", management_domain_);
599 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data);
602 } // namespace chromeos