Index: chrome/browser/chromeos/login/supervised_user_manager_impl.cc |
diff --git a/chrome/browser/chromeos/login/supervised_user_manager_impl.cc b/chrome/browser/chromeos/login/supervised_user_manager_impl.cc |
index 15132ea3abba57ed8935ec44f18b2832be45d01a..1e7199a107b67b96d79d6e883aef736944751bfe 100644 |
--- a/chrome/browser/chromeos/login/supervised_user_manager_impl.cc |
+++ b/chrome/browser/chromeos/login/supervised_user_manager_impl.cc |
@@ -4,16 +4,23 @@ |
#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" |
@@ -67,6 +74,17 @@ const char kSupervisedUserPasswordSalt[] = |
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)) { |
Nikita (slow)
2014/02/07 09:51:48
nit: Drop {}
|
+ return std::string(); |
+ } |
+ return token; |
+} |
+ |
} // namespace |
namespace chromeos { |
@@ -417,4 +435,23 @@ SupervisedUserAuthentication* SupervisedUserManagerImpl::GetAuthentication() { |
return authentication_.get(); |
} |
+void SupervisedUserManagerImpl::LoadSupervisedUserToken( |
+ Profile* profile, |
+ const LoadTokenCallback& callback) { |
+ base::FilePath profile_dir = ProfileHelper::GetProfilePathByUserIdHash( |
Nikita (slow)
2014/02/07 09:51:48
profile->GetPath() should work too.
|
+ 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 |