1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_IMPL_H_ 7 8 #include <vector> 9 10 #include "base/basictypes.h" 11 #include "base/compiler_specific.h" 12 #include "chrome/browser/chromeos/login/supervised_user_manager.h" 13 14 namespace chromeos { 15 16 class CrosSettings; 17 class UserManagerImpl; 18 19 // Implementation of the UserManager. 20 class SupervisedUserManagerImpl 21 : public SupervisedUserManager { 22 public: 23 virtual ~SupervisedUserManagerImpl(); 24 25 virtual const User* CreateUserRecord( 26 const std::string& manager_id, 27 const std::string& local_user_id, 28 const std::string& sync_user_id, 29 const base::string16& display_name) OVERRIDE; 30 virtual std::string GenerateUserId() OVERRIDE; 31 virtual const User* FindByDisplayName(const base::string16& display_name) const 32 OVERRIDE; 33 virtual const User* FindBySyncId(const std::string& sync_id) const OVERRIDE; 34 virtual std::string GetUserSyncId(const std::string& user_id) const OVERRIDE; 35 virtual base::string16 GetManagerDisplayName(const std::string& user_id) const 36 OVERRIDE; 37 virtual std::string GetManagerUserId(const std::string& user_id) const 38 OVERRIDE; 39 virtual std::string GetManagerDisplayEmail(const std::string& user_id) const 40 OVERRIDE; 41 virtual void StartCreationTransaction(const base::string16& display_name) OVERRIDE; 42 virtual void SetCreationTransactionUserId(const std::string& user_id) 43 OVERRIDE; 44 virtual void CommitCreationTransaction() OVERRIDE; 45 virtual void LoadSupervisedUserToken( 46 Profile * profile, 47 const LoadTokenCallback& callback) OVERRIDE; 48 virtual void ConfigureSyncWithToken( 49 Profile* profile, 50 const std::string& token) OVERRIDE; 51 52 private: 53 friend class UserManager; 54 friend class UserManagerImpl; 55 56 explicit SupervisedUserManagerImpl(UserManagerImpl* owner); 57 58 // Returns true if there is non-committed user creation transaction. 59 bool HasFailedUserCreationTransaction(); 60 61 // Attempts to clean up data that could be left from failed user creation. 62 void RollbackUserCreationTransaction(); 63 64 void RemoveNonCryptohomeData(const std::string& user_id); 65 66 bool CheckForFirstRun(const std::string& user_id); 67 68 // Update name if this user is manager of some managed users. 69 void UpdateManagerName(const std::string& manager_id, 70 const base::string16& new_display_name); 71 72 UserManagerImpl* owner_; 73 74 // Interface to the signed settings store. 75 CrosSettings* cros_settings_; 76 77 DISALLOW_COPY_AND_ASSIGN(SupervisedUserManagerImpl); 78 }; 79 80 } // namespace chromeos 81 82 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_IMPL_H_ 83