blob: 880c989c75bdf458d796a2f4d27e00cd2488f8fb [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_
#include <string>
#include "base/basictypes.h"
#include "base/strings/string16.h"
class PrefRegistrySimple;
namespace chromeos {
class User;
// Base class for SupervisedUserManagerImpl - provides a mechanism for getting
// and setting specific values for supervised users, as well as additional
// lookup methods that make sense only for supervised users.
class SupervisedUserManager {
public:
// Registers user manager preferences.
static void RegisterPrefs(PrefRegistrySimple* registry);
SupervisedUserManager() {}
virtual ~SupervisedUserManager() {}
// Creates supervised user with given |display_name| and |local_user_id|
// and persists that to user list. Also links this user identified by
// |sync_user_id| to manager with a |manager_id|.
// Returns created user, or existing user if there already
// was locally managed user with such display name.
// TODO(antrim): Refactor into a single struct to have only 1 getter.
virtual const User* CreateUserRecord(
const std::string& manager_id,
const std::string& local_user_id,
const std::string& sync_user_id,
const string16& display_name) = 0;
// Generates unique user ID for supervised user.
virtual std::string GenerateUserId() = 0;
// Returns the supervised user with the given |display_name| if found in
// the persistent list. Returns |NULL| otherwise.
virtual const User* FindByDisplayName(const string16& display_name) const = 0;
// Returns the supervised user with the given |sync_id| if found in
// the persistent list. Returns |NULL| otherwise.
virtual const User* FindBySyncId(const std::string& sync_id) const = 0;
// Returns sync_user_id for supervised user with |user_id| or empty string if
// such user is not found or it doesn't have user_id defined.
virtual std::string GetUserSyncId(const std::string& user_id) const = 0;
// Returns the display name for manager of user |user_id| if it is known
// (was previously set by a |SaveUserDisplayName| call).
// Otherwise, returns a manager id.
virtual string16 GetManagerDisplayName(const std::string& user_id) const = 0;
// Returns the user id for manager of user |user_id| if it is known (user is
// actually a managed user).
// Otherwise, returns an empty string.
virtual std::string GetManagerUserId(const std::string& user_id) const = 0;
// Returns the display email for manager of user |user_id| if it is known
// (user is actually a managed user).
// Otherwise, returns an empty string.
virtual std::string GetManagerDisplayEmail(const std::string& user_id)
const = 0;
// Create a record about starting supervised user creation transaction.
virtual void StartCreationTransaction(const string16& display_name) = 0;
// Add user id to supervised user creation transaction record.
virtual void SetCreationTransactionUserId(const std::string& user_id) = 0;
// Remove locally managed user creation transaction record.
virtual void CommitCreationTransaction() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(SupervisedUserManager);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_USER_MANAGER_H_