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

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

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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
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 // Signed settings or user list changed. Notify views and update them. 232 if (host_ != NULL) {
233 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers(); 233 // Signed settings or user list changed. Notify views and update them.
234 UpdateLoginDisplay(users); 234 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers());
235 return; 235 return;
236 }
236 } 237 }
237 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { 238 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) {
238 // Possibly the user has authenticated against a proxy server and we might 239 // Possibly the user has authenticated against a proxy server and we might
239 // need the credentials for enrollment and other system requests from the 240 // need the credentials for enrollment and other system requests from the
240 // main |g_browser_process| request context (see bug 241 // main |g_browser_process| request context (see bug
241 // http://crosbug.com/24861). So we transfer any credentials to the global 242 // http://crosbug.com/24861). So we transfer any credentials to the global
242 // request context here. 243 // request context here.
243 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent 244 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent
244 // just after the UI is closed but before the new credentials were stored 245 // just after the UI is closed but before the new credentials were stored
245 // in the profile. Therefore we have to give it some time to make sure it 246 // 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
332 ShowEnrollmentScreen(true, username); 333 ShowEnrollmentScreen(true, username);
333 } else { 334 } else {
334 CompleteLoginInternal(username, password); 335 CompleteLoginInternal(username, password);
335 } 336 }
336 } 337 }
337 338
338 void ExistingUserController::CompleteLoginInternal(std::string username, 339 void ExistingUserController::CompleteLoginInternal(std::string username,
339 std::string password) { 340 std::string password) {
340 resume_login_callback_.Reset(); 341 resume_login_callback_.Reset();
341 342
342 if (!login_performer_.get()) { 343 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
343 LoginPerformer::Delegate* delegate = this; 344 base::Bind(&ExistingUserController::PerformLogin,
344 if (login_performer_delegate_.get()) 345 weak_factory_.GetWeakPtr(), username, password,
345 delegate = login_performer_delegate_.get(); 346 LoginPerformer::AUTH_MODE_EXTENSION));
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));
358 } 347 }
359 348
360 void ExistingUserController::Login(const std::string& username, 349 void ExistingUserController::Login(const std::string& username,
361 const std::string& password) { 350 const std::string& password) {
362 if (username.empty() || password.empty()) 351 if (username.empty() || password.empty())
363 return; 352 return;
364 // Disable clicking on other windows. 353 // Disable clicking on other windows.
365 login_display_->SetUIEnabled(false); 354 login_display_->SetUIEnabled(false);
366 355
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
371 BootTimesLoader::Get()->RecordLoginAttempted(); 356 BootTimesLoader::Get()->RecordLoginAttempted();
372 357
373 if (last_login_attempt_username_ != username) { 358 if (last_login_attempt_username_ != username) {
374 last_login_attempt_username_ = username; 359 last_login_attempt_username_ = username;
375 num_login_attempts_ = 0; 360 num_login_attempts_ = 0;
376 // Also reset state variables, which are used to determine password change. 361 // Also reset state variables, which are used to determine password change.
377 offline_failed_ = false; 362 offline_failed_ = false;
378 online_succeeded_for_.clear(); 363 online_succeeded_for_.clear();
379 } 364 }
380 num_login_attempts_++; 365 num_login_attempts_++;
381 366
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
392 is_login_in_progress_ = true; 393 is_login_in_progress_ = true;
393 login_performer_->Login(username, password); 394 login_performer_->PerformLogin(username, password, auth_mode);
394 accessibility::MaybeSpeak( 395 accessibility::MaybeSpeak(
395 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 396 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
396 } 397 }
397 398
398 void ExistingUserController::LoginAsDemoUser() { 399 void ExistingUserController::LoginAsDemoUser() {
399 // Disable clicking on other windows. 400 // Disable clicking on other windows.
400 login_display_->SetUIEnabled(false); 401 login_display_->SetUIEnabled(false);
401 // TODO(rkc): Add a CHECK to make sure demo logins are allowed once 402 // TODO(rkc): Add a CHECK to make sure demo logins are allowed once
402 // the enterprise policy wiring is done for kiosk mode. 403 // the enterprise policy wiring is done for kiosk mode.
403 404
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 void ExistingUserController::Signout() { 459 void ExistingUserController::Signout() {
459 NOTREACHED(); 460 NOTREACHED();
460 } 461 }
461 462
462 void ExistingUserController::OnUserSelected(const std::string& username) { 463 void ExistingUserController::OnUserSelected(const std::string& username) {
463 login_performer_.reset(NULL); 464 login_performer_.reset(NULL);
464 num_login_attempts_ = 0; 465 num_login_attempts_ = 0;
465 } 466 }
466 467
467 void ExistingUserController::OnStartEnterpriseEnrollment() { 468 void ExistingUserController::OnStartEnterpriseEnrollment() {
468 OwnershipService::GetSharedInstance()->GetStatusAsync( 469 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
469 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, 470 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
470 weak_factory_.GetWeakPtr())); 471 weak_factory_.GetWeakPtr()));
471 } 472 }
472 473
473 void ExistingUserController::OnEnrollmentOwnershipCheckCompleted( 474 void ExistingUserController::OnEnrollmentOwnershipCheckCompleted(
474 OwnershipService::Status status, 475 DeviceSettingsService::OwnershipStatus status,
475 bool current_user_is_owner) { 476 bool current_user_is_owner) {
476 if (status == OwnershipService::OWNERSHIP_NONE) { 477 if (status == DeviceSettingsService::OWNERSHIP_NONE) {
477 ShowEnrollmentScreen(false, std::string()); 478 ShowEnrollmentScreen(false, std::string());
478 } else if (status == OwnershipService::OWNERSHIP_TAKEN) { 479 } else if (status == DeviceSettingsService::OWNERSHIP_TAKEN) {
479 // On a device that is already owned we might want to allow users to 480 // On a device that is already owned we might want to allow users to
480 // re-enroll if the policy information is invalid. 481 // re-enroll if the policy information is invalid.
481 CrosSettingsProvider::TrustedStatus trusted_status = 482 CrosSettingsProvider::TrustedStatus trusted_status =
482 CrosSettings::Get()->PrepareTrustedValues( 483 CrosSettings::Get()->PrepareTrustedValues(
483 base::Bind( 484 base::Bind(
484 &ExistingUserController::OnEnrollmentOwnershipCheckCompleted, 485 &ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
485 weak_factory_.GetWeakPtr(), status, current_user_is_owner)); 486 weak_factory_.GetWeakPtr(), status, current_user_is_owner));
486 if (trusted_status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) 487 if (trusted_status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED)
487 ShowEnrollmentScreen(false, std::string()); 488 ShowEnrollmentScreen(false, std::string());
488 } else { 489 } else {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 // Invalidate OAuth token, since it can't be correct after password is 922 // Invalidate OAuth token, since it can't be correct after password is
922 // changed. 923 // changed.
923 UserManager::Get()->SaveUserOAuthStatus(username, 924 UserManager::Get()->SaveUserOAuthStatus(username,
924 User::OAUTH_TOKEN_STATUS_INVALID); 925 User::OAUTH_TOKEN_STATUS_INVALID);
925 926
926 login_display_->SetUIEnabled(true); 927 login_display_->SetUIEnabled(true);
927 login_display_->ShowGaiaPasswordChanged(username); 928 login_display_->ShowGaiaPasswordChanged(username);
928 } 929 }
929 930
930 } // namespace chromeos 931 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698