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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 10918027: Revert 154457 - Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
Property Changes:
Deleted: svn:mergeinfo
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/chromeos/login/existing_user_controller.h" 5 #include "chrome/browser/chromeos/login/existing_user_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (type == chrome::NOTIFICATION_SESSION_STARTED) { 222 if (type == chrome::NOTIFICATION_SESSION_STARTED) {
223 // Stop listening to any notification once session has started. 223 // Stop listening to any notification once session has started.
224 // Sign in screen objects are marked for deletion with DeleteSoon so 224 // Sign in screen objects are marked for deletion with DeleteSoon so
225 // make sure no object would be used after session has started. 225 // make sure no object would be used after session has started.
226 // http://crbug.com/125276 226 // http://crbug.com/125276
227 registrar_.RemoveAll(); 227 registrar_.RemoveAll();
228 return; 228 return;
229 } 229 }
230 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || 230 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED ||
231 type == chrome::NOTIFICATION_POLICY_USER_LIST_CHANGED) { 231 type == chrome::NOTIFICATION_POLICY_USER_LIST_CHANGED) {
232 if (host_ != NULL) { 232 // Signed settings or user list changed. Notify views and update them.
233 // Signed settings or user list changed. Notify views and update them. 233 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers();
234 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); 234 UpdateLoginDisplay(users);
235 return; 235 return;
236 }
237 } 236 }
238 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { 237 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) {
239 // Possibly the user has authenticated against a proxy server and we might 238 // Possibly the user has authenticated against a proxy server and we might
240 // need the credentials for enrollment and other system requests from the 239 // need the credentials for enrollment and other system requests from the
241 // main |g_browser_process| request context (see bug 240 // main |g_browser_process| request context (see bug
242 // http://crosbug.com/24861). So we transfer any credentials to the global 241 // http://crosbug.com/24861). So we transfer any credentials to the global
243 // request context here. 242 // request context here.
244 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent 243 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent
245 // just after the UI is closed but before the new credentials were stored 244 // just after the UI is closed but before the new credentials were stored
246 // in the profile. Therefore we have to give it some time to make sure it 245 // in the profile. Therefore we have to give it some time to make sure it
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 ShowEnrollmentScreen(true, username); 332 ShowEnrollmentScreen(true, username);
334 } else { 333 } else {
335 CompleteLoginInternal(username, password); 334 CompleteLoginInternal(username, password);
336 } 335 }
337 } 336 }
338 337
339 void ExistingUserController::CompleteLoginInternal(std::string username, 338 void ExistingUserController::CompleteLoginInternal(std::string username,
340 std::string password) { 339 std::string password) {
341 resume_login_callback_.Reset(); 340 resume_login_callback_.Reset();
342 341
343 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 342 if (!login_performer_.get()) {
344 base::Bind(&ExistingUserController::PerformLogin, 343 LoginPerformer::Delegate* delegate = this;
345 weak_factory_.GetWeakPtr(), username, password, 344 if (login_performer_delegate_.get())
346 LoginPerformer::AUTH_MODE_EXTENSION)); 345 delegate = login_performer_delegate_.get();
346 // Only one instance of LoginPerformer should exist at a time.
347 login_performer_.reset(new LoginPerformer(delegate));
348 }
349
350 // If the device is not owned yet, successfully logged in user will be owner.
351 is_owner_login_ = OwnershipService::GetSharedInstance()->GetStatus(true) ==
352 OwnershipService::OWNERSHIP_NONE;
353
354 is_login_in_progress_ = true;
355 login_performer_->CompleteLogin(username, password);
356 accessibility::MaybeSpeak(
357 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
347 } 358 }
348 359
349 void ExistingUserController::Login(const std::string& username, 360 void ExistingUserController::Login(const std::string& username,
350 const std::string& password) { 361 const std::string& password) {
351 if (username.empty() || password.empty()) 362 if (username.empty() || password.empty())
352 return; 363 return;
353 // Disable clicking on other windows. 364 // Disable clicking on other windows.
354 login_display_->SetUIEnabled(false); 365 login_display_->SetUIEnabled(false);
355 366
367 // If the device is not owned yet, successfully logged in user will be owner.
368 is_owner_login_ = OwnershipService::GetSharedInstance()->GetStatus(true) ==
369 OwnershipService::OWNERSHIP_NONE;
370
356 BootTimesLoader::Get()->RecordLoginAttempted(); 371 BootTimesLoader::Get()->RecordLoginAttempted();
357 372
358 if (last_login_attempt_username_ != username) { 373 if (last_login_attempt_username_ != username) {
359 last_login_attempt_username_ = username; 374 last_login_attempt_username_ = username;
360 num_login_attempts_ = 0; 375 num_login_attempts_ = 0;
361 // Also reset state variables, which are used to determine password change. 376 // Also reset state variables, which are used to determine password change.
362 offline_failed_ = false; 377 offline_failed_ = false;
363 online_succeeded_for_.clear(); 378 online_succeeded_for_.clear();
364 } 379 }
365 num_login_attempts_++; 380 num_login_attempts_++;
366 381
367 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
368 base::Bind(&ExistingUserController::PerformLogin,
369 weak_factory_.GetWeakPtr(), username, password,
370 LoginPerformer::AUTH_MODE_INTERNAL));
371 }
372
373 void ExistingUserController::PerformLogin(
374 const std::string& username,
375 const std::string& password,
376 LoginPerformer::AuthorizationMode auth_mode,
377 DeviceSettingsService::OwnershipStatus ownership_status,
378 bool is_owner) {
379 // If the device is not owned yet, successfully logged in user will be owner.
380 is_owner_login_ = ownership_status == DeviceSettingsService::OWNERSHIP_NONE;
381
382 // Use the same LoginPerformer for subsequent login as it has state 382 // Use the same LoginPerformer for subsequent login as it has state
383 // such as Authenticator instance. 383 // such as Authenticator instance.
384 if (!login_performer_.get() || num_login_attempts_ <= 1) { 384 if (!login_performer_.get() || num_login_attempts_ <= 1) {
385 LoginPerformer::Delegate* delegate = this; 385 LoginPerformer::Delegate* delegate = this;
386 if (login_performer_delegate_.get()) 386 if (login_performer_delegate_.get())
387 delegate = login_performer_delegate_.get(); 387 delegate = login_performer_delegate_.get();
388 // Only one instance of LoginPerformer should exist at a time. 388 // Only one instance of LoginPerformer should exist at a time.
389 login_performer_.reset(NULL); 389 login_performer_.reset(NULL);
390 login_performer_.reset(new LoginPerformer(delegate)); 390 login_performer_.reset(new LoginPerformer(delegate));
391 } 391 }
392
393 is_login_in_progress_ = true; 392 is_login_in_progress_ = true;
394 login_performer_->PerformLogin(username, password, auth_mode); 393 login_performer_->Login(username, password);
395 accessibility::MaybeSpeak( 394 accessibility::MaybeSpeak(
396 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 395 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
397 } 396 }
398 397
399 void ExistingUserController::LoginAsDemoUser() { 398 void ExistingUserController::LoginAsDemoUser() {
400 // Disable clicking on other windows. 399 // Disable clicking on other windows.
401 login_display_->SetUIEnabled(false); 400 login_display_->SetUIEnabled(false);
402 // TODO(rkc): Add a CHECK to make sure demo logins are allowed once 401 // TODO(rkc): Add a CHECK to make sure demo logins are allowed once
403 // the enterprise policy wiring is done for kiosk mode. 402 // the enterprise policy wiring is done for kiosk mode.
404 403
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 void ExistingUserController::Signout() { 458 void ExistingUserController::Signout() {
460 NOTREACHED(); 459 NOTREACHED();
461 } 460 }
462 461
463 void ExistingUserController::OnUserSelected(const std::string& username) { 462 void ExistingUserController::OnUserSelected(const std::string& username) {
464 login_performer_.reset(NULL); 463 login_performer_.reset(NULL);
465 num_login_attempts_ = 0; 464 num_login_attempts_ = 0;
466 } 465 }
467 466
468 void ExistingUserController::OnStartEnterpriseEnrollment() { 467 void ExistingUserController::OnStartEnterpriseEnrollment() {
469 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 468 OwnershipService::GetSharedInstance()->GetStatusAsync(
470 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, 469 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
471 weak_factory_.GetWeakPtr())); 470 weak_factory_.GetWeakPtr()));
472 } 471 }
473 472
474 void ExistingUserController::OnEnrollmentOwnershipCheckCompleted( 473 void ExistingUserController::OnEnrollmentOwnershipCheckCompleted(
475 DeviceSettingsService::OwnershipStatus status, 474 OwnershipService::Status status,
476 bool current_user_is_owner) { 475 bool current_user_is_owner) {
477 if (status == DeviceSettingsService::OWNERSHIP_NONE) { 476 if (status == OwnershipService::OWNERSHIP_NONE) {
478 ShowEnrollmentScreen(false, std::string()); 477 ShowEnrollmentScreen(false, std::string());
479 } else if (status == DeviceSettingsService::OWNERSHIP_TAKEN) { 478 } else if (status == OwnershipService::OWNERSHIP_TAKEN) {
480 // On a device that is already owned we might want to allow users to 479 // On a device that is already owned we might want to allow users to
481 // re-enroll if the policy information is invalid. 480 // re-enroll if the policy information is invalid.
482 CrosSettingsProvider::TrustedStatus trusted_status = 481 CrosSettingsProvider::TrustedStatus trusted_status =
483 CrosSettings::Get()->PrepareTrustedValues( 482 CrosSettings::Get()->PrepareTrustedValues(
484 base::Bind( 483 base::Bind(
485 &ExistingUserController::OnEnrollmentOwnershipCheckCompleted, 484 &ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
486 weak_factory_.GetWeakPtr(), status, current_user_is_owner)); 485 weak_factory_.GetWeakPtr(), status, current_user_is_owner));
487 if (trusted_status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) 486 if (trusted_status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED)
488 ShowEnrollmentScreen(false, std::string()); 487 ShowEnrollmentScreen(false, std::string());
489 } else { 488 } else {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 // Invalidate OAuth token, since it can't be correct after password is 921 // Invalidate OAuth token, since it can't be correct after password is
923 // changed. 922 // changed.
924 UserManager::Get()->SaveUserOAuthStatus(username, 923 UserManager::Get()->SaveUserOAuthStatus(username,
925 User::OAUTH_TOKEN_STATUS_INVALID); 924 User::OAUTH_TOKEN_STATUS_INVALID);
926 925
927 login_display_->SetUIEnabled(true); 926 login_display_->SetUIEnabled(true);
928 login_display_->ShowGaiaPasswordChanged(username); 927 login_display_->ShowGaiaPasswordChanged(username);
929 } 928 }
930 929
931 } // namespace chromeos 930 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.h ('k') | chrome/browser/chromeos/login/language_switch_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698