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/callback.h"
12 #include "base/strings/string16.h"
13 #include "base/values.h"
14 #include "chrome/browser/profiles/profile.h"
16 class PrefRegistrySimple
;
21 class SupervisedUserAuthentication
;
23 // Keys in dictionary with supervised password information.
24 extern const char kSchemaVersion
[];
25 extern const char kPasswordRevision
[];
26 extern const char kSalt
[];
27 extern const char kRequirePasswordUpdate
[];
28 extern const char kHasIncompleteKey
[];
29 extern const int kMinPasswordRevision
;
31 // Values for these keys are not stored in local state.
32 extern const char kEncryptedPassword
[];
33 extern const char kPasswordSignature
[];
34 extern const char kPasswordEncryptionKey
[];
35 extern const char kPasswordSignatureKey
[];
37 extern const char kPasswordUpdateFile
[];
39 // Base class for SupervisedUserManagerImpl - provides a mechanism for getting
40 // and setting specific values for supervised users, as well as additional
41 // lookup methods that make sense only for supervised users.
42 class SupervisedUserManager
{
44 typedef base::Callback
<void(const std::string
& /* token */)>
47 // Registers user manager preferences.
48 static void RegisterPrefs(PrefRegistrySimple
* registry
);
50 SupervisedUserManager() {}
51 virtual ~SupervisedUserManager() {}
53 // Checks if given user have supervised users on this device.
55 virtual bool HasSupervisedUsers(const std::string
& manager_id
) const = 0;
57 // Creates supervised user with given |display_name| and |local_user_id|
58 // and persists that to user list. Also links this user identified by
59 // |sync_user_id| to manager with a |manager_id|.
60 // Returns created user, or existing user if there already
61 // was locally managed user with such display name.
62 // TODO(antrim): Refactor into a single struct to have only 1 getter.
63 virtual const User
* CreateUserRecord(
64 const std::string
& manager_id
,
65 const std::string
& local_user_id
,
66 const std::string
& sync_user_id
,
67 const base::string16
& display_name
) = 0;
69 // Generates unique user ID for supervised user.
70 virtual std::string
GenerateUserId() = 0;
72 // Returns the supervised user with the given |display_name| if found in
73 // the persistent list. Returns |NULL| otherwise.
74 virtual const User
* FindByDisplayName(
75 const base::string16
& display_name
) const = 0;
77 // Returns the supervised user with the given |sync_id| if found in
78 // the persistent list. Returns |NULL| otherwise.
79 virtual const User
* FindBySyncId(const std::string
& sync_id
) const = 0;
81 // Returns sync_user_id for supervised user with |user_id| or empty string if
82 // such user is not found or it doesn't have user_id defined.
83 virtual std::string
GetUserSyncId(const std::string
& user_id
) const = 0;
85 // Returns the display name for manager of user |user_id| if it is known
86 // (was previously set by a |SaveUserDisplayName| call).
87 // Otherwise, returns a manager id.
88 virtual base::string16
GetManagerDisplayName(
89 const std::string
& user_id
) const = 0;
91 // Returns the user id for manager of user |user_id| if it is known (user is
92 // actually a managed user).
93 // Otherwise, returns an empty string.
94 virtual std::string
GetManagerUserId(const std::string
& user_id
) const = 0;
96 // Returns the display email for manager of user |user_id| if it is known
97 // (user is actually a managed user).
98 // Otherwise, returns an empty string.
99 virtual std::string
GetManagerDisplayEmail(const std::string
& user_id
)
102 // Create a record about starting supervised user creation transaction.
103 virtual void StartCreationTransaction(const base::string16
& display_name
) = 0;
105 // Add user id to supervised user creation transaction record.
106 virtual void SetCreationTransactionUserId(const std::string
& user_id
) = 0;
108 // Remove locally managed user creation transaction record.
109 virtual void CommitCreationTransaction() = 0;
111 // Return object that handles specifics of supervised user authentication.
112 virtual SupervisedUserAuthentication
* GetAuthentication() = 0;
114 // Fill |result| with public password-specific data for |user_id| from Local
116 virtual void GetPasswordInformation(const std::string
& user_id
,
117 base::DictionaryValue
* result
) = 0;
119 // Stores public password-specific data from |password_info| for |user_id| in
121 virtual void SetPasswordInformation(
122 const std::string
& user_id
,
123 const base::DictionaryValue
* password_info
) = 0;
125 // Loads a sync oauth token in background, and passes it to callback.
126 virtual void LoadSupervisedUserToken(Profile
* profile
,
127 const LoadTokenCallback
& callback
) = 0;
129 // Configures sync service with oauth token.
130 virtual void ConfigureSyncWithToken(Profile
* profile
,
131 const std::string
& token
) = 0;
134 DISALLOW_COPY_AND_ASSIGN(SupervisedUserManager
);
137 } // namespace chromeos
139 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_