Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / login / users / supervised_user_manager_impl.h
blob06ecc4a12dbd063af1ccdc8a07a1cc452b95dc69
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_SUPERVISED_USER_MANAGER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_SUPERVISED_USER_MANAGER_IMPL_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/chromeos/login/supervised/supervised_user_authentication.h"
13 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
15 namespace chromeos {
17 class ChromeUserManagerImpl;
18 class CrosSettings;
19 class SupervisedUserTestBase;
21 // Implementation of the UserManager.
22 class SupervisedUserManagerImpl
23 : public SupervisedUserManager {
24 public:
25 ~SupervisedUserManagerImpl() override;
27 bool HasSupervisedUsers(const std::string& manager_id) const override;
28 const user_manager::User* CreateUserRecord(
29 const std::string& manager_id,
30 const std::string& local_user_id,
31 const std::string& sync_user_id,
32 const base::string16& display_name) override;
33 std::string GenerateUserId() override;
34 const user_manager::User* FindByDisplayName(
35 const base::string16& display_name) const override;
36 const user_manager::User* FindBySyncId(
37 const std::string& sync_id) const override;
38 std::string GetUserSyncId(const std::string& user_id) const override;
39 base::string16 GetManagerDisplayName(
40 const std::string& user_id) const override;
41 std::string GetManagerUserId(const std::string& user_id) const override;
42 std::string GetManagerDisplayEmail(const std::string& user_id) const override;
43 void StartCreationTransaction(const base::string16& display_name) override;
44 void SetCreationTransactionUserId(const std::string& user_id) override;
45 void CommitCreationTransaction() override;
46 SupervisedUserAuthentication* GetAuthentication() override;
47 void GetPasswordInformation(const std::string& user_id,
48 base::DictionaryValue* result) override;
49 void SetPasswordInformation(
50 const std::string& user_id,
51 const base::DictionaryValue* password_info) override;
52 void LoadSupervisedUserToken(Profile* profile,
53 const LoadTokenCallback& callback) override;
54 void ConfigureSyncWithToken(Profile* profile,
55 const std::string& token) override;
57 private:
58 friend class ChromeUserManagerImpl;
59 friend class UserManager;
60 friend class SupervisedUserTestBase;
62 explicit SupervisedUserManagerImpl(ChromeUserManagerImpl* owner);
64 // Returns true if there is non-committed user creation transaction.
65 bool HasFailedUserCreationTransaction();
67 // Attempts to clean up data that could be left from failed user creation.
68 void RollbackUserCreationTransaction();
70 void RemoveNonCryptohomeData(const std::string& user_id);
72 bool CheckForFirstRun(const std::string& user_id);
74 // Update name if this user is manager of some managed users.
75 void UpdateManagerName(const std::string& manager_id,
76 const base::string16& new_display_name);
78 bool GetUserStringValue(const std::string& user_id,
79 const char* key,
80 std::string* out_value) const;
82 void SetUserStringValue(const std::string& user_id,
83 const char* key,
84 const std::string& value);
86 bool GetUserIntegerValue(const std::string& user_id,
87 const char* key,
88 int* out_value) const;
90 void SetUserIntegerValue(const std::string& user_id,
91 const char* key,
92 const int value);
94 bool GetUserBooleanValue(const std::string& user_id,
95 const char* key,
96 bool* out_value) const;
98 void SetUserBooleanValue(const std::string& user_id,
99 const char* key,
100 const bool value);
102 void CleanPref(const std::string& user_id,
103 const char* key);
105 ChromeUserManagerImpl* owner_;
107 // Interface to the signed settings store.
108 CrosSettings* cros_settings_;
110 scoped_ptr<SupervisedUserAuthentication> authentication_;
112 DISALLOW_COPY_AND_ASSIGN(SupervisedUserManagerImpl);
115 } // namespace chromeos
117 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_SUPERVISED_USER_MANAGER_IMPL_H_