OLD | NEW |
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/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 | 282 |
283 } // namespace | 283 } // namespace |
284 | 284 |
285 UserManagerImpl::UserManagerImpl() | 285 UserManagerImpl::UserManagerImpl() |
286 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader)), | 286 : ALLOW_THIS_IN_INITIALIZER_LIST(image_loader_(new UserImageLoader)), |
287 logged_in_user_(NULL), | 287 logged_in_user_(NULL), |
288 is_current_user_owner_(false), | 288 is_current_user_owner_(false), |
289 is_current_user_new_(false), | 289 is_current_user_new_(false), |
290 is_current_user_ephemeral_(false), | 290 is_current_user_ephemeral_(false), |
| 291 key_store_loaded_(false), |
291 ephemeral_users_enabled_(false), | 292 ephemeral_users_enabled_(false), |
292 observed_sync_service_(NULL), | 293 observed_sync_service_(NULL), |
293 last_image_set_async_(false), | 294 last_image_set_async_(false), |
294 downloaded_profile_image_data_url_(chrome::kAboutBlankURL) { | 295 downloaded_profile_image_data_url_(chrome::kAboutBlankURL) { |
295 // If we're not running on ChromeOS, and are not showing the login manager | 296 // If we're not running on ChromeOS, and are not showing the login manager |
296 // or attempting a command line login? Then login the stub user. | 297 // or attempting a command line login? Then login the stub user. |
297 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 298 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
298 if (!base::chromeos::IsRunningOnChromeOS() && | 299 if (!base::chromeos::IsRunningOnChromeOS() && |
299 !command_line->HasSwitch(switches::kLoginManager) && | 300 !command_line->HasSwitch(switches::kLoginManager) && |
300 !command_line->HasSwitch(switches::kLoginPassword)) { | 301 !command_line->HasSwitch(switches::kLoginPassword)) { |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 return NULL; | 874 return NULL; |
874 } | 875 } |
875 | 876 |
876 void UserManagerImpl::NotifyOnLogin() { | 877 void UserManagerImpl::NotifyOnLogin() { |
877 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 878 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
878 content::NotificationService::current()->Notify( | 879 content::NotificationService::current()->Notify( |
879 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 880 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
880 content::Source<UserManagerImpl>(this), | 881 content::Source<UserManagerImpl>(this), |
881 content::Details<const User>(logged_in_user_)); | 882 content::Details<const User>(logged_in_user_)); |
882 | 883 |
| 884 LoadKeyStore(); |
| 885 |
| 886 // Schedules current user ownership check on file thread. |
| 887 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 888 base::Bind(&UserManagerImpl::CheckOwnership, |
| 889 base::Unretained(this))); |
| 890 } |
| 891 |
| 892 void UserManagerImpl::LoadKeyStore() { |
| 893 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 894 if (key_store_loaded_) |
| 895 return; |
| 896 |
883 // Ensure we've opened the real user's key/certificate database. | 897 // Ensure we've opened the real user's key/certificate database. |
884 crypto::OpenPersistentNSSDB(); | 898 crypto::OpenPersistentNSSDB(); |
885 | 899 |
886 // Only load the Opencryptoki library into NSS if we have this switch. | 900 // Only load the Opencryptoki library into NSS if we have this switch. |
887 // TODO(gspencer): Remove this switch once cryptohomed work is finished: | 901 // TODO(gspencer): Remove this switch once cryptohomed work is finished: |
888 // http://crosbug.com/12295 and http://crosbug.com/12304 | 902 // http://crosbug.com/12295 and http://crosbug.com/12304 |
889 if (CommandLine::ForCurrentProcess()->HasSwitch( | 903 if (CommandLine::ForCurrentProcess()->HasSwitch( |
890 switches::kLoadOpencryptoki)) { | 904 switches::kLoadOpencryptoki)) { |
891 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate()); | 905 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate()); |
892 CertLibrary* cert_library; | 906 CertLibrary* cert_library; |
893 cert_library = chromeos::CrosLibrary::Get()->GetCertLibrary(); | 907 cert_library = chromeos::CrosLibrary::Get()->GetCertLibrary(); |
894 // Note: this calls crypto::EnsureTPMTokenReady() | 908 // Note: this calls crypto::EnsureTPMTokenReady() |
895 cert_library->RequestCertificates(); | 909 cert_library->RequestCertificates(); |
896 } | 910 } |
897 | 911 key_store_loaded_ = true; |
898 // Schedules current user ownership check on file thread. | |
899 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
900 base::Bind(&UserManagerImpl::CheckOwnership, | |
901 base::Unretained(this))); | |
902 } | 912 } |
903 | 913 |
904 void UserManagerImpl::SetInitialUserImage(const std::string& username) { | 914 void UserManagerImpl::SetInitialUserImage(const std::string& username) { |
905 // Choose a random default image. | 915 // Choose a random default image. |
906 int image_id = base::RandInt(0, kDefaultImagesCount - 1); | 916 int image_id = base::RandInt(0, kDefaultImagesCount - 1); |
907 SaveUserDefaultImageIndex(username, image_id); | 917 SaveUserDefaultImageIndex(username, image_id); |
908 } | 918 } |
909 | 919 |
910 int UserManagerImpl::GetUserWallpaperIndex() { | 920 int UserManagerImpl::GetUserWallpaperIndex() { |
911 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 921 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 BrowserThread::PostTask( | 1245 BrowserThread::PostTask( |
1236 BrowserThread::FILE, | 1246 BrowserThread::FILE, |
1237 FROM_HERE, | 1247 FROM_HERE, |
1238 base::Bind(&UserManagerImpl::DeleteUserImage, | 1248 base::Bind(&UserManagerImpl::DeleteUserImage, |
1239 base::Unretained(this), | 1249 base::Unretained(this), |
1240 image_path)); | 1250 image_path)); |
1241 } | 1251 } |
1242 } | 1252 } |
1243 | 1253 |
1244 } // namespace chromeos | 1254 } // namespace chromeos |
OLD | NEW |