#include "chrome/browser/chromeos/login/supervised_user_manager_impl.h"
+#include "base/file_util.h"
+#include "base/files/file_path.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h"
#include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h"
#include "chrome/browser/chromeos/login/user_manager_impl.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/managed_mode/managed_user_service.h"
+#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chromeos/settings/cros_settings_names.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_auth_util.h"
const char kSupervisedUserPasswordRevision[] =
"SupervisedUserPasswordRevision";
+std::string LoadSyncToken(base::FilePath profile_dir) {
+ std::string token;
+ base::FilePath token_file =
+ profile_dir.Append(chromeos::kManagedUserTokenFilename);
+ VLOG(1) << "Loading" << token_file.value();
+ if (!base::ReadFileToString(token_file, &token))
+ return std::string();
+ return token;
+}
+
} // namespace
namespace chromeos {
const char kPasswordRevision[] = "PasswordRevision";
const char kSalt[] = "PasswordSalt";
const char kEncryptedPassword[] = "EncryptedPassword";
+const char kRequirePasswordUpdate[] = "RequirePasswordUpdate";
+const char kPasswordUpdateFile[] = "password.update";
const int kMinPasswordRevision = 1;
// static
return id;
}
+bool SupervisedUserManagerImpl::HasSupervisedUsers(
+ const std::string& manager_id) const {
+ const UserList& users = owner_->GetUsers();
+ for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
+ if ((*it)->GetType() == User::USER_TYPE_LOCALLY_MANAGED) {
+ if (manager_id == GetManagerUserId((*it)->email()))
+ return true;
+ }
+ }
+ return false;
+}
+
const User* SupervisedUserManagerImpl::CreateUserRecord(
const std::string& manager_id,
const std::string& local_user_id,
return authentication_.get();
}
+void SupervisedUserManagerImpl::LoadSupervisedUserToken(
+ Profile* profile,
+ const LoadTokenCallback& callback) {
+ // TODO(antrim): use profile->GetPath() once we sure it is safe.
+ base::FilePath profile_dir = ProfileHelper::GetProfilePathByUserIdHash(
+ UserManager::Get()->GetUserByProfile(profile)->username_hash());
+ PostTaskAndReplyWithResult(
+ content::BrowserThread::GetBlockingPool(),
+ FROM_HERE,
+ base::Bind(&LoadSyncToken, profile_dir),
+ callback);
+}
+
+void SupervisedUserManagerImpl::ConfigureSyncWithToken(
+ Profile* profile,
+ const std::string& token) {
+ if (!token.empty())
+ ManagedUserServiceFactory::GetForProfile(profile)->InitSync(token);
+}
+
} // namespace chromeos