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

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

Issue 9466005: Make sure the device recovers from policy loss in the consumer case. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on ToT and cleaned up comments and unrelated changes. Created 8 years, 9 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/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
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 // Use stub as the logged-in user for test paths without login. 296 // Use stub as the logged-in user for test paths without login.
296 if (!base::chromeos::IsRunningOnChromeOS()) 297 if (!base::chromeos::IsRunningOnChromeOS())
297 StubUserLoggedIn(); 298 StubUserLoggedIn();
298 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 299 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
299 content::NotificationService::AllSources()); 300 content::NotificationService::AllSources());
300 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, 301 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 return NULL; 868 return NULL;
868 } 869 }
869 870
870 void UserManagerImpl::NotifyOnLogin() { 871 void UserManagerImpl::NotifyOnLogin() {
871 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 872 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
872 content::NotificationService::current()->Notify( 873 content::NotificationService::current()->Notify(
873 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 874 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
874 content::Source<UserManagerImpl>(this), 875 content::Source<UserManagerImpl>(this),
875 content::Details<const User>(logged_in_user_)); 876 content::Details<const User>(logged_in_user_));
876 877
878 LoadKeyStore();
879
880 // Schedules current user ownership check on file thread.
881 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
882 base::Bind(&UserManagerImpl::CheckOwnership,
883 base::Unretained(this)));
884 }
885
886 void UserManagerImpl::LoadKeyStore() {
887 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
888 if (key_store_loaded_)
889 return;
890
877 // Ensure we've opened the real user's key/certificate database. 891 // Ensure we've opened the real user's key/certificate database.
878 crypto::OpenPersistentNSSDB(); 892 crypto::OpenPersistentNSSDB();
879 893
880 // Only load the Opencryptoki library into NSS if we have this switch. 894 // Only load the Opencryptoki library into NSS if we have this switch.
881 // TODO(gspencer): Remove this switch once cryptohomed work is finished: 895 // TODO(gspencer): Remove this switch once cryptohomed work is finished:
882 // http://crosbug.com/12295 and http://crosbug.com/12304 896 // http://crosbug.com/12295 and http://crosbug.com/12304
883 if (CommandLine::ForCurrentProcess()->HasSwitch( 897 if (CommandLine::ForCurrentProcess()->HasSwitch(
884 switches::kLoadOpencryptoki)) { 898 switches::kLoadOpencryptoki)) {
885 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate()); 899 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate());
886 CertLibrary* cert_library; 900 CertLibrary* cert_library;
887 cert_library = chromeos::CrosLibrary::Get()->GetCertLibrary(); 901 cert_library = chromeos::CrosLibrary::Get()->GetCertLibrary();
888 // Note: this calls crypto::EnsureTPMTokenReady() 902 // Note: this calls crypto::EnsureTPMTokenReady()
889 cert_library->RequestCertificates(); 903 cert_library->RequestCertificates();
890 } 904 }
891 905 key_store_loaded_ = true;
892 // Schedules current user ownership check on file thread.
893 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
894 base::Bind(&UserManagerImpl::CheckOwnership,
895 base::Unretained(this)));
896 } 906 }
897 907
898 void UserManagerImpl::SetInitialUserImage(const std::string& username) { 908 void UserManagerImpl::SetInitialUserImage(const std::string& username) {
899 // Choose a random default image. 909 // Choose a random default image.
900 int image_id = base::RandInt(0, kDefaultImagesCount - 1); 910 int image_id = base::RandInt(0, kDefaultImagesCount - 1);
901 SaveUserDefaultImageIndex(username, image_id); 911 SaveUserDefaultImageIndex(username, image_id);
902 } 912 }
903 913
904 int UserManagerImpl::GetUserWallpaper(const std::string& username) { 914 int UserManagerImpl::GetUserWallpaper(const std::string& username) {
905 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 915 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 BrowserThread::PostTask( 1222 BrowserThread::PostTask(
1213 BrowserThread::FILE, 1223 BrowserThread::FILE,
1214 FROM_HERE, 1224 FROM_HERE,
1215 base::Bind(&UserManagerImpl::DeleteUserImage, 1225 base::Bind(&UserManagerImpl::DeleteUserImage,
1216 base::Unretained(this), 1226 base::Unretained(this),
1217 image_path)); 1227 image_path));
1218 } 1228 }
1219 } 1229 }
1220 1230
1221 } // namespace chromeos 1231 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698