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

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

Issue 2959853003: Add UI components for license type selection in ChromeOS login UI. (Closed)
Patch Set: Remove unused flex import Created 3 years, 4 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 (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/enrollment_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/system/devicetype_utils.h" 9 #include "ash/system/devicetype_utils.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 26 matching lines...) Expand all
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
38 38
39 namespace chromeos { 39 namespace chromeos {
40 namespace { 40 namespace {
41 41
42 const char kJsScreenPath[] = "login.OAuthEnrollmentScreen"; 42 const char kJsScreenPath[] = "login.OAuthEnrollmentScreen";
43 43
44 // Enrollment step names. 44 // Enrollment step names.
45 const char kEnrollmentStepSignin[] = "signin"; 45 const char kEnrollmentStepSignin[] = "signin";
46 const char kEnrollmentStepAdJoin[] = "ad-join"; 46 const char kEnrollmentStepAdJoin[] = "ad-join";
47 const char kEnrollmentStepPickLicense[] = "license";
47 const char kEnrollmentStepSuccess[] = "success"; 48 const char kEnrollmentStepSuccess[] = "success";
48 const char kEnrollmentStepWorking[] = "working"; 49 const char kEnrollmentStepWorking[] = "working";
49 50
50 // Enrollment mode constants used in the UI. This needs to be kept in sync with 51 // Enrollment mode constants used in the UI. This needs to be kept in sync with
51 // oobe_screen_oauth_enrollment.js. 52 // oobe_screen_oauth_enrollment.js.
52 const char kEnrollmentModeUIForced[] = "forced"; 53 const char kEnrollmentModeUIForced[] = "forced";
53 const char kEnrollmentModeUIManual[] = "manual"; 54 const char kEnrollmentModeUIManual[] = "manual";
54 const char kEnrollmentModeUIRecovery[] = "recovery"; 55 const char kEnrollmentModeUIRecovery[] = "recovery";
55 56
56 // Converts |mode| to a mode identifier for the UI. 57 // Converts |mode| to a mode identifier for the UI.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 AddCallback("oauthEnrollAdCompleteLogin", 143 AddCallback("oauthEnrollAdCompleteLogin",
143 &EnrollmentScreenHandler::HandleAdCompleteLogin); 144 &EnrollmentScreenHandler::HandleAdCompleteLogin);
144 AddCallback("oauthEnrollRetry", 145 AddCallback("oauthEnrollRetry",
145 &EnrollmentScreenHandler::HandleRetry); 146 &EnrollmentScreenHandler::HandleRetry);
146 AddCallback("frameLoadingCompleted", 147 AddCallback("frameLoadingCompleted",
147 &EnrollmentScreenHandler::HandleFrameLoadingCompleted); 148 &EnrollmentScreenHandler::HandleFrameLoadingCompleted);
148 AddCallback("oauthEnrollAttributes", 149 AddCallback("oauthEnrollAttributes",
149 &EnrollmentScreenHandler::HandleDeviceAttributesProvided); 150 &EnrollmentScreenHandler::HandleDeviceAttributesProvided);
150 AddCallback("oauthEnrollOnLearnMore", 151 AddCallback("oauthEnrollOnLearnMore",
151 &EnrollmentScreenHandler::HandleOnLearnMore); 152 &EnrollmentScreenHandler::HandleOnLearnMore);
153 AddCallback("onLicenseTypeSelected",
154 &EnrollmentScreenHandler::HandleLicenseTypeSelected);
152 } 155 }
153 156
154 // EnrollmentScreenHandler 157 // EnrollmentScreenHandler
155 // EnrollmentScreenActor implementation ----------------------------------- 158 // EnrollmentScreenActor implementation -----------------------------------
156 159
157 void EnrollmentScreenHandler::SetParameters( 160 void EnrollmentScreenHandler::SetParameters(
158 Controller* controller, 161 Controller* controller,
159 const policy::EnrollmentConfig& config) { 162 const policy::EnrollmentConfig& config) {
160 CHECK(config.should_enroll()); 163 CHECK(config.should_enroll());
161 controller_ = controller; 164 controller_ = controller;
162 config_ = config; 165 config_ = config;
163 } 166 }
164 167
165 void EnrollmentScreenHandler::Show() { 168 void EnrollmentScreenHandler::Show() {
166 if (!page_is_ready()) 169 if (!page_is_ready())
167 show_on_init_ = true; 170 show_on_init_ = true;
168 else 171 else
169 DoShow(); 172 DoShow();
170 } 173 }
171 174
172 void EnrollmentScreenHandler::Hide() { 175 void EnrollmentScreenHandler::Hide() {
173 } 176 }
174 177
175 void EnrollmentScreenHandler::ShowSigninScreen() { 178 void EnrollmentScreenHandler::ShowSigninScreen() {
176 observe_network_failure_ = true; 179 observe_network_failure_ = true;
177 ShowStep(kEnrollmentStepSignin); 180 ShowStep(kEnrollmentStepSignin);
178 } 181 }
179 182
183 void EnrollmentScreenHandler::ShowLicenseTypeSelectionScreen(
184 const base::DictionaryValue& license_types) {
185 CallJS("setAvailableLicenseTypes", license_types);
186 ShowStep(kEnrollmentStepPickLicense);
187 }
188
180 void EnrollmentScreenHandler::ShowAdJoin() { 189 void EnrollmentScreenHandler::ShowAdJoin() {
181 observe_network_failure_ = false; 190 observe_network_failure_ = false;
182 if (!authpolicy_login_helper_) 191 if (!authpolicy_login_helper_)
183 authpolicy_login_helper_ = base::MakeUnique<AuthPolicyLoginHelper>(); 192 authpolicy_login_helper_ = base::MakeUnique<AuthPolicyLoginHelper>();
184 ShowStep(kEnrollmentStepAdJoin); 193 ShowStep(kEnrollmentStepAdJoin);
185 } 194 }
186 195
187 void EnrollmentScreenHandler::ShowAttributePromptScreen( 196 void EnrollmentScreenHandler::ShowAttributePromptScreen(
188 const std::string& asset_id, 197 const std::string& asset_id,
189 const std::string& location) { 198 const std::string& location) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 false); 360 false);
352 return; 361 return;
353 case policy::EnrollmentStatus::ACTIVE_DIRECTORY_POLICY_FETCH_FAILED: 362 case policy::EnrollmentStatus::ACTIVE_DIRECTORY_POLICY_FETCH_FAILED:
354 ShowError(IDS_ENTERPRISE_ENROLLMENT_ERROR_ACTIVE_DIRECTORY_POLICY_FETCH, 363 ShowError(IDS_ENTERPRISE_ENROLLMENT_ERROR_ACTIVE_DIRECTORY_POLICY_FETCH,
355 false); 364 false);
356 return; 365 return;
357 case policy::EnrollmentStatus::DM_TOKEN_STORE_FAILED: 366 case policy::EnrollmentStatus::DM_TOKEN_STORE_FAILED:
358 ShowError(IDS_ENTERPRISE_ENROLLMENT_ERROR_SAVE_DEVICE_CONFIGURATION, 367 ShowError(IDS_ENTERPRISE_ENROLLMENT_ERROR_SAVE_DEVICE_CONFIGURATION,
359 false); 368 false);
360 return; 369 return;
370 case policy::EnrollmentStatus::LICENSE_REQUEST_FAILED:
371 ShowError(IDS_ENTERPRISE_ENROLLMENT_ERROR_LICENSE_REQUEST, false);
372 return;
361 } 373 }
362 NOTREACHED(); 374 NOTREACHED();
363 } 375 }
364 376
365 // EnrollmentScreenHandler BaseScreenHandler implementation ----- 377 // EnrollmentScreenHandler BaseScreenHandler implementation -----
366 378
367 void EnrollmentScreenHandler::Initialize() { 379 void EnrollmentScreenHandler::Initialize() {
368 if (show_on_init_) { 380 if (show_on_init_) {
369 Show(); 381 Show();
370 show_on_init_ = false; 382 show_on_init_ = false;
(...skipping 26 matching lines...) Expand all
397 builder->Add("oauthEnrollAdMachineNameInput", 409 builder->Add("oauthEnrollAdMachineNameInput",
398 IDS_AD_MACHINE_NAME_INPUT_LABEL); 410 IDS_AD_MACHINE_NAME_INPUT_LABEL);
399 builder->Add("oauthEnrollAdDomainJoinWelcomeMessage", 411 builder->Add("oauthEnrollAdDomainJoinWelcomeMessage",
400 IDS_AD_DOMAIN_JOIN_WELCOME_MESSAGE); 412 IDS_AD_DOMAIN_JOIN_WELCOME_MESSAGE);
401 builder->Add("adEnrollmentLoginUsername", IDS_AD_ENROLLMENT_LOGIN_USER); 413 builder->Add("adEnrollmentLoginUsername", IDS_AD_ENROLLMENT_LOGIN_USER);
402 builder->Add("adLoginInvalidUsername", IDS_AD_INVALID_USERNAME); 414 builder->Add("adLoginInvalidUsername", IDS_AD_INVALID_USERNAME);
403 builder->Add("adLoginPassword", IDS_AD_LOGIN_PASSWORD); 415 builder->Add("adLoginPassword", IDS_AD_LOGIN_PASSWORD);
404 builder->Add("adLoginInvalidPassword", IDS_AD_INVALID_PASSWORD); 416 builder->Add("adLoginInvalidPassword", IDS_AD_INVALID_PASSWORD);
405 builder->Add("adJoinErrorMachineNameInvalid", IDS_AD_MACHINENAME_INVALID); 417 builder->Add("adJoinErrorMachineNameInvalid", IDS_AD_MACHINENAME_INVALID);
406 builder->Add("adJoinErrorMachineNameTooLong", IDS_AD_MACHINENAME_TOO_LONG); 418 builder->Add("adJoinErrorMachineNameTooLong", IDS_AD_MACHINENAME_TOO_LONG);
419 builder->Add("licenseSelectionCardTitle",
420 IDS_ENTERPRISE_ENROLLMENT_LICENSE_SELECTION);
421 builder->Add("licenseSelectionCardExplanation",
422 IDS_ENTERPRISE_ENROLLMENT_LICENSE_SELECTION_EXPLANATION);
423 builder->Add("perpetualLicenseTypeTitle",
424 IDS_ENTERPRISE_ENROLLMENT_PERPETUAL_LICENSE_TYPE);
425 builder->Add("annualLicenseTypeTitle",
426 IDS_ENTERPRISE_ENROLLMENT_ANNUAL_LICENSE_TYPE);
427 builder->Add("kioskLicenseTypeTitle",
428 IDS_ENTERPRISE_ENROLLMENT_KIOSK_LICENSE_TYPE);
429 builder->Add("licenseCountTemplate",
430 IDS_ENTERPRISE_ENROLLMENT_LICENSES_REMAINING_TEMPLATE);
407 } 431 }
408 432
409 bool EnrollmentScreenHandler::IsOnEnrollmentScreen() const { 433 bool EnrollmentScreenHandler::IsOnEnrollmentScreen() const {
410 return (GetCurrentScreen() == kScreenId); 434 return (GetCurrentScreen() == kScreenId);
411 } 435 }
412 436
413 bool EnrollmentScreenHandler::IsEnrollmentScreenHiddenByError() const { 437 bool EnrollmentScreenHandler::IsEnrollmentScreenHiddenByError() const {
414 return (GetCurrentScreen() == OobeScreen::SCREEN_ERROR_MESSAGE && 438 return (GetCurrentScreen() == OobeScreen::SCREEN_ERROR_MESSAGE &&
415 error_screen_->GetParentScreen() == kScreenId); 439 error_screen_->GetParentScreen() == kScreenId);
416 } 440 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 const std::string& location) { 636 const std::string& location) {
613 controller_->OnDeviceAttributeProvided(asset_id, location); 637 controller_->OnDeviceAttributeProvided(asset_id, location);
614 } 638 }
615 639
616 void EnrollmentScreenHandler::HandleOnLearnMore() { 640 void EnrollmentScreenHandler::HandleOnLearnMore() {
617 if (!help_app_.get()) 641 if (!help_app_.get())
618 help_app_ = new HelpAppLauncher(GetNativeWindow()); 642 help_app_ = new HelpAppLauncher(GetNativeWindow());
619 help_app_->ShowHelpTopic(HelpAppLauncher::HELP_DEVICE_ATTRIBUTES); 643 help_app_->ShowHelpTopic(HelpAppLauncher::HELP_DEVICE_ATTRIBUTES);
620 } 644 }
621 645
646 void EnrollmentScreenHandler::HandleLicenseTypeSelected(
647 const std::string& licenseType) {
648 controller_->OnLicenseTypeSelected(licenseType);
649 }
650
622 void EnrollmentScreenHandler::ShowStep(const char* step) { 651 void EnrollmentScreenHandler::ShowStep(const char* step) {
623 CallJS("showStep", std::string(step)); 652 CallJS("showStep", std::string(step));
624 } 653 }
625 654
626 void EnrollmentScreenHandler::ShowError(int message_id, bool retry) { 655 void EnrollmentScreenHandler::ShowError(int message_id, bool retry) {
627 ShowErrorMessage(l10n_util::GetStringUTF8(message_id), retry); 656 ShowErrorMessage(l10n_util::GetStringUTF8(message_id), retry);
628 } 657 }
629 658
630 void EnrollmentScreenHandler::ShowErrorForDevice(int message_id, bool retry) { 659 void EnrollmentScreenHandler::ShowErrorForDevice(int message_id, bool retry) {
631 ShowErrorMessage( 660 ShowErrorMessage(
(...skipping 25 matching lines...) Expand all
657 686
658 ShowScreenWithData(OobeScreen::SCREEN_OOBE_ENROLLMENT, &screen_data); 687 ShowScreenWithData(OobeScreen::SCREEN_OOBE_ENROLLMENT, &screen_data);
659 if (first_show_) { 688 if (first_show_) {
660 first_show_ = false; 689 first_show_ = false;
661 UpdateStateInternal(NetworkError::ERROR_REASON_UPDATE, true); 690 UpdateStateInternal(NetworkError::ERROR_REASON_UPDATE, true);
662 } 691 }
663 histogram_helper_->OnScreenShow(); 692 histogram_helper_->OnScreenShow();
664 } 693 }
665 694
666 } // namespace chromeos 695 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698