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

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

Issue 426153003: Consumer management enrollment signin screen change: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added owner email check. Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/gaia_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 18 matching lines...) Expand all
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 30
31 using content::BrowserThread; 31 using content::BrowserThread;
32 32
33 namespace chromeos { 33 namespace chromeos {
34 34
35 namespace { 35 namespace {
36 36
37 const char kJsScreenPath[] = "login.GaiaSigninScreen"; 37 const char kJsScreenPath[] = "login.GaiaSigninScreen";
38 38
39 void UpdateAuthParams(base::DictionaryValue* params, bool has_users) { 39 void UpdateAuthParams(base::DictionaryValue* params, bool has_users,
bartfab (slow) 2014/08/04 17:40:52 Nit: Per the style guide, either put all arguments
davidyu 2014/08/05 07:24:05 Done.
40 bool is_enrolling_consumer_management) {
40 CrosSettings* cros_settings = CrosSettings::Get(); 41 CrosSettings* cros_settings = CrosSettings::Get();
41 bool allow_new_user = true; 42 bool allow_new_user = true;
42 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 43 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
43 bool allow_guest = true; 44 bool allow_guest = true;
44 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); 45 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
45 // Account creation depends on Guest sign-in (http://crosbug.com/24570). 46 // Account creation depends on Guest sign-in (http://crosbug.com/24570).
46 params->SetBoolean("createAccount", allow_new_user && allow_guest); 47 params->SetBoolean("createAccount", allow_new_user && allow_guest);
47 params->SetBoolean("guestSignin", allow_guest); 48 params->SetBoolean("guestSignin", allow_guest);
48 49
49 // Allow supervised user creation only if: 50 // Allow supervised user creation only if:
(...skipping 16 matching lines...) Expand all
66 67
67 params->SetBoolean("supervisedUsersEnabled", supervised_users_allowed); 68 params->SetBoolean("supervisedUsersEnabled", supervised_users_allowed);
68 params->SetBoolean("supervisedUsersCanCreate", supervised_users_can_create); 69 params->SetBoolean("supervisedUsersCanCreate", supervised_users_can_create);
69 if (!supervised_users_can_create) { 70 if (!supervised_users_can_create) {
70 params->SetString("supervisedUsersRestrictionReason", 71 params->SetString("supervisedUsersRestrictionReason",
71 l10n_util::GetStringUTF16(message_id)); 72 l10n_util::GetStringUTF16(message_id));
72 } 73 }
73 74
74 // Now check whether we're in multi-profiles user adding scenario and 75 // Now check whether we're in multi-profiles user adding scenario and
75 // disable GAIA right panel features if that's the case. 76 // disable GAIA right panel features if that's the case.
76 if (UserAddingScreen::Get()->IsRunning()) { 77 // For consumer management enrollment, we also hide all right panel components
78 // and show only an enrollment message.
79 if (UserAddingScreen::Get()->IsRunning() ||
80 is_enrolling_consumer_management) {
77 params->SetBoolean("createAccount", false); 81 params->SetBoolean("createAccount", false);
78 params->SetBoolean("guestSignin", false); 82 params->SetBoolean("guestSignin", false);
79 params->SetBoolean("supervisedUsersEnabled", false); 83 params->SetBoolean("supervisedUsersEnabled", false);
80 } 84 }
81 } 85 }
82 86
83 void RecordSAMLScrapingVerificationResultInHistogram(bool success) { 87 void RecordSAMLScrapingVerificationResultInHistogram(bool success) {
84 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success); 88 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success);
85 } 89 }
86 90
(...skipping 22 matching lines...) Expand all
109 : BaseScreenHandler(kJsScreenPath), 113 : BaseScreenHandler(kJsScreenPath),
110 frame_state_(FRAME_STATE_UNKNOWN), 114 frame_state_(FRAME_STATE_UNKNOWN),
111 frame_error_(net::OK), 115 frame_error_(net::OK),
112 network_state_informer_(network_state_informer), 116 network_state_informer_(network_state_informer),
113 dns_cleared_(false), 117 dns_cleared_(false),
114 dns_clear_task_running_(false), 118 dns_clear_task_running_(false),
115 cookies_cleared_(false), 119 cookies_cleared_(false),
116 focus_stolen_(false), 120 focus_stolen_(false),
117 gaia_silent_load_(false), 121 gaia_silent_load_(false),
118 using_saml_api_(false), 122 using_saml_api_(false),
123 is_enrolling_consumer_management_(false),
119 test_expects_complete_login_(false), 124 test_expects_complete_login_(false),
120 signin_screen_handler_(NULL), 125 signin_screen_handler_(NULL),
121 weak_factory_(this) { 126 weak_factory_(this) {
122 DCHECK(network_state_informer_.get()); 127 DCHECK(network_state_informer_.get());
123 } 128 }
124 129
125 GaiaScreenHandler::~GaiaScreenHandler() { 130 GaiaScreenHandler::~GaiaScreenHandler() {
126 } 131 }
127 132
128 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { 133 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) {
129 base::DictionaryValue params; 134 base::DictionaryValue params;
130 135
131 params.SetBoolean("forceReload", context.force_reload); 136 params.SetBoolean("forceReload", context.force_reload);
132 params.SetBoolean("isLocal", context.is_local); 137 params.SetBoolean("isLocal", context.is_local);
133 params.SetBoolean("passwordChanged", context.password_changed); 138 params.SetBoolean("passwordChanged", context.password_changed);
134 params.SetBoolean("isShowUsers", context.show_users); 139 params.SetBoolean("isShowUsers", context.show_users);
135 params.SetBoolean("useOffline", context.use_offline); 140 params.SetBoolean("useOffline", context.use_offline);
136 params.SetString("email", context.email); 141 params.SetString("email", context.email);
142 params.SetBoolean("isEnrollingConsumerManagement",
143 context.is_enrolling_consumer_management);
137 144
138 UpdateAuthParams(&params, context.has_users); 145 UpdateAuthParams(&params, context.has_users,
146 context.is_enrolling_consumer_management);
bartfab (slow) 2014/08/04 17:40:52 Nit: You use |context.is_enrolling_consumer_manage
davidyu 2014/08/05 07:24:05 Done.
139 147
140 if (!context.use_offline) { 148 if (!context.use_offline) {
141 const std::string app_locale = g_browser_process->GetApplicationLocale(); 149 const std::string app_locale = g_browser_process->GetApplicationLocale();
142 if (!app_locale.empty()) 150 if (!app_locale.empty())
143 params.SetString("hl", app_locale); 151 params.SetString("hl", app_locale);
144 } else { 152 } else {
145 base::DictionaryValue* localized_strings = new base::DictionaryValue(); 153 base::DictionaryValue* localized_strings = new base::DictionaryValue();
146 localized_strings->SetString( 154 localized_strings->SetString(
147 "stringEmail", l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_EMAIL)); 155 "stringEmail", l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_EMAIL));
148 localized_strings->SetString( 156 localized_strings->SetString(
(...skipping 22 matching lines...) Expand all
171 179
172 if (command_line->HasSwitch(chromeos::switches::kEnableEmbeddedSignin)) 180 if (command_line->HasSwitch(chromeos::switches::kEnableEmbeddedSignin))
173 params.SetBoolean("useEmbedded", true); 181 params.SetBoolean("useEmbedded", true);
174 182
175 frame_state_ = FRAME_STATE_LOADING; 183 frame_state_ = FRAME_STATE_LOADING;
176 CallJS("loadAuthExtension", params); 184 CallJS("loadAuthExtension", params);
177 } 185 }
178 186
179 void GaiaScreenHandler::UpdateGaia(const GaiaContext& context) { 187 void GaiaScreenHandler::UpdateGaia(const GaiaContext& context) {
180 base::DictionaryValue params; 188 base::DictionaryValue params;
181 UpdateAuthParams(&params, context.has_users); 189 UpdateAuthParams(&params, context.has_users,
190 context.is_enrolling_consumer_management);
182 CallJS("updateAuthExtension", params); 191 CallJS("updateAuthExtension", params);
183 } 192 }
184 193
185 void GaiaScreenHandler::ReloadGaia(bool force_reload) { 194 void GaiaScreenHandler::ReloadGaia(bool force_reload) {
186 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) { 195 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) {
187 VLOG(1) << "Skipping reloading of Gaia since gaia is loading."; 196 VLOG(1) << "Skipping reloading of Gaia since gaia is loading.";
188 return; 197 return;
189 } 198 }
190 NetworkStateInformer::State state = network_state_informer_->state(); 199 NetworkStateInformer::State state = network_state_informer_->state();
191 if (state != NetworkStateInformer::ONLINE) { 200 if (state != NetworkStateInformer::ONLINE) {
(...skipping 10 matching lines...) Expand all
202 LocalizedValuesBuilder* builder) { 211 LocalizedValuesBuilder* builder) {
203 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE); 212 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE);
204 builder->Add("signinScreenPasswordChanged", 213 builder->Add("signinScreenPasswordChanged",
205 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED); 214 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED);
206 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); 215 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML);
207 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); 216 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML);
208 builder->Add("createSupervisedUser", 217 builder->Add("createSupervisedUser",
209 IDS_CREATE_LOCALLY_MANAGED_USER_HTML); 218 IDS_CREATE_LOCALLY_MANAGED_USER_HTML);
210 builder->Add("createSupervisedUserFeatureName", 219 builder->Add("createSupervisedUserFeatureName",
211 IDS_CREATE_LOCALLY_MANAGED_USER_FEATURE_NAME); 220 IDS_CREATE_LOCALLY_MANAGED_USER_FEATURE_NAME);
221 builder->Add("consumerManagementEnrollmentSigninMessage",
222 IDS_LOGIN_CONSUMER_MANAGEMENT_ENROLLMENT);
212 223
213 // Strings used by the SAML fatal error dialog. 224 // Strings used by the SAML fatal error dialog.
214 builder->Add("fatalErrorMessageNoEmail", IDS_LOGIN_FATAL_ERROR_NO_EMAIL); 225 builder->Add("fatalErrorMessageNoEmail", IDS_LOGIN_FATAL_ERROR_NO_EMAIL);
215 builder->Add("fatalErrorMessageNoPassword", 226 builder->Add("fatalErrorMessageNoPassword",
216 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD); 227 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD);
217 builder->Add("fatalErrorMessageVerificationFailed", 228 builder->Add("fatalErrorMessageVerificationFailed",
218 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION); 229 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION);
219 builder->Add("fatalErrorMessageInsecureURL", 230 builder->Add("fatalErrorMessageInsecureURL",
220 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL); 231 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL);
221 builder->Add("fatalErrorInstructions", IDS_LOGIN_FATAL_ERROR_INSTRUCTIONS); 232 builder->Add("fatalErrorInstructions", IDS_LOGIN_FATAL_ERROR_INSTRUCTIONS);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 Delegate()->SetDisplayEmail(gaia::SanitizeEmail(email)); 282 Delegate()->SetDisplayEmail(gaia::SanitizeEmail(email));
272 UserContext user_context(email); 283 UserContext user_context(email);
273 user_context.SetKey(Key(password)); 284 user_context.SetKey(Key(password));
274 user_context.SetAuthCode(auth_code); 285 user_context.SetAuthCode(auth_code);
275 Delegate()->CompleteLogin(user_context); 286 Delegate()->CompleteLogin(user_context);
276 } 287 }
277 288
278 void GaiaScreenHandler::HandleCompleteLogin(const std::string& typed_email, 289 void GaiaScreenHandler::HandleCompleteLogin(const std::string& typed_email,
279 const std::string& password, 290 const std::string& password,
280 bool using_saml) { 291 bool using_saml) {
292 std::string owner_email = UserManager::Get()->GetOwnerEmail();
bartfab (slow) 2014/08/04 17:40:52 Nit: const.
davidyu 2014/08/05 07:24:05 Done.
293 if (is_enrolling_consumer_management_ && typed_email != owner_email) {
294 // Show Gaia signin page again since we only allow the owner to sign in.
bartfab (slow) 2014/08/04 17:40:52 Nit 1: s/signin/sign-in/ Nit 2: s/again/again, /
davidyu 2014/08/05 07:24:05 Done.
295 populated_email_ = owner_email;
296 ShowGaia(is_enrolling_consumer_management_);
297 return;
298 }
299
281 if (!Delegate()) 300 if (!Delegate())
282 return; 301 return;
283 302
284 if (using_saml && !using_saml_api_) 303 if (using_saml && !using_saml_api_)
285 RecordSAMLScrapingVerificationResultInHistogram(true); 304 RecordSAMLScrapingVerificationResultInHistogram(true);
286 305
287 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); 306 const std::string sanitized_email = gaia::SanitizeEmail(typed_email);
288 Delegate()->SetDisplayEmail(sanitized_email); 307 Delegate()->SetDisplayEmail(sanitized_email);
289 UserContext user_context(sanitized_email); 308 UserContext user_context(sanitized_email);
290 user_context.SetKey(Key(password)); 309 user_context.SetKey(Key(password));
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // Test properties are cleared in HandleCompleteLogin because the form 458 // Test properties are cleared in HandleCompleteLogin because the form
440 // submission might fail and login will not be attempted after reloading 459 // submission might fail and login will not be attempted after reloading
441 // if they are cleared here. 460 // if they are cleared here.
442 } 461 }
443 462
444 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) { 463 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) {
445 using_saml_api_ = api_used; 464 using_saml_api_ = api_used;
446 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used); 465 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used);
447 } 466 }
448 467
449 void GaiaScreenHandler::ShowGaia() { 468 void GaiaScreenHandler::ShowGaia(bool is_enrolling_consumer_management) {
469 is_enrolling_consumer_management_ = is_enrolling_consumer_management;
450 if (gaia_silent_load_ && populated_email_.empty()) { 470 if (gaia_silent_load_ && populated_email_.empty()) {
451 dns_cleared_ = true; 471 dns_cleared_ = true;
452 cookies_cleared_ = true; 472 cookies_cleared_ = true;
453 ShowGaiaScreenIfReady(); 473 ShowGaiaScreenIfReady();
454 } else { 474 } else {
455 StartClearingDnsCache(); 475 StartClearingDnsCache();
456 StartClearingCookies(base::Bind(&GaiaScreenHandler::ShowGaiaScreenIfReady, 476 StartClearingCookies(base::Bind(&GaiaScreenHandler::ShowGaiaScreenIfReady,
457 weak_factory_.GetWeakPtr())); 477 weak_factory_.GetWeakPtr()));
458 } 478 }
459 } 479 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 void GaiaScreenHandler::LoadAuthExtension(bool force, 536 void GaiaScreenHandler::LoadAuthExtension(bool force,
517 bool silent_load, 537 bool silent_load,
518 bool offline) { 538 bool offline) {
519 GaiaContext context; 539 GaiaContext context;
520 context.force_reload = force; 540 context.force_reload = force;
521 context.is_local = offline; 541 context.is_local = offline;
522 context.password_changed = !populated_email_.empty() && 542 context.password_changed = !populated_email_.empty() &&
523 password_changed_for_.count(populated_email_); 543 password_changed_for_.count(populated_email_);
524 context.use_offline = offline; 544 context.use_offline = offline;
525 context.email = populated_email_; 545 context.email = populated_email_;
546 context.is_enrolling_consumer_management = is_enrolling_consumer_management_;
526 if (Delegate()) { 547 if (Delegate()) {
527 context.show_users = Delegate()->IsShowUsers(); 548 context.show_users = Delegate()->IsShowUsers();
528 context.has_users = !Delegate()->GetUsers().empty(); 549 context.has_users = !Delegate()->GetUsers().empty();
529 } 550 }
530 551
531 populated_email_.clear(); 552 populated_email_.clear();
532 553
533 LoadGaia(context); 554 LoadGaia(context);
534 } 555 }
535 556
536 void GaiaScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) { 557 void GaiaScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) {
537 if (signin_screen_handler_) 558 if (signin_screen_handler_)
538 signin_screen_handler_->UpdateState(reason); 559 signin_screen_handler_->UpdateState(reason);
539 } 560 }
540 561
541 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { 562 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() {
542 DCHECK(signin_screen_handler_); 563 DCHECK(signin_screen_handler_);
543 return signin_screen_handler_->delegate_; 564 return signin_screen_handler_->delegate_;
544 } 565 }
545 566
546 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { 567 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) {
547 signin_screen_handler_ = handler; 568 signin_screen_handler_ = handler;
548 } 569 }
549 } // namespace chromeos 570 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698