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

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

Issue 171423009: Use MountGuest to mount cryptohome for a demo user. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 19 matching lines...) Expand all
30 #include "base/threading/worker_pool.h" 30 #include "base/threading/worker_pool.h"
31 #include "base/time/time.h" 31 #include "base/time/time.h"
32 #include "chrome/browser/about_flags.h" 32 #include "chrome/browser/about_flags.h"
33 #include "chrome/browser/app_mode/app_mode_utils.h" 33 #include "chrome/browser/app_mode/app_mode_utils.h"
34 #include "chrome/browser/browser_process.h" 34 #include "chrome/browser/browser_process.h"
35 #include "chrome/browser/browser_shutdown.h" 35 #include "chrome/browser/browser_shutdown.h"
36 #include "chrome/browser/chrome_notification_types.h" 36 #include "chrome/browser/chrome_notification_types.h"
37 #include "chrome/browser/chromeos/boot_times_loader.h" 37 #include "chrome/browser/chromeos/boot_times_loader.h"
38 #include "chrome/browser/chromeos/input_method/input_method_util.h" 38 #include "chrome/browser/chromeos/input_method/input_method_util.h"
39 #include "chrome/browser/chromeos/login/chrome_restart_request.h" 39 #include "chrome/browser/chromeos/login/chrome_restart_request.h"
40 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
40 #include "chrome/browser/chromeos/login/input_events_blocker.h" 41 #include "chrome/browser/chromeos/login/input_events_blocker.h"
41 #include "chrome/browser/chromeos/login/login_display_host.h" 42 #include "chrome/browser/chromeos/login/login_display_host.h"
42 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" 43 #include "chrome/browser/chromeos/login/oauth2_login_manager.h"
43 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h" 44 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h"
44 #include "chrome/browser/chromeos/login/parallel_authenticator.h" 45 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
45 #include "chrome/browser/chromeos/login/profile_auth_data.h" 46 #include "chrome/browser/chromeos/login/profile_auth_data.h"
46 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" 47 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
47 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h" 48 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h"
48 #include "chrome/browser/chromeos/login/screen_locker.h" 49 #include "chrome/browser/chromeos/login/screen_locker.h"
49 #include "chrome/browser/chromeos/login/supervised_user_manager.h" 50 #include "chrome/browser/chromeos/login/supervised_user_manager.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // early profile initialization that needs to happen before 179 // early profile initialization that needs to happen before
179 // ProfileManager::DoFinalInit() gets called is done here. 180 // ProfileManager::DoFinalInit() gets called is done here.
180 void InitProfilePreferences(Profile* user_profile, 181 void InitProfilePreferences(Profile* user_profile,
181 const std::string& email); 182 const std::string& email);
182 183
183 // Callback for asynchronous profile creation. 184 // Callback for asynchronous profile creation.
184 void OnProfileCreated(const std::string& email, 185 void OnProfileCreated(const std::string& email,
185 Profile* profile, 186 Profile* profile,
186 Profile::CreateStatus status); 187 Profile::CreateStatus status);
187 188
189 // Callback for asynchronous off the record profile creation.
190 void OnOTRProfileCreated(const std::string& email,
191 Profile* profile,
192 Profile::CreateStatus status);
193
188 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state. 194 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state.
189 // Profile is created, extensions and promo resources are initialized. 195 // Profile is created, extensions and promo resources are initialized.
190 void UserProfileInitialized(Profile* user_profile); 196 void UserProfileInitialized(Profile* user_profile);
191 197
198 // Callback for Profile::CREATE_STATUS_INITIALIZED profile state for an OTR
199 // login.
200 void OTRProfileInitialized(Profile* user_profile);
201
192 // Callback to resume profile creation after transferring auth data from 202 // Callback to resume profile creation after transferring auth data from
193 // the authentication profile. 203 // the authentication profile.
194 void CompleteProfileCreate(Profile* user_profile); 204 void CompleteProfileCreate(Profile* user_profile);
195 205
196 // Finalized profile preparation. 206 // Finalized profile preparation.
197 void FinalizePrepareProfile(Profile* user_profile); 207 void FinalizePrepareProfile(Profile* user_profile);
198 208
199 // Initializes member variables needed for session restore process via 209 // Initializes member variables needed for session restore process via
200 // OAuthLoginManager. 210 // OAuthLoginManager.
201 void InitSessionRestoreStrategy(); 211 void InitSessionRestoreStrategy();
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // Update user's displayed email. 417 // Update user's displayed email.
408 if (!display_email.empty()) 418 if (!display_email.empty())
409 user_manager->SaveUserDisplayEmail(user_context.username, display_email); 419 user_manager->SaveUserDisplayEmail(user_context.username, display_email);
410 420
411 user_context_ = user_context; 421 user_context_ = user_context;
412 422
413 has_web_auth_cookies_ = has_cookies; 423 has_web_auth_cookies_ = has_cookies;
414 delegate_ = delegate; 424 delegate_ = delegate;
415 InitSessionRestoreStrategy(); 425 InitSessionRestoreStrategy();
416 426
417 // Can't use display_email because it is empty when existing user logs in 427 base::FilePath profile_dir;
418 // using sing-in pod on login screen (i.e. user didn't type email). 428 if (DemoAppLauncher::IsDemoAppSession(user_context.username)) {
419 g_browser_process->profile_manager()->CreateProfileAsync( 429 g_browser_process->profile_manager()->CreateProfileAsync(
420 user_manager->GetUserProfileDir(user_context.username), 430 ProfileManager::GetGuestProfilePath(),
Nikita (slow) 2014/06/10 16:48:43 Are you sure that this is actually working? All o
Nikita (slow) 2014/06/11 09:44:40 So I've actually found that this issue was fixed r
421 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr(), 431 base::Bind(&LoginUtilsImpl::OnOTRProfileCreated, AsWeakPtr(),
422 user_context.username), 432 user_context.username),
423 base::string16(), base::string16(), std::string()); 433 base::string16(), base::string16(), std::string());
434 } else {
435 // Can't use display_email because it is empty when existing user logs in
436 // using sing-in pod on login screen (i.e. user didn't type email).
437 g_browser_process->profile_manager()->CreateProfileAsync(
438 user_manager->GetUserProfileDir(user_context.username),
439 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr(),
440 user_context.username),
441 base::string16(), base::string16(), std::string());
442 }
424 } 443 }
425 444
426 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { 445 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) {
427 if (delegate_ == delegate) 446 if (delegate_ == delegate)
428 delegate_ = NULL; 447 delegate_ = NULL;
429 } 448 }
430 449
431 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile, 450 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile,
432 const std::string& user_id) { 451 const std::string& user_id) {
433 if (UserManager::Get()->IsCurrentUserNew()) 452 if (UserManager::Get()->IsCurrentUserNew())
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 break; 531 break;
513 case Profile::CREATE_STATUS_LOCAL_FAIL: 532 case Profile::CREATE_STATUS_LOCAL_FAIL:
514 case Profile::CREATE_STATUS_REMOTE_FAIL: 533 case Profile::CREATE_STATUS_REMOTE_FAIL:
515 case Profile::CREATE_STATUS_CANCELED: 534 case Profile::CREATE_STATUS_CANCELED:
516 case Profile::MAX_CREATE_STATUS: 535 case Profile::MAX_CREATE_STATUS:
517 NOTREACHED(); 536 NOTREACHED();
518 break; 537 break;
519 } 538 }
520 } 539 }
521 540
541 void LoginUtilsImpl::OnOTRProfileCreated(
542 const std::string& user_id,
543 Profile* user_profile,
544 Profile::CreateStatus status) {
545 CHECK(user_profile);
546
547 switch (status) {
548 case Profile::CREATE_STATUS_CREATED:
549 InitProfilePreferences(user_profile, user_id);
550 break;
551 case Profile::CREATE_STATUS_INITIALIZED:
552 OTRProfileInitialized(user_profile);
553 break;
554 case Profile::CREATE_STATUS_LOCAL_FAIL:
555 case Profile::CREATE_STATUS_REMOTE_FAIL:
556 case Profile::CREATE_STATUS_CANCELED:
557 case Profile::MAX_CREATE_STATUS:
558 NOTREACHED();
559 break;
560 }
561 }
562
522 void LoginUtilsImpl::UserProfileInitialized(Profile* user_profile) { 563 void LoginUtilsImpl::UserProfileInitialized(Profile* user_profile) {
523 BootTimesLoader* btl = BootTimesLoader::Get(); 564 BootTimesLoader* btl = BootTimesLoader::Get();
524 btl->AddLoginTimeMarker("UserProfileGotten", false); 565 btl->AddLoginTimeMarker("UserProfileGotten", false);
525 566
526 if (user_context_.using_oauth) { 567 if (user_context_.using_oauth) {
527 // Transfer proxy authentication cache, cookies (optionally) and server 568 // Transfer proxy authentication cache, cookies (optionally) and server
528 // bound certs from the profile that was used for authentication. This 569 // bound certs from the profile that was used for authentication. This
529 // profile contains cookies that auth extension should have already put in 570 // profile contains cookies that auth extension should have already put in
530 // place that will ensure that the newly created session is authenticated 571 // place that will ensure that the newly created session is authenticated
531 // for the websites that work with the used authentication schema. 572 // for the websites that work with the used authentication schema.
532 ProfileAuthData::Transfer(authenticator_->authentication_profile(), 573 ProfileAuthData::Transfer(authenticator_->authentication_profile(),
533 user_profile, 574 user_profile,
534 has_web_auth_cookies_, // transfer_cookies 575 has_web_auth_cookies_, // transfer_cookies
535 base::Bind( 576 base::Bind(
536 &LoginUtilsImpl::CompleteProfileCreate, 577 &LoginUtilsImpl::CompleteProfileCreate,
537 AsWeakPtr(), 578 AsWeakPtr(),
538 user_profile)); 579 user_profile));
539 return; 580 return;
540 } 581 }
541 582
542 FinalizePrepareProfile(user_profile); 583 FinalizePrepareProfile(user_profile);
543 } 584 }
544 585
586 void LoginUtilsImpl::OTRProfileInitialized(Profile* user_profile) {
587 user_profile->OnLogin();
588 // Send the notification before creating the browser so additional objects
589 // that need the profile (e.g. the launcher) can be created first.
590 content::NotificationService::current()->Notify(
591 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
592 content::NotificationService::AllSources(),
593 content::Details<Profile>(user_profile));
594
595 if (delegate_)
596 delegate_->OnProfilePrepared(user_profile);
597 }
598
545 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { 599 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) {
546 RestoreAuthSession(user_profile, has_web_auth_cookies_); 600 RestoreAuthSession(user_profile, has_web_auth_cookies_);
547 FinalizePrepareProfile(user_profile); 601 FinalizePrepareProfile(user_profile);
548 } 602 }
549 603
550 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, 604 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile,
551 bool restore_from_auth_cookies) { 605 bool restore_from_auth_cookies) {
552 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || 606 CHECK((authenticator_.get() && authenticator_->authentication_profile()) ||
553 !restore_from_auth_cookies); 607 !restore_from_auth_cookies);
554 608
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 CrosSettings* cros_settings = CrosSettings::Get(); 967 CrosSettings* cros_settings = CrosSettings::Get();
914 bool allow_new_user = false; 968 bool allow_new_user = false;
915 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 969 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
916 if (allow_new_user) 970 if (allow_new_user)
917 return true; 971 return true;
918 return cros_settings->FindEmailInList( 972 return cros_settings->FindEmailInList(
919 kAccountsPrefUsers, username, wildcard_match); 973 kAccountsPrefUsers, username, wildcard_match);
920 } 974 }
921 975
922 } // namespace chromeos 976 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc ('k') | chrome/browser/chromeos/login/parallel_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698