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

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: Now with proper testing. 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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 demo_user_(kDemoUser, false), 287 demo_user_(kDemoUser, false),
288 guest_user_(kGuestUser, true), 288 guest_user_(kGuestUser, true),
289 stub_user_(kStubUser, false), 289 stub_user_(kStubUser, false),
290 logged_in_user_(NULL), 290 logged_in_user_(NULL),
291 is_current_user_owner_(false), 291 is_current_user_owner_(false),
292 is_current_user_new_(false), 292 is_current_user_new_(false),
293 is_user_logged_in_(false), 293 is_user_logged_in_(false),
294 key_store_loaded_(false),
294 observed_sync_service_(NULL), 295 observed_sync_service_(NULL),
295 last_image_set_async_(false), 296 last_image_set_async_(false),
296 downloaded_profile_image_data_url_(chrome::kAboutBlankURL) { 297 downloaded_profile_image_data_url_(chrome::kAboutBlankURL) {
297 // Use stub as the logged-in user for test paths without login. 298 // Use stub as the logged-in user for test paths without login.
298 if (!system::runtime_environment::IsRunningOnChromeOS()) 299 if (!system::runtime_environment::IsRunningOnChromeOS())
299 StubUserLoggedIn(); 300 StubUserLoggedIn();
300 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED, 301 registrar_.Add(this, chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED,
301 content::NotificationService::AllSources()); 302 content::NotificationService::AllSources());
302 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, 303 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
303 content::NotificationService::AllSources()); 304 content::NotificationService::AllSources());
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 content::NotificationService::current()->Notify( 804 content::NotificationService::current()->Notify(
804 chrome::NOTIFICATION_LOGIN_USER_CHANGED, 805 chrome::NOTIFICATION_LOGIN_USER_CHANGED,
805 content::Source<UserManagerImpl>(this), 806 content::Source<UserManagerImpl>(this),
806 content::Details<const User>(logged_in_user_)); 807 content::Details<const User>(logged_in_user_));
807 808
808 #if defined(TOOLKIT_USES_GTK) 809 #if defined(TOOLKIT_USES_GTK)
809 // Let the window manager know that we're logged in now. 810 // Let the window manager know that we're logged in now.
810 WmIpc::instance()->SetLoggedInProperty(true); 811 WmIpc::instance()->SetLoggedInProperty(true);
811 #endif 812 #endif
812 813
814 LoadKeyStore();
815
816 // Schedules current user ownership check on file thread.
817 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
818 base::Bind(&UserManagerImpl::CheckOwnership,
819 base::Unretained(this)));
820 }
821
822 void UserManagerImpl::LoadKeyStore() {
823 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
824 if (key_store_loaded_)
825 return;
826
813 // Ensure we've opened the real user's key/certificate database. 827 // Ensure we've opened the real user's key/certificate database.
814 crypto::OpenPersistentNSSDB(); 828 crypto::OpenPersistentNSSDB();
815 829
816 // Only load the Opencryptoki library into NSS if we have this switch. 830 // Only load the Opencryptoki library into NSS if we have this switch.
817 // TODO(gspencer): Remove this switch once cryptohomed work is finished: 831 // TODO(gspencer): Remove this switch once cryptohomed work is finished:
818 // http://crosbug.com/12295 and http://crosbug.com/12304 832 // http://crosbug.com/12295 and http://crosbug.com/12304
819 if (CommandLine::ForCurrentProcess()->HasSwitch( 833 if (CommandLine::ForCurrentProcess()->HasSwitch(
820 switches::kLoadOpencryptoki)) { 834 switches::kLoadOpencryptoki)) {
821 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate()); 835 crypto::EnableTPMTokenForNSS(new RealTPMTokenInfoDelegate());
822 CertLibrary* cert_library; 836 CertLibrary* cert_library;
823 cert_library = chromeos::CrosLibrary::Get()->GetCertLibrary(); 837 cert_library = chromeos::CrosLibrary::Get()->GetCertLibrary();
824 // Note: this calls crypto::EnsureTPMTokenReady() 838 // Note: this calls crypto::EnsureTPMTokenReady()
825 cert_library->RequestCertificates(); 839 cert_library->RequestCertificates();
826 } 840 }
827 841 key_store_loaded_ = true;
828 // Schedules current user ownership check on file thread.
829 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
830 base::Bind(&UserManagerImpl::CheckOwnership,
831 base::Unretained(this)));
832 } 842 }
833 843
834 void UserManagerImpl::SetInitialUserImage(const std::string& username) { 844 void UserManagerImpl::SetInitialUserImage(const std::string& username) {
835 // Choose a random default image. 845 // Choose a random default image.
836 int image_id = base::RandInt(0, kDefaultImagesCount - 1); 846 int image_id = base::RandInt(0, kDefaultImagesCount - 1);
837 SaveUserDefaultImageIndex(username, image_id); 847 SaveUserDefaultImageIndex(username, image_id);
838 } 848 }
839 849
840 void UserManagerImpl::SetUserImage(const std::string& username, 850 void UserManagerImpl::SetUserImage(const std::string& username,
841 int image_index, 851 int image_index,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1073
1064 User* UserManagerImpl::CreateUser(const std::string& email) const { 1074 User* UserManagerImpl::CreateUser(const std::string& email) const {
1065 User* user = new User(email, email == kGuestUser); 1075 User* user = new User(email, email == kGuestUser);
1066 user->set_oauth_token_status(LoadUserOAuthStatus(email)); 1076 user->set_oauth_token_status(LoadUserOAuthStatus(email));
1067 // Used to determine whether user's display name is unique. 1077 // Used to determine whether user's display name is unique.
1068 ++display_name_count_[user->GetDisplayName()]; 1078 ++display_name_count_[user->GetDisplayName()];
1069 return user; 1079 return user;
1070 } 1080 }
1071 1081
1072 } // namespace chromeos 1082 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698