- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / supervised_user_manager.h
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_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12
13 class PrefRegistrySimple;
14
15 namespace chromeos {
16
17 class User;
18
19 // Base class for SupervisedUserManagerImpl - provides a mechanism for getting
20 // and setting specific values for supervised users, as well as additional
21 // lookup methods that make sense only for supervised users.
22 class SupervisedUserManager {
23  public:
24   // Registers user manager preferences.
25   static void RegisterPrefs(PrefRegistrySimple* registry);
26
27   SupervisedUserManager() {}
28   virtual ~SupervisedUserManager() {}
29
30   // Creates supervised user with given |display_name| and |local_user_id|
31   // and persists that to user list. Also links this user identified by
32   // |sync_user_id| to manager with a |manager_id|.
33   // Returns created user, or existing user if there already
34   // was locally managed user with such display name.
35   // TODO(antrim): Refactor into a single struct to have only 1 getter.
36   virtual const User* CreateUserRecord(
37       const std::string& manager_id,
38       const std::string& local_user_id,
39       const std::string& sync_user_id,
40       const string16& display_name) = 0;
41
42   // Generates unique user ID for supervised user.
43   virtual std::string GenerateUserId() = 0;
44
45   // Returns the supervised user with the given |display_name| if found in
46   // the persistent list. Returns |NULL| otherwise.
47   virtual const User* FindByDisplayName(const string16& display_name) const = 0;
48
49   // Returns the supervised user with the given |sync_id| if found in
50   // the persistent list. Returns |NULL| otherwise.
51   virtual const User* FindBySyncId(const std::string& sync_id) const = 0;
52
53   // Returns sync_user_id for supervised user with |user_id| or empty string if
54   // such user is not found or it doesn't have user_id defined.
55   virtual std::string GetUserSyncId(const std::string& user_id) const = 0;
56
57   // Returns the display name for manager of user |user_id| if it is known
58   // (was previously set by a |SaveUserDisplayName| call).
59   // Otherwise, returns a manager id.
60   virtual string16 GetManagerDisplayName(const std::string& user_id) const = 0;
61
62   // Returns the user id for manager of user |user_id| if it is known (user is
63   // actually a managed user).
64   // Otherwise, returns an empty string.
65   virtual std::string GetManagerUserId(const std::string& user_id) const = 0;
66
67   // Returns the display email for manager of user |user_id| if it is known
68   // (user is actually a managed user).
69   // Otherwise, returns an empty string.
70   virtual std::string GetManagerDisplayEmail(const std::string& user_id)
71       const = 0;
72
73   // Create a record about starting supervised user creation transaction.
74   virtual void StartCreationTransaction(const string16& display_name) = 0;
75
76   // Add user id to supervised user creation transaction record.
77   virtual void SetCreationTransactionUserId(const std::string& user_id) = 0;
78
79   // Remove locally managed user creation transaction record.
80   virtual void CommitCreationTransaction() = 0;
81
82  private:
83   DISALLOW_COPY_AND_ASSIGN(SupervisedUserManager);
84 };
85
86 }  // namespace chromeos
87
88 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_