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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "base/values.h"
14 class PrefRegistrySimple
;
19 class SupervisedUserAuthentication
;
21 // Keys in dictionary with supervised password information.
22 extern const char kSchemaVersion
[];
23 extern const char kPasswordRevision
[];
24 extern const char kSalt
[];
25 extern const char kEncryptedPassword
[];
26 extern const int kMinPasswordRevision
;
28 // Base class for SupervisedUserManagerImpl - provides a mechanism for getting
29 // and setting specific values for supervised users, as well as additional
30 // lookup methods that make sense only for supervised users.
31 class SupervisedUserManager
{
33 // Registers user manager preferences.
34 static void RegisterPrefs(PrefRegistrySimple
* registry
);
36 SupervisedUserManager() {}
37 virtual ~SupervisedUserManager() {}
39 // Creates supervised user with given |display_name| and |local_user_id|
40 // and persists that to user list. Also links this user identified by
41 // |sync_user_id| to manager with a |manager_id|.
42 // Returns created user, or existing user if there already
43 // was locally managed user with such display name.
44 // TODO(antrim): Refactor into a single struct to have only 1 getter.
45 virtual const User
* CreateUserRecord(
46 const std::string
& manager_id
,
47 const std::string
& local_user_id
,
48 const std::string
& sync_user_id
,
49 const base::string16
& display_name
) = 0;
51 // Generates unique user ID for supervised user.
52 virtual std::string
GenerateUserId() = 0;
54 // Returns the supervised user with the given |display_name| if found in
55 // the persistent list. Returns |NULL| otherwise.
56 virtual const User
* FindByDisplayName(
57 const base::string16
& display_name
) const = 0;
59 // Returns the supervised user with the given |sync_id| if found in
60 // the persistent list. Returns |NULL| otherwise.
61 virtual const User
* FindBySyncId(const std::string
& sync_id
) const = 0;
63 // Returns sync_user_id for supervised user with |user_id| or empty string if
64 // such user is not found or it doesn't have user_id defined.
65 virtual std::string
GetUserSyncId(const std::string
& user_id
) const = 0;
67 // Returns the display name for manager of user |user_id| if it is known
68 // (was previously set by a |SaveUserDisplayName| call).
69 // Otherwise, returns a manager id.
70 virtual base::string16
GetManagerDisplayName(
71 const std::string
& user_id
) const = 0;
73 // Returns the user id for manager of user |user_id| if it is known (user is
74 // actually a managed user).
75 // Otherwise, returns an empty string.
76 virtual std::string
GetManagerUserId(const std::string
& user_id
) const = 0;
78 // Returns the display email for manager of user |user_id| if it is known
79 // (user is actually a managed user).
80 // Otherwise, returns an empty string.
81 virtual std::string
GetManagerDisplayEmail(const std::string
& user_id
)
84 // Create a record about starting supervised user creation transaction.
85 virtual void StartCreationTransaction(const base::string16
& display_name
) = 0;
87 // Add user id to supervised user creation transaction record.
88 virtual void SetCreationTransactionUserId(const std::string
& user_id
) = 0;
90 // Remove locally managed user creation transaction record.
91 virtual void CommitCreationTransaction() = 0;
93 // Return object that handles specifics of supervised user authentication.
94 virtual SupervisedUserAuthentication
* GetAuthentication() = 0;
96 // Fill |result| with public password-specific data for |user_id| from Local
98 virtual void GetPasswordInformation(const std::string
& user_id
,
99 base::DictionaryValue
* result
) = 0;
101 // Stores public password-specific data from |password_info| for |user_id| in
103 virtual void SetPasswordInformation(
104 const std::string
& user_id
,
105 const base::DictionaryValue
* password_info
) = 0;
108 DISALLOW_COPY_AND_ASSIGN(SupervisedUserManager
);
111 } // namespace chromeos
113 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_