summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.cc5
-rw-r--r--chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc4
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc8
-rw-r--r--chrome/browser/chromeos/login/reauth_stats.cc15
-rw-r--r--chrome/browser/chromeos/login/screens/chrome_user_selection_screen.cc7
-rw-r--r--chrome/browser/chromeos/login/screens/user_selection_screen.cc11
-rw-r--r--chrome/browser/chromeos/login/session/user_session_manager.cc22
-rw-r--r--chrome/browser/chromeos/login/signin/device_id_browsertest.cc7
-rw-r--r--chrome/browser/chromeos/login/signin/token_handle_util.cc28
-rw-r--r--chrome/browser/chromeos/login/signin/token_handle_util.h9
-rw-r--r--chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc16
-rw-r--r--chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc11
-rw-r--r--chrome/browser/chromeos/login/users/fake_chrome_user_manager.h5
-rw-r--r--chrome/browser/chromeos/preferences.cc6
-rw-r--r--chrome/browser/signin/chrome_signin_client.cc17
-rw-r--r--chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc22
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc5
-rw-r--r--chrome/browser/ui/webui/options/chromeos/user_image_source.cc3
-rw-r--r--components/user_manager.gypi2
-rw-r--r--components/user_manager/BUILD.gn2
-rw-r--r--components/user_manager/known_user.cc334
-rw-r--r--components/user_manager/known_user.h132
-rw-r--r--components/user_manager/user_manager.cc23
-rw-r--r--components/user_manager/user_manager.h106
-rw-r--r--components/user_manager/user_manager_base.cc296
-rw-r--r--components/user_manager/user_manager_base.h46
26 files changed, 567 insertions, 575 deletions
diff --git a/chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.cc b/chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.cc
index d4fb577..ae18311 100644
--- a/chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.cc
+++ b/chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.cc
@@ -9,6 +9,7 @@
#include "base/prefs/scoped_user_pref_update.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
+#include "components/user_manager/known_user.h"
namespace chromeos {
@@ -62,8 +63,8 @@ void BootstrapManager::RemoveAllPendingBootstrap() {
std::string current_user_email;
if (users->GetString(i, &current_user_email)) {
delegate_->RemovePendingBootstrapUser(
- user_manager::UserManager::Get()->GetKnownUserAccountId(
- current_user_email, std::string() /* gaia_id */));
+ user_manager::known_user::GetAccountId(current_user_email,
+ std::string() /* gaia_id */));
}
}
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc
index 3badfbe..cdce1cf 100644
--- a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc
+++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc
@@ -12,7 +12,9 @@
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user.h"
+#include "components/user_manager/user_manager.h"
namespace {
@@ -39,7 +41,7 @@ EasyUnlockTpmKeyManager* EasyUnlockTpmKeyManagerFactory::GetForUser(
const std::string& user_id) {
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
const user_manager::User* user = user_manager->FindUser(
- user_manager->GetKnownUserAccountId(user_id, std::string()));
+ user_manager::known_user::GetAccountId(user_id, std::string()));
if (!user)
return NULL;
Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(user);
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 8655f71..ece1c2d 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -63,6 +63,7 @@
#include "components/policy/core/common/policy_types.h"
#include "components/signin/core/account_id/account_id.h"
#include "components/signin/core/browser/signin_client.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
#include "content/public/browser/browser_thread.h"
@@ -1065,8 +1066,7 @@ void ExistingUserController::DoCompleteLogin(
const UserContext& user_context_wo_device_id) {
UserContext user_context = user_context_wo_device_id;
std::string device_id =
- user_manager::UserManager::Get()->GetKnownUserDeviceId(
- user_context.GetAccountId());
+ user_manager::known_user::GetDeviceId(user_context.GetAccountId());
if (device_id.empty()) {
bool is_ephemeral = ChromeUserManager::Get()->AreEphemeralUsersEnabled() &&
user_context.GetAccountId() !=
@@ -1077,8 +1077,8 @@ void ExistingUserController::DoCompleteLogin(
const std::string& gaps_cookie = user_context.GetGAPSCookie();
if (!gaps_cookie.empty()) {
- user_manager::UserManager::Get()->SetKnownUserGAPSCookie(
- user_context.GetAccountId(), gaps_cookie);
+ user_manager::known_user::SetGAPSCookie(user_context.GetAccountId(),
+ gaps_cookie);
}
PerformPreLoginActions(user_context);
diff --git a/chrome/browser/chromeos/login/reauth_stats.cc b/chrome/browser/chromeos/login/reauth_stats.cc
index f392465..4920f87 100644
--- a/chrome/browser/chromeos/login/reauth_stats.cc
+++ b/chrome/browser/chromeos/login/reauth_stats.cc
@@ -5,31 +5,30 @@
#include "chrome/browser/chromeos/login/reauth_stats.h"
#include "base/metrics/histogram_macros.h"
-#include "components/user_manager/user_manager.h"
+#include "components/user_manager/known_user.h"
namespace chromeos {
void RecordReauthReason(const AccountId& account_id, ReauthReason reason) {
- user_manager::UserManager* user_manager = user_manager::UserManager::Get();
int old_reason;
// We record only the first value, skipping everything else, except "none"
// value, which is used to reset the current state.
- if (!user_manager->FindReauthReason(account_id, &old_reason) ||
+ if (!user_manager::known_user::FindReauthReason(account_id, &old_reason) ||
(static_cast<ReauthReason>(old_reason) == ReauthReason::NONE &&
reason != ReauthReason::NONE)) {
- user_manager->UpdateReauthReason(account_id, static_cast<int>(reason));
+ user_manager::known_user::UpdateReauthReason(account_id,
+ static_cast<int>(reason));
}
}
void SendReauthReason(const AccountId& account_id) {
- user_manager::UserManager* user_manager = user_manager::UserManager::Get();
int reauth_reason;
- if (user_manager->FindReauthReason(account_id, &reauth_reason) &&
+ if (user_manager::known_user::FindReauthReason(account_id, &reauth_reason) &&
static_cast<ReauthReason>(reauth_reason) != ReauthReason::NONE) {
UMA_HISTOGRAM_ENUMERATION("Login.ReauthReason", reauth_reason,
NUM_REAUTH_FLOW_REASONS);
- user_manager->UpdateReauthReason(account_id,
- static_cast<int>(ReauthReason::NONE));
+ user_manager::known_user::UpdateReauthReason(
+ account_id, static_cast<int>(ReauthReason::NONE));
}
}
diff --git a/chrome/browser/chromeos/login/screens/chrome_user_selection_screen.cc b/chrome/browser/chromeos/login/screens/chrome_user_selection_screen.cc
index 4d00564..d8bd84b 100644
--- a/chrome/browser/chromeos/login/screens/chrome_user_selection_screen.cc
+++ b/chrome/browser/chromeos/login/screens/chrome_user_selection_screen.cc
@@ -22,6 +22,7 @@
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
@@ -78,8 +79,7 @@ void ChromeUserSelectionScreen::OnDeviceLocalAccountsChanged() {
void ChromeUserSelectionScreen::CheckForPublicSessionDisplayNameChange(
policy::DeviceLocalAccountPolicyBroker* broker) {
const AccountId& account_id =
- user_manager::UserManager::GetKnownUserAccountId(broker->user_id(),
- std::string());
+ user_manager::known_user::GetAccountId(broker->user_id(), std::string());
DCHECK(account_id.is_valid());
const std::string& display_name = broker->GetDisplayName();
if (display_name == public_session_display_names_[account_id])
@@ -110,8 +110,7 @@ void ChromeUserSelectionScreen::CheckForPublicSessionDisplayNameChange(
void ChromeUserSelectionScreen::CheckForPublicSessionLocalePolicyChange(
policy::DeviceLocalAccountPolicyBroker* broker) {
const AccountId& account_id =
- user_manager::UserManager::GetKnownUserAccountId(broker->user_id(),
- std::string());
+ user_manager::known_user::GetAccountId(broker->user_id(), std::string());
DCHECK(account_id.is_valid());
const policy::PolicyMap::Entry* entry =
broker->core()->store()->policy_map().Get(policy::key::kSessionLocales);
diff --git a/chrome/browser/chromeos/login/screens/user_selection_screen.cc b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
index 68609e6..444c60e 100644
--- a/chrome/browser/chromeos/login/screens/user_selection_screen.cc
+++ b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "components/proximity_auth/screenlock_bridge.h"
#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
#include "ui/base/user_activity/user_activity_detector.h"
@@ -172,8 +173,7 @@ void UserSelectionScreen::FillUserDictionary(
void UserSelectionScreen::FillKnownUserPrefs(user_manager::User* user,
base::DictionaryValue* user_dict) {
std::string gaia_id;
- if (user_manager::UserManager::Get()->FindGaiaID(user->GetAccountId(),
- &gaia_id)) {
+ if (user_manager::known_user::FindGaiaID(user->GetAccountId(), &gaia_id)) {
user_dict->SetString(kKeyGaiaID, gaia_id);
}
}
@@ -349,8 +349,8 @@ void UserSelectionScreen::SendUserList() {
std::string owner_email;
chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner,
&owner_email);
- const AccountId owner = user_manager::UserManager::GetKnownUserAccountId(
- owner_email, std::string());
+ const AccountId owner =
+ user_manager::known_user::GetAccountId(owner_email, std::string());
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -412,8 +412,7 @@ void UserSelectionScreen::CheckUserStatus(const AccountId& account_id) {
return;
if (!token_handle_util_.get()) {
- token_handle_util_.reset(
- new TokenHandleUtil(user_manager::UserManager::Get()));
+ token_handle_util_.reset(new TokenHandleUtil());
}
if (token_handle_util_->HasToken(account_id)) {
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc
index 0df31bf..04eb05f 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -94,6 +94,7 @@
#include "components/signin/core/account_id/account_id.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager_base.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
@@ -466,8 +467,8 @@ void UserSessionManager::StartSession(
NotifyUserLoggedIn();
if (!user_context.GetDeviceId().empty()) {
- user_manager::UserManager::Get()->SetKnownUserDeviceId(
- user_context.GetAccountId(), user_context.GetDeviceId());
+ user_manager::known_user::SetDeviceId(user_context.GetAccountId(),
+ user_context.GetDeviceId());
}
PrepareProfile();
@@ -864,8 +865,8 @@ void UserSessionManager::PreStartSession() {
void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() {
// Store obfuscated GAIA ID.
if (!user_context_.GetGaiaID().empty()) {
- user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetAccountId(),
- user_context_.GetGaiaID());
+ user_manager::known_user::UpdateGaiaID(user_context_.GetAccountId(),
+ user_context_.GetGaiaID());
}
}
@@ -981,10 +982,11 @@ void UserSessionManager::InitProfilePreferences(
// Backfill GAIA ID in user prefs stored in Local State.
std::string tmp_gaia_id;
- user_manager::UserManager* user_manager = user_manager::UserManager::Get();
- if (!user_manager->FindGaiaID(user_context.GetAccountId(), &tmp_gaia_id) &&
+ if (!user_manager::known_user::FindGaiaID(user_context.GetAccountId(),
+ &tmp_gaia_id) &&
!gaia_id.empty()) {
- user_manager->UpdateGaiaID(user_context.GetAccountId(), gaia_id);
+ user_manager::known_user::UpdateGaiaID(user_context.GetAccountId(),
+ gaia_id);
}
}
}
@@ -1090,7 +1092,8 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) {
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
if (user_manager->IsLoggedInAsUserWithGaiaAccount()) {
if (user_context_.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITH_SAML)
- user_manager->UpdateUsingSAML(user_context_.GetAccountId(), true);
+ user_manager::known_user::UpdateUsingSAML(user_context_.GetAccountId(),
+ true);
SAMLOfflineSigninLimiter* saml_offline_signin_limiter =
SAMLOfflineSigninLimiterFactory::GetForProfile(profile);
if (saml_offline_signin_limiter)
@@ -1763,8 +1766,7 @@ void UserSessionManager::Shutdown() {
void UserSessionManager::CreateTokenUtilIfMissing() {
if (!token_handle_util_.get())
- token_handle_util_.reset(
- new TokenHandleUtil(user_manager::UserManager::Get()));
+ token_handle_util_.reset(new TokenHandleUtil());
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/signin/device_id_browsertest.cc b/chrome/browser/chromeos/login/signin/device_id_browsertest.cc
index 1a1efdb..5d9fbb0 100644
--- a/chrome/browser/chromeos/login/signin/device_id_browsertest.cc
+++ b/chrome/browser/chromeos/login/signin/device_id_browsertest.cc
@@ -19,6 +19,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chromeos/chromeos_switches.h"
#include "components/signin/core/common/signin_pref_names.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/remove_user_delegate.h"
#include "components/user_manager/user_manager.h"
@@ -58,7 +59,7 @@ class DeviceIDTest : public OobeBaseTest,
}
std::string GetDeviceId(const AccountId& account_id) {
- return user_manager::UserManager::Get()->GetKnownUserDeviceId(account_id);
+ return user_manager::known_user::GetDeviceId(account_id);
}
std::string GetDeviceIdFromSigninClient(const AccountId& account_id) {
@@ -253,7 +254,7 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_Migration) {
// Can't use SetKnownUserDeviceId here, because it forbids changing a device
// ID.
- user_manager::UserManager::Get()->SetKnownUserStringPref(
+ user_manager::known_user::SetStringPref(
AccountId::FromUserEmail(kFakeUserEmail), "device_id", std::string());
}
@@ -280,7 +281,7 @@ IN_PROC_BROWSER_TEST_F(DeviceIDTest, PRE_LegacyUsers) {
// Can't use SetKnownUserDeviceId here, because it forbids changing a device
// ID.
- user_manager::UserManager::Get()->SetKnownUserStringPref(
+ user_manager::known_user::SetStringPref(
AccountId::FromUserEmail(kFakeUserEmail), "device_id", std::string());
}
diff --git a/chrome/browser/chromeos/login/signin/token_handle_util.cc b/chrome/browser/chromeos/login/signin/token_handle_util.cc
index 5304a94..1ca6f04 100644
--- a/chrome/browser/chromeos/login/signin/token_handle_util.cc
+++ b/chrome/browser/chromeos/login/signin/token_handle_util.cc
@@ -9,7 +9,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
-#include "components/user_manager/user_manager.h"
+#include "components/user_manager/known_user.h"
#include "google_apis/gaia/gaia_oauth_client.h"
namespace {
@@ -25,9 +25,7 @@ static const int kMaxRetries = 3;
} // namespace
-TokenHandleUtil::TokenHandleUtil(user_manager::UserManager* user_manager)
- : user_manager_(user_manager), weak_factory_(this) {
-}
+TokenHandleUtil::TokenHandleUtil() : weak_factory_(this) {}
TokenHandleUtil::~TokenHandleUtil() {
weak_factory_.InvalidateWeakPtrs();
@@ -37,7 +35,7 @@ TokenHandleUtil::~TokenHandleUtil() {
bool TokenHandleUtil::HasToken(const AccountId& account_id) {
const base::DictionaryValue* dict = nullptr;
std::string token;
- if (!user_manager_->FindKnownUserPrefs(account_id, &dict))
+ if (!user_manager::known_user::FindPrefs(account_id, &dict))
return false;
if (!dict->GetString(kTokenHandlePref, &token))
return false;
@@ -47,7 +45,7 @@ bool TokenHandleUtil::HasToken(const AccountId& account_id) {
bool TokenHandleUtil::ShouldObtainHandle(const AccountId& account_id) {
const base::DictionaryValue* dict = nullptr;
std::string token;
- if (!user_manager_->FindKnownUserPrefs(account_id, &dict))
+ if (!user_manager::known_user::FindPrefs(account_id, &dict))
return true;
if (!dict->GetString(kTokenHandlePref, &token))
return true;
@@ -60,25 +58,25 @@ bool TokenHandleUtil::ShouldObtainHandle(const AccountId& account_id) {
void TokenHandleUtil::DeleteHandle(const AccountId& account_id) {
const base::DictionaryValue* dict = nullptr;
- if (!user_manager_->FindKnownUserPrefs(account_id, &dict))
+ if (!user_manager::known_user::FindPrefs(account_id, &dict))
return;
scoped_ptr<base::DictionaryValue> dict_copy(dict->DeepCopy());
dict_copy->Remove(kTokenHandlePref, nullptr);
dict_copy->Remove(kTokenHandleStatusPref, nullptr);
- user_manager_->UpdateKnownUserPrefs(account_id, *dict_copy.get(),
- /* replace values */ true);
+ user_manager::known_user::UpdatePrefs(account_id, *dict_copy.get(),
+ /* replace values */ true);
}
void TokenHandleUtil::MarkHandleInvalid(const AccountId& account_id) {
- user_manager_->SetKnownUserStringPref(account_id, kTokenHandleStatusPref,
- kHandleStatusInvalid);
+ user_manager::known_user::SetStringPref(account_id, kTokenHandleStatusPref,
+ kHandleStatusInvalid);
}
void TokenHandleUtil::CheckToken(const AccountId& account_id,
const TokenValidationCallback& callback) {
const base::DictionaryValue* dict = nullptr;
std::string token;
- if (!user_manager_->FindKnownUserPrefs(account_id, &dict)) {
+ if (!user_manager::known_user::FindPrefs(account_id, &dict)) {
callback.Run(account_id, UNKNOWN);
return;
}
@@ -102,9 +100,9 @@ void TokenHandleUtil::CheckToken(const AccountId& account_id,
void TokenHandleUtil::StoreTokenHandle(const AccountId& account_id,
const std::string& handle) {
- user_manager_->SetKnownUserStringPref(account_id, kTokenHandlePref, handle);
- user_manager_->SetKnownUserStringPref(account_id, kTokenHandleStatusPref,
- kHandleStatusValid);
+ user_manager::known_user::SetStringPref(account_id, kTokenHandlePref, handle);
+ user_manager::known_user::SetStringPref(account_id, kTokenHandleStatusPref,
+ kHandleStatusValid);
}
void TokenHandleUtil::OnValidationComplete(const std::string& token) {
diff --git a/chrome/browser/chromeos/login/signin/token_handle_util.h b/chrome/browser/chromeos/login/signin/token_handle_util.h
index 20ef090..8520966 100644
--- a/chrome/browser/chromeos/login/signin/token_handle_util.h
+++ b/chrome/browser/chromeos/login/signin/token_handle_util.h
@@ -21,17 +21,13 @@ namespace base {
class DictionaryValue;
}
-namespace user_manager {
-class UserManager;
-}
-
// This class is responsible for operations with External Token Handle.
// Handle is an extra token associated with OAuth refresh token that have
// exactly same lifetime. It is not secure, and it's only purpose is checking
// validity of corresponding refresh token in the insecure environment.
class TokenHandleUtil {
public:
- explicit TokenHandleUtil(user_manager::UserManager* user_manager);
+ TokenHandleUtil();
~TokenHandleUtil();
enum TokenHandleStatus { VALID, INVALID, UNKNOWN };
@@ -88,9 +84,6 @@ class TokenHandleUtil {
void OnValidationComplete(const std::string& token);
void OnObtainTokenComplete(const AccountId& account_id);
- // UserManager that stores corresponding user data.
- user_manager::UserManager* user_manager_;
-
// Map of pending check operations.
base::ScopedPtrHashMap<std::string, scoped_ptr<TokenDelegate>>
validation_delegates_;
diff --git a/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc b/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc
index 4b79a97..e026c5a 100644
--- a/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc
@@ -56,6 +56,7 @@
#include "chromeos/timezone/timezone_resolver.h"
#include "components/session_manager/core/session_manager.h"
#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/remove_user_delegate.h"
#include "components/user_manager/user_image/user_image.h"
#include "components/user_manager/user_type.h"
@@ -439,8 +440,7 @@ void ChromeUserManagerImpl::Observe(
void ChromeUserManagerImpl::OnExternalDataSet(const std::string& policy,
const std::string& user_id) {
const AccountId account_id =
- user_manager::UserManager::Get()->GetKnownUserAccountId(user_id,
- std::string());
+ user_manager::known_user::GetAccountId(user_id, std::string());
if (policy == policy::key::kUserAvatarImage)
GetUserImageManager(account_id)->OnExternalDataSet(policy);
else if (policy == policy::key::kWallpaperImage)
@@ -452,8 +452,7 @@ void ChromeUserManagerImpl::OnExternalDataSet(const std::string& policy,
void ChromeUserManagerImpl::OnExternalDataCleared(const std::string& policy,
const std::string& user_id) {
const AccountId account_id =
- user_manager::UserManager::Get()->GetKnownUserAccountId(user_id,
- std::string());
+ user_manager::known_user::GetAccountId(user_id, std::string());
if (policy == policy::key::kUserAvatarImage)
GetUserImageManager(account_id)->OnExternalDataCleared(policy);
else if (policy == policy::key::kWallpaperImage)
@@ -467,8 +466,7 @@ void ChromeUserManagerImpl::OnExternalDataFetched(
const std::string& user_id,
scoped_ptr<std::string> data) {
const AccountId account_id =
- user_manager::UserManager::Get()->GetKnownUserAccountId(user_id,
- std::string());
+ user_manager::known_user::GetAccountId(user_id, std::string());
if (policy == policy::key::kUserAvatarImage)
GetUserImageManager(account_id)->OnExternalDataFetched(policy, data.Pass());
else if (policy == policy::key::kWallpaperImage)
@@ -479,8 +477,7 @@ void ChromeUserManagerImpl::OnExternalDataFetched(
void ChromeUserManagerImpl::OnPolicyUpdated(const std::string& user_id) {
const AccountId account_id =
- user_manager::UserManager::Get()->GetKnownUserAccountId(user_id,
- std::string());
+ user_manager::known_user::GetAccountId(user_id, std::string());
const user_manager::User* user = FindUser(account_id);
if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT)
return;
@@ -1156,8 +1153,7 @@ void ChromeUserManagerImpl::SetUserAffiliation(
const std::string& user_email,
const AffiliationIDSet& user_affiliation_ids) {
const AccountId& account_id =
- user_manager::UserManager::GetKnownUserAccountId(user_email,
- std::string());
+ user_manager::known_user::GetAccountId(user_email, std::string());
user_manager::User* user = FindUserAndModify(account_id);
if (user) {
diff --git a/chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc b/chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc
index 763f5b2..0d4812f 100644
--- a/chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc
+++ b/chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc
@@ -188,15 +188,4 @@ UserFlow* FakeChromeUserManager::GetDefaultUserFlow() const {
return default_flow_.get();
}
-bool FakeChromeUserManager::FindKnownUserPrefs(
- const AccountId& account_id,
- const base::DictionaryValue** out_value) {
- return false;
-}
-
-void FakeChromeUserManager::UpdateKnownUserPrefs(
- const AccountId& account_id,
- const base::DictionaryValue& values,
- bool clear) {}
-
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/users/fake_chrome_user_manager.h b/chrome/browser/chromeos/login/users/fake_chrome_user_manager.h
index 608c1ff..dc30613 100644
--- a/chrome/browser/chromeos/login/users/fake_chrome_user_manager.h
+++ b/chrome/browser/chromeos/login/users/fake_chrome_user_manager.h
@@ -62,11 +62,6 @@ class FakeChromeUserManager : public user_manager::FakeUserManager,
void RemoveUser(const AccountId& account_id,
user_manager::RemoveUserDelegate* delegate) override;
void RemoveUserFromList(const AccountId& account_id) override;
- bool FindKnownUserPrefs(const AccountId& account_id,
- const base::DictionaryValue** out_value) override;
- void UpdateKnownUserPrefs(const AccountId& account_id,
- const base::DictionaryValue& values,
- bool clear) override;
void set_owner_id(const AccountId& owner_account_id) {
owner_account_id_ = owner_account_id;
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index c5336f7..e0810c8 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -38,7 +38,9 @@
#include "components/feedback/tracing_manager.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/syncable_prefs/pref_service_syncable.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user.h"
+#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
#include "ui/base/ime/chromeos/extension_ime_util.h"
@@ -625,8 +627,8 @@ void Preferences::ApplyPreferences(ApplyReason reason,
if (pref_name == prefs::kUse24HourClock ||
reason != REASON_ACTIVE_USER_CHANGED) {
const bool value = prefs_->GetBoolean(prefs::kUse24HourClock);
- user_manager::UserManager::Get()->SetKnownUserBooleanPref(
- user_->GetAccountId(), prefs::kUse24HourClock, value);
+ user_manager::known_user::SetBooleanPref(user_->GetAccountId(),
+ prefs::kUse24HourClock, value);
}
}
diff --git a/chrome/browser/signin/chrome_signin_client.cc b/chrome/browser/signin/chrome_signin_client.cc
index ba280aa..6995990 100644
--- a/chrome/browser/signin/chrome_signin_client.cc
+++ b/chrome/browser/signin/chrome_signin_client.cc
@@ -39,6 +39,7 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/net/delay_network_call.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
#endif
@@ -63,20 +64,19 @@ ChromeSigninClient::ChromeSigninClient(
chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
if (!user)
return;
- auto* user_manager = user_manager::UserManager::Get();
const AccountId account_id = user->GetAccountId();
- if (user_manager->GetKnownUserDeviceId(account_id).empty()) {
+ if (user_manager::known_user::GetDeviceId(account_id).empty()) {
const std::string legacy_device_id =
GetPrefs()->GetString(prefs::kGoogleServicesSigninScopedDeviceId);
if (!legacy_device_id.empty()) {
// Need to move device ID from the old location to the new one, if it has
// not been done yet.
- user_manager->SetKnownUserDeviceId(account_id, legacy_device_id);
+ user_manager::known_user::SetDeviceId(account_id, legacy_device_id);
} else {
- user_manager->SetKnownUserDeviceId(
- account_id,
- GenerateSigninScopedDeviceID(
- user_manager->IsUserNonCryptohomeDataEphemeral(account_id)));
+ user_manager::known_user::SetDeviceId(
+ account_id, GenerateSigninScopedDeviceID(
+ user_manager::UserManager::Get()
+ ->IsUserNonCryptohomeDataEphemeral(account_id)));
}
}
GetPrefs()->SetString(prefs::kGoogleServicesSigninScopedDeviceId,
@@ -154,8 +154,7 @@ std::string ChromeSigninClient::GetSigninScopedDeviceId() {
return std::string();
const std::string signin_scoped_device_id =
- user_manager::UserManager::Get()->GetKnownUserDeviceId(
- user->GetAccountId());
+ user_manager::known_user::GetDeviceId(user->GetAccountId());
LOG_IF(ERROR, signin_scoped_device_id.empty())
<< "Device ID is not set for user.";
return signin_scoped_device_id;
diff --git a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
index d41dace..58cc105 100644
--- a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
@@ -35,6 +35,7 @@
#include "chromeos/system/devicetype.h"
#include "chromeos/system/version_loader.h"
#include "components/login/localized_values_builder.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h"
@@ -369,9 +370,8 @@ void GaiaScreenHandler::OnPortalDetectionCompleted(
}
void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) {
- if (!Delegate()->IsUserWhitelisted(
- user_manager::UserManager::Get()->GetKnownUserAccountId(
- user_email, std::string() /* gaia_id */)))
+ if (!Delegate()->IsUserWhitelisted(user_manager::known_user::GetAccountId(
+ user_email, std::string() /* gaia_id */)))
ShowWhitelistCheckFailedError();
}
@@ -415,8 +415,8 @@ AccountId GaiaScreenHandler::GetAccountId(
const std::string canonicalized_email =
gaia::CanonicalizeEmail(gaia::SanitizeEmail(authenticated_email));
- const AccountId account_id = user_manager::UserManager::GetKnownUserAccountId(
- authenticated_email, gaia_id);
+ const AccountId account_id =
+ user_manager::known_user::GetAccountId(authenticated_email, gaia_id);
if (account_id.GetUserEmail() != canonicalized_email) {
LOG(WARNING) << "Existing user '" << account_id.GetUserEmail()
@@ -666,9 +666,8 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
if (populated_email_.empty()) {
Delegate()->LoadSigninWallpaper();
} else {
- Delegate()->LoadWallpaper(
- user_manager::UserManager::Get()->GetKnownUserAccountId(
- populated_email_, std::string()));
+ Delegate()->LoadWallpaper(user_manager::known_user::GetAccountId(
+ populated_email_, std::string()));
}
input_method::InputMethodManager* imm =
@@ -769,15 +768,14 @@ void GaiaScreenHandler::LoadAuthExtension(bool force,
std::string gaia_id;
if (!context.email.empty() &&
- user_manager::UserManager::Get()->FindGaiaID(
+ user_manager::known_user::FindGaiaID(
AccountId::FromUserEmail(context.email), &gaia_id)) {
context.gaia_id = gaia_id;
}
if (!context.email.empty()) {
- context.gaps_cookie =
- user_manager::UserManager::Get()->GetKnownUserGAPSCookie(
- AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email)));
+ context.gaps_cookie = user_manager::known_user::GetGAPSCookie(
+ AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email)));
}
populated_email_.clear();
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index b1cb3c2..e208438 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -69,6 +69,7 @@
#include "chromeos/network/network_state_handler.h"
#include "components/login/localized_values_builder.h"
#include "components/proximity_auth/screenlock_bridge.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
@@ -1230,7 +1231,7 @@ void SigninScreenHandler::HandleFocusPod(const AccountId& account_id) {
test_focus_pod_callback_.Run();
bool use_24hour_clock = false;
- if (user_manager::UserManager::Get()->GetKnownUserBooleanPref(
+ if (user_manager::known_user::GetBooleanPref(
account_id, prefs::kUse24HourClock, &use_24hour_clock)) {
g_browser_process->platform_part()
->GetSystemClock()
@@ -1282,7 +1283,7 @@ void SigninScreenHandler::HandleFirstIncorrectPasswordAttempt(
const AccountId& account_id) {
// TODO(ginkage): Fix this case once crbug.com/469987 is ready.
/*
- if (user_manager::UserManager::Get()->FindUsingSAML(email))
+ if (user_manager::known_user::IsUsingSAML(email))
RecordReauthReason(email, ReauthReason::INCORRECT_SAML_PASSWORD_ENTERED);
*/
}
diff --git a/chrome/browser/ui/webui/options/chromeos/user_image_source.cc b/chrome/browser/ui/webui/options/chromeos/user_image_source.cc
index 790543c..c7a05e3 100644
--- a/chrome/browser/ui/webui/options/chromeos/user_image_source.cc
+++ b/chrome/browser/ui/webui/options/chromeos/user_image_source.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_split.h"
#include "chrome/common/url_constants.h"
#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/user_image/default_user_images.h"
#include "components/user_manager/user_manager.h"
#include "grit/theme_resources.h"
@@ -36,7 +37,7 @@ void ParseRequest(const GURL& url,
// migrated.
if (!status) {
LOG(WARNING) << "Failed to deserialize '" << serialized_account_id << "'";
- account_id = user_manager::UserManager::Get()->GetKnownUserAccountId(
+ account_id = user_manager::known_user::GetAccountId(
serialized_account_id, std::string() /* gaia_id */);
}
*email = account_id.GetUserEmail();
diff --git a/components/user_manager.gypi b/components/user_manager.gypi
index 67f090d..3fcb019 100644
--- a/components/user_manager.gypi
+++ b/components/user_manager.gypi
@@ -16,6 +16,8 @@
],
# Chrome OS user_manager sources.
'user_manager_chromeos_sources': [
+ 'user_manager/known_user.cc',
+ 'user_manager/known_user.h',
'user_manager/remove_user_delegate.h',
'user_manager/user.cc',
'user_manager/user.h',
diff --git a/components/user_manager/BUILD.gn b/components/user_manager/BUILD.gn
index 55ab2a2..1c4019c 100644
--- a/components/user_manager/BUILD.gn
+++ b/components/user_manager/BUILD.gn
@@ -24,6 +24,8 @@ component("user_manager") {
if (is_chromeos) {
sources += [
+ "known_user.cc",
+ "known_user.h",
"remove_user_delegate.h",
"user.cc",
"user.h",
diff --git a/components/user_manager/known_user.cc b/components/user_manager/known_user.cc
new file mode 100644
index 0000000..d78dff7
--- /dev/null
+++ b/components/user_manager/known_user.cc
@@ -0,0 +1,334 @@
+// Copyright 2015 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.
+
+#include "components/user_manager/known_user.h"
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/prefs/pref_registry_simple.h"
+#include "base/prefs/scoped_user_pref_update.h"
+#include "base/values.h"
+#include "chromeos/login/user_names.h"
+#include "components/user_manager/user_manager.h"
+#include "google_apis/gaia/gaia_auth_util.h"
+
+namespace user_manager {
+namespace known_user {
+namespace {
+
+// A vector pref of preferences of known users. All new preferences should be
+// placed in this list.
+const char kKnownUsers[] = "KnownUsers";
+
+// Known user preferences keys (stored in Local State).
+
+// Key of canonical e-mail value.
+const char kCanonicalEmail[] = "email";
+
+// Key of obfuscated GAIA id value.
+const char kGAIAIdKey[] = "gaia_id";
+
+// Key of whether this user ID refers to a SAML user.
+const char kUsingSAMLKey[] = "using_saml";
+
+// Key of Device Id.
+const char kDeviceId[] = "device_id";
+
+// Key of GAPS cookie.
+const char kGAPSCookie[] = "gaps_cookie";
+
+// Key of the reason for re-auth.
+const char kReauthReasonKey[] = "reauth_reason";
+
+PrefService* GetLocalState() {
+ UserManager* user_manager = UserManager::Get();
+ if (user_manager)
+ return user_manager->GetLocalState();
+
+ return nullptr;
+}
+
+// Checks if values in |dict| correspond with |account_id| identity.
+bool UserMatches(const AccountId& account_id,
+ const base::DictionaryValue& dict) {
+ std::string value;
+
+ // TODO(alemate): update code once user id is really a struct.
+ bool has_gaia_id = dict.GetString(kGAIAIdKey, &value);
+ if (has_gaia_id && account_id.GetGaiaId() == value)
+ return true;
+
+ bool has_email = dict.GetString(kCanonicalEmail, &value);
+ if (has_email && account_id.GetUserEmail() == value)
+ return true;
+
+ return false;
+}
+
+// Fills relevant |dict| values based on |account_id|.
+void UpdateIdentity(const AccountId& account_id, base::DictionaryValue& dict) {
+ dict.SetString(kCanonicalEmail, account_id.GetUserEmail());
+}
+
+} // namespace
+
+bool FindPrefs(const AccountId& account_id,
+ const base::DictionaryValue** out_value) {
+ PrefService* local_state = GetLocalState();
+
+ // Local State may not be initialized in tests.
+ if (!local_state)
+ return false;
+
+ // UserManager is usually NULL in unit tests.
+ UserManager* user_manager = UserManager::Get();
+ if (user_manager &&
+ user_manager->IsUserNonCryptohomeDataEphemeral(account_id))
+ return false;
+
+ const base::ListValue* known_users = local_state->GetList(kKnownUsers);
+ for (size_t i = 0; i < known_users->GetSize(); ++i) {
+ const base::DictionaryValue* element = nullptr;
+ if (known_users->GetDictionary(i, &element)) {
+ if (UserMatches(account_id, *element)) {
+ known_users->GetDictionary(i, out_value);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void UpdatePrefs(const AccountId& account_id,
+ const base::DictionaryValue& values,
+ bool clear) {
+ PrefService* local_state = GetLocalState();
+
+ // Local State may not be initialized in tests.
+ if (!local_state)
+ return;
+
+ // UserManager is usually NULL in unit tests.
+ UserManager* user_manager = UserManager::Get();
+ if (user_manager &&
+ user_manager->IsUserNonCryptohomeDataEphemeral(account_id))
+ return;
+
+ ListPrefUpdate update(local_state, kKnownUsers);
+ for (size_t i = 0; i < update->GetSize(); ++i) {
+ base::DictionaryValue* element = nullptr;
+ if (update->GetDictionary(i, &element)) {
+ if (UserMatches(account_id, *element)) {
+ if (clear)
+ element->Clear();
+ element->MergeDictionary(&values);
+ UpdateIdentity(account_id, *element);
+ return;
+ }
+ }
+ }
+ scoped_ptr<base::DictionaryValue> new_value(new base::DictionaryValue());
+ new_value->MergeDictionary(&values);
+ UpdateIdentity(account_id, *new_value);
+ update->Append(new_value.release());
+}
+
+bool GetStringPref(const AccountId& account_id,
+ const std::string& path,
+ std::string* out_value) {
+ const base::DictionaryValue* user_pref_dict = nullptr;
+ if (!FindPrefs(account_id, &user_pref_dict))
+ return false;
+
+ return user_pref_dict->GetString(path, out_value);
+}
+
+void SetStringPref(const AccountId& account_id,
+ const std::string& path,
+ const std::string& in_value) {
+ PrefService* local_state = GetLocalState();
+
+ // Local State may not be initialized in tests.
+ if (!local_state)
+ return;
+
+ ListPrefUpdate update(local_state, kKnownUsers);
+ base::DictionaryValue dict;
+ dict.SetString(path, in_value);
+ UpdatePrefs(account_id, dict, false);
+}
+
+bool GetBooleanPref(const AccountId& account_id,
+ const std::string& path,
+ bool* out_value) {
+ const base::DictionaryValue* user_pref_dict = nullptr;
+ if (!FindPrefs(account_id, &user_pref_dict))
+ return false;
+
+ return user_pref_dict->GetBoolean(path, out_value);
+}
+
+void SetBooleanPref(const AccountId& account_id,
+ const std::string& path,
+ const bool in_value) {
+ PrefService* local_state = GetLocalState();
+
+ // Local State may not be initialized in tests.
+ if (!local_state)
+ return;
+
+ ListPrefUpdate update(local_state, kKnownUsers);
+ base::DictionaryValue dict;
+ dict.SetBoolean(path, in_value);
+ UpdatePrefs(account_id, dict, false);
+}
+
+bool GetIntegerPref(const AccountId& account_id,
+ const std::string& path,
+ int* out_value) {
+ const base::DictionaryValue* user_pref_dict = nullptr;
+ if (!FindPrefs(account_id, &user_pref_dict))
+ return false;
+ return user_pref_dict->GetInteger(path, out_value);
+}
+
+void SetIntegerPref(const AccountId& account_id,
+ const std::string& path,
+ const int in_value) {
+ PrefService* local_state = GetLocalState();
+
+ // Local State may not be initialized in tests.
+ if (!local_state)
+ return;
+
+ ListPrefUpdate update(local_state, kKnownUsers);
+ base::DictionaryValue dict;
+ dict.SetInteger(path, in_value);
+ UpdatePrefs(account_id, dict, false);
+}
+
+AccountId GetAccountId(const std::string& user_email,
+ const std::string& gaia_id) {
+ // In tests empty accounts are possible.
+ if (user_email.empty() && gaia_id.empty())
+ return EmptyAccountId();
+
+ if (user_email == chromeos::login::kStubUser)
+ return chromeos::login::StubAccountId();
+
+ if (user_email == chromeos::login::kGuestUserName)
+ return chromeos::login::GuestAccountId();
+
+ // We can have several users with the same gaia_id but different e-mails.
+ // The opposite case is not possible.
+ std::string stored_gaia_id;
+ const std::string sanitized_email =
+ user_email.empty()
+ ? std::string()
+ : gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_email));
+
+ if (!sanitized_email.empty() &&
+ GetStringPref(AccountId::FromUserEmail(sanitized_email), kGAIAIdKey,
+ &stored_gaia_id)) {
+ if (!gaia_id.empty() && gaia_id != stored_gaia_id)
+ LOG(ERROR) << "User gaia id has changed. Sync will not work.";
+
+ // gaia_id is associated with cryptohome.
+ return AccountId::FromUserEmailGaiaId(sanitized_email, stored_gaia_id);
+ }
+
+ std::string stored_email;
+ // GetStringPref() returns the first user record that matches
+ // given ID. So we will get the first one if there are multiples.
+ if (!gaia_id.empty() && GetStringPref(AccountId::FromGaiaId(gaia_id),
+ kCanonicalEmail, &stored_email)) {
+ return AccountId::FromUserEmailGaiaId(stored_email, gaia_id);
+ }
+
+ return (gaia_id.empty()
+ ? AccountId::FromUserEmail(user_email)
+ : AccountId::FromUserEmailGaiaId(user_email, gaia_id));
+}
+
+void UpdateGaiaID(const AccountId& account_id, const std::string& gaia_id) {
+ SetStringPref(account_id, kGAIAIdKey, gaia_id);
+}
+
+bool FindGaiaID(const AccountId& account_id, std::string* out_value) {
+ return GetStringPref(account_id, kGAIAIdKey, out_value);
+}
+
+void SetDeviceId(const AccountId& account_id, const std::string& device_id) {
+ const std::string known_device_id = GetDeviceId(account_id);
+ if (!known_device_id.empty() && device_id != known_device_id) {
+ NOTREACHED() << "Trying to change device ID for known user.";
+ }
+ SetStringPref(account_id, kDeviceId, device_id);
+}
+
+std::string GetDeviceId(const AccountId& account_id) {
+ std::string device_id;
+ if (GetStringPref(account_id, kDeviceId, &device_id)) {
+ return device_id;
+ }
+ return std::string();
+}
+
+void SetGAPSCookie(const AccountId& account_id,
+ const std::string& gaps_cookie) {
+ SetStringPref(account_id, kGAPSCookie, gaps_cookie);
+}
+
+std::string GetGAPSCookie(const AccountId& account_id) {
+ std::string gaps_cookie;
+ if (GetStringPref(account_id, kGAPSCookie, &gaps_cookie)) {
+ return gaps_cookie;
+ }
+ return std::string();
+}
+
+void UpdateUsingSAML(const AccountId& account_id, const bool using_saml) {
+ SetBooleanPref(account_id, kUsingSAMLKey, using_saml);
+}
+
+bool IsUsingSAML(const AccountId& account_id) {
+ bool using_saml;
+ if (GetBooleanPref(account_id, kUsingSAMLKey, &using_saml))
+ return using_saml;
+ return false;
+}
+
+void UpdateReauthReason(const AccountId& account_id, const int reauth_reason) {
+ SetIntegerPref(account_id, kReauthReasonKey, reauth_reason);
+}
+
+bool FindReauthReason(const AccountId& account_id, int* out_value) {
+ return GetIntegerPref(account_id, kReauthReasonKey, out_value);
+}
+
+void RemovePrefs(const AccountId& account_id) {
+ PrefService* local_state = GetLocalState();
+
+ // Local State may not be initialized in tests.
+ if (!local_state)
+ return;
+
+ ListPrefUpdate update(local_state, kKnownUsers);
+ for (size_t i = 0; i < update->GetSize(); ++i) {
+ base::DictionaryValue* element = nullptr;
+ if (update->GetDictionary(i, &element)) {
+ if (UserMatches(account_id, *element)) {
+ update->Remove(i, nullptr);
+ break;
+ }
+ }
+ }
+}
+
+void RegisterPrefs(PrefRegistrySimple* registry) {
+ registry->RegisterListPref(kKnownUsers);
+}
+
+} // namespace known_user
+} // namespace user_manager
diff --git a/components/user_manager/known_user.h b/components/user_manager/known_user.h
new file mode 100644
index 0000000..03528dc
--- /dev/null
+++ b/components/user_manager/known_user.h
@@ -0,0 +1,132 @@
+// Copyright 2015 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 COMPONENTS_USER_MANAGER_KNOWN_USER_H_
+#define COMPONENTS_USER_MANAGER_KNOWN_USER_H_
+
+#include <string>
+
+#include "components/user_manager/user_manager_export.h"
+
+class AccountId;
+class PrefRegistrySimple;
+
+namespace base {
+class DictionaryValue;
+class ListValue;
+class TaskRunner;
+}
+
+namespace user_manager {
+namespace known_user {
+// Methods for storage/retrieval of per-user properties in Local State.
+
+// Performs a lookup of properties associated with |account_id|. If found,
+// returns |true| and fills |out_value|. |out_value| can be NULL, if
+// only existence check is required.
+bool USER_MANAGER_EXPORT FindPrefs(const AccountId& account_id,
+ const base::DictionaryValue** out_value);
+
+// Updates (or creates) properties associated with |account_id| based
+// on |values|. |clear| defines if existing properties are cleared (|true|)
+// or if it is just a incremental update (|false|).
+void USER_MANAGER_EXPORT UpdatePrefs(const AccountId& account_id,
+ const base::DictionaryValue& values,
+ bool clear);
+
+// Returns true if |account_id| preference by |path| does exist,
+// fills in |out_value|. Otherwise returns false.
+bool USER_MANAGER_EXPORT GetStringPref(const AccountId& account_id,
+ const std::string& path,
+ std::string* out_value);
+
+// Updates user's identified by |account_id| string preference |path|.
+void USER_MANAGER_EXPORT SetStringPref(const AccountId& account_id,
+ const std::string& path,
+ const std::string& in_value);
+
+// Returns true if |account_id| preference by |path| does exist,
+// fills in |out_value|. Otherwise returns false.
+bool USER_MANAGER_EXPORT GetBooleanPref(const AccountId& account_id,
+ const std::string& path,
+ bool* out_value);
+
+// Updates user's identified by |account_id| boolean preference |path|.
+void USER_MANAGER_EXPORT SetBooleanPref(const AccountId& account_id,
+ const std::string& path,
+ const bool in_value);
+
+// Returns true if |account_id| preference by |path| does exist,
+// fills in |out_value|. Otherwise returns false.
+bool USER_MANAGER_EXPORT GetIntegerPref(const AccountId& account_id,
+ const std::string& path,
+ int* out_value);
+
+// Updates user's identified by |account_id| integer preference |path|.
+void USER_MANAGER_EXPORT SetIntegerPref(const AccountId& account_id,
+ const std::string& path,
+ const int in_value);
+
+// This call forms full account id of a known user by email and (optionally)
+// gaia_id.
+// This is a temporary call while migrating to AccountId.
+AccountId USER_MANAGER_EXPORT GetAccountId(const std::string& user_email,
+ const std::string& gaia_id);
+
+// Updates |gaia_id| for user with |account_id|.
+// TODO(alemate): Update this once AccountId contains GAIA ID
+// (crbug.com/548926).
+void USER_MANAGER_EXPORT UpdateGaiaID(const AccountId& account_id,
+ const std::string& gaia_id);
+
+// Find GAIA ID for user with |account_id|, fill in |out_value| and return
+// true
+// if GAIA ID was found or false otherwise.
+// TODO(antrim): Update this once AccountId contains GAIA ID
+// (crbug.com/548926).
+bool USER_MANAGER_EXPORT FindGaiaID(const AccountId& account_id,
+ std::string* out_value);
+
+// Setter and getter for DeviceId known user string preference.
+void USER_MANAGER_EXPORT SetDeviceId(const AccountId& account_id,
+ const std::string& device_id);
+
+std::string USER_MANAGER_EXPORT GetDeviceId(const AccountId& account_id);
+
+// Setter and getter for GAPSCookie known user string preference.
+void USER_MANAGER_EXPORT SetGAPSCookie(const AccountId& account_id,
+ const std::string& gaps_cookie);
+
+std::string USER_MANAGER_EXPORT GetGAPSCookie(const AccountId& account_id);
+
+// Saves whether the user authenticates using SAML.
+void USER_MANAGER_EXPORT UpdateUsingSAML(const AccountId& account_id,
+ const bool using_saml);
+
+// Returns if SAML needs to be used for authentication of the user with
+// |account_id|, if it is known (was set by a |UpdateUsingSaml| call).
+// Otherwise
+// returns false.
+bool USER_MANAGER_EXPORT IsUsingSAML(const AccountId& account_id);
+
+// Saves why the user has to go through re-auth flow.
+void USER_MANAGER_EXPORT UpdateReauthReason(const AccountId& account_id,
+ const int reauth_reason);
+
+// Returns the reason why the user with |account_id| has to go through the
+// re-auth flow. Returns true if such a reason was recorded or false
+// otherwise.
+bool USER_MANAGER_EXPORT FindReauthReason(const AccountId& account_id,
+ int* out_value);
+
+// Removes all user preferences associated with |account_id|.
+// (This one used by user_manager only and thus not exported.)
+void RemovePrefs(const AccountId& account_id);
+
+// Register known user prefs.
+void USER_MANAGER_EXPORT RegisterPrefs(PrefRegistrySimple* registry);
+}
+} // namespace user_manager
+
+#endif // COMPONENTS_USER_MANAGER_KNOWN_USER_H_
diff --git a/components/user_manager/user_manager.cc b/components/user_manager/user_manager.cc
index 869b366..22425b8 100644
--- a/components/user_manager/user_manager.cc
+++ b/components/user_manager/user_manager.cc
@@ -87,27 +87,4 @@ UserManager* UserManager::SetForTesting(UserManager* user_manager) {
return previous_instance;
}
-// static
-AccountId UserManager::GetKnownUserAccountId(const std::string& user_email,
- const std::string& gaia_id) {
- // In tests empty accounts are possible.
- if (user_email.empty() && gaia_id.empty())
- return EmptyAccountId();
-
- if (user_email == chromeos::login::kStubUser)
- return chromeos::login::StubAccountId();
-
- if (user_email == chromeos::login::kGuestUserName)
- return chromeos::login::GuestAccountId();
-
- UserManager* user_manager = Get();
- if (user_manager)
- return user_manager->GetKnownUserAccountIdImpl(user_email, gaia_id);
-
- // This is fallback for tests.
- return (gaia_id.empty()
- ? AccountId::FromUserEmail(user_email)
- : AccountId::FromUserEmailGaiaId(user_email, gaia_id));
-}
-
} // namespace user_manager
diff --git a/components/user_manager/user_manager.h b/components/user_manager/user_manager.h
index 59cbbd9..d614086 100644
--- a/components/user_manager/user_manager.h
+++ b/components/user_manager/user_manager.h
@@ -12,6 +12,7 @@
#include "components/user_manager/user_type.h"
class AccountId;
+class PrefService;
namespace base {
class DictionaryValue;
@@ -315,109 +316,8 @@ class USER_MANAGER_EXPORT UserManager {
// Returns true if supervised users allowed.
virtual bool AreSupervisedUsersAllowed() const = 0;
- // Methods for storage/retrieval of per-user properties in Local State.
-
- // Performs a lookup of properties associated with |account_id|. If found,
- // returns |true| and fills |out_value|. |out_value| can be NULL, if
- // only existence check is required.
- virtual bool FindKnownUserPrefs(const AccountId& account_id,
- const base::DictionaryValue** out_value) = 0;
-
- // Updates (or creates) properties associated with |account_id| based
- // on |values|. |clear| defines if existing properties are cleared (|true|)
- // or if it is just a incremental update (|false|).
- virtual void UpdateKnownUserPrefs(const AccountId& account_id,
- const base::DictionaryValue& values,
- bool clear) = 0;
-
- // Returns true if |account_id| preference by |path| does exist,
- // fills in |out_value|. Otherwise returns false.
- virtual bool GetKnownUserStringPref(const AccountId& account_id,
- const std::string& path,
- std::string* out_value) = 0;
-
- // Updates user's identified by |account_id| string preference |path|.
- virtual void SetKnownUserStringPref(const AccountId& account_id,
- const std::string& path,
- const std::string& in_value) = 0;
-
- // Returns true if |account_id| preference by |path| does exist,
- // fills in |out_value|. Otherwise returns false.
- virtual bool GetKnownUserBooleanPref(const AccountId& account_id,
- const std::string& path,
- bool* out_value) = 0;
-
- // Updates user's identified by |account_id| boolean preference |path|.
- virtual void SetKnownUserBooleanPref(const AccountId& account_id,
- const std::string& path,
- const bool in_value) = 0;
-
- // Returns true if |account_id| preference by |path| does exist,
- // fills in |out_value|. Otherwise returns false.
- virtual bool GetKnownUserIntegerPref(const AccountId& account_id,
- const std::string& path,
- int* out_value) = 0;
-
- // Updates user's identified by |account_id| integer preference |path|.
- virtual void SetKnownUserIntegerPref(const AccountId& account_id,
- const std::string& path,
- const int in_value) = 0;
-
- // This call forms full account id of a known user by email and (optionally)
- // gaia_id.
- // This is a temporary call while migrating to AccountId.
- virtual AccountId GetKnownUserAccountIdImpl(const std::string& user_email,
- const std::string& gaia_id) = 0;
-
- // The same as above, but doesn't crash in unit_tests when Usermanager
- // doesn't exist.
- static AccountId GetKnownUserAccountId(const std::string& user_email,
- const std::string& gaia_id);
-
- // Updates |gaia_id| for user with |account_id|.
- // TODO(alemate): Update this once AccountId contains GAIA ID
- // (crbug.com/548926).
- virtual void UpdateGaiaID(const AccountId& account_id,
- const std::string& gaia_id) = 0;
-
- // Find GAIA ID for user with |account_id|, fill in |out_value| and return
- // true
- // if GAIA ID was found or false otherwise.
- // TODO(antrim): Update this once AccountId contains GAIA ID
- // (crbug.com/548926).
- virtual bool FindGaiaID(const AccountId& account_id,
- std::string* out_value) = 0;
-
- // Saves whether the user authenticates using SAML.
- virtual void UpdateUsingSAML(const AccountId& account_id,
- const bool using_saml) = 0;
-
- // Returns if SAML needs to be used for authentication of the user with
- // |account_id|, if it is known (was set by a |UpdateUsingSaml| call).
- // Otherwise
- // returns false.
- virtual bool FindUsingSAML(const AccountId& account_id) = 0;
-
- // Setter and getter for DeviceId known user string preference.
- virtual void SetKnownUserDeviceId(const AccountId& account_id,
- const std::string& device_id) = 0;
- virtual std::string GetKnownUserDeviceId(const AccountId& account_id) = 0;
-
- // Setter and getter for GAPSCookie known user string preference.
- virtual void SetKnownUserGAPSCookie(const AccountId& account_id,
- const std::string& gaps_cookie) = 0;
-
- virtual std::string GetKnownUserGAPSCookie(const AccountId& account_id) = 0;
-
- // Saves why the user has to go through re-auth flow.
- virtual void UpdateReauthReason(const AccountId& account_id,
- const int reauth_reason) = 0;
-
- // Returns the reason why the user with |account_id| has to go through the
- // re-auth flow. Returns true if such a reason was recorded or false
- // otherwise.
- virtual bool FindReauthReason(const AccountId& account_id,
- int* out_value) = 0;
+ // Returns "Local State" PrefService instance.
+ virtual PrefService* GetLocalState() const = 0;
protected:
// Sets UserManager instance.
diff --git a/components/user_manager/user_manager_base.cc b/components/user_manager/user_manager_base.cc
index bdeb438..7c8e865 100644
--- a/components/user_manager/user_manager_base.cc
+++ b/components/user_manager/user_manager_base.cc
@@ -29,6 +29,7 @@
#include "chromeos/login/login_state.h"
#include "chromeos/login/user_names.h"
#include "components/session_manager/core/session_manager.h"
+#include "components/user_manager/known_user.h"
#include "components/user_manager/remove_user_delegate.h"
#include "components/user_manager/user_type.h"
#include "google_apis/gaia/gaia_auth_util.h"
@@ -70,30 +71,6 @@ const char kLastLoggedInGaiaUser[] = "LastLoggedInRegularUser";
// session restore.
const char kLastActiveUser[] = "LastActiveUser";
-// A vector pref of preferences of known users. All new preferences should be
-// placed in this list.
-const char kKnownUsers[] = "KnownUsers";
-
-// Known user preferences keys (stored in Local State).
-
-// Key of canonical e-mail value.
-const char kCanonicalEmail[] = "email";
-
-// Key of obfuscated GAIA id value.
-const char kGAIAIdKey[] = "gaia_id";
-
-// Key of whether this user ID refers to a SAML user.
-const char kUsingSAMLKey[] = "using_saml";
-
-// Key of Device Id.
-const char kDeviceId[] = "device_id";
-
-// Key of GAPS cookie.
-const char kGAPSCookie[] = "gaps_cookie";
-
-// Key of the reason for re-auth.
-const char kReauthReasonKey[] = "reauth_reason";
-
// Upper bound for a histogram metric reporting the amount of time between
// one regular user logging out and a different regular user logging in.
const int kLogoutToLoginDelayMaxSec = 1800;
@@ -115,34 +92,11 @@ void ResolveLocale(const std::string& raw_locale,
ignore_result(l10n_util::CheckAndResolveLocale(raw_locale, resolved_locale));
}
-// Checks if values in |dict| correspond with |account_id| identity.
-bool UserMatches(const AccountId& account_id,
- const base::DictionaryValue& dict) {
- std::string value;
-
- // TODO(alemate): update code once user id is really a struct.
- bool has_gaia_id = dict.GetString(kGAIAIdKey, &value);
- if (has_gaia_id && account_id.GetGaiaId() == value)
- return true;
-
- bool has_email = dict.GetString(kCanonicalEmail, &value);
- if (has_email && account_id.GetUserEmail() == value)
- return true;
-
- return false;
-}
-
-// Fills relevant |dict| values based on |account_id|.
-void UpdateIdentity(const AccountId& account_id, base::DictionaryValue& dict) {
- dict.SetString(kCanonicalEmail, account_id.GetUserEmail());
-}
-
} // namespace
// static
void UserManagerBase::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterListPref(kRegularUsers);
- registry->RegisterListPref(kKnownUsers);
registry->RegisterStringPref(kLastLoggedInGaiaUser, std::string());
registry->RegisterDictionaryPref(kUserDisplayName);
registry->RegisterDictionaryPref(kUserGivenName);
@@ -151,6 +105,8 @@ void UserManagerBase::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(kUserForceOnlineSignin);
registry->RegisterDictionaryPref(kUserType);
registry->RegisterStringPref(kLastActiveUser, std::string());
+
+ known_user::RegisterPrefs(registry);
}
UserManagerBase::UserManagerBase(
@@ -539,28 +495,6 @@ void UserManagerBase::SaveUserType(const AccountId& account_id,
GetLocalState()->CommitPendingWrite();
}
-void UserManagerBase::UpdateUsingSAML(const AccountId& account_id,
- const bool using_saml) {
- SetKnownUserBooleanPref(account_id, kUsingSAMLKey, using_saml);
-}
-
-bool UserManagerBase::FindUsingSAML(const AccountId& account_id) {
- bool using_saml;
- if (GetKnownUserBooleanPref(account_id, kUsingSAMLKey, &using_saml))
- return using_saml;
- return false;
-}
-
-void UserManagerBase::UpdateReauthReason(const AccountId& account_id,
- const int reauth_reason) {
- SetKnownUserIntegerPref(account_id, kReauthReasonKey, reauth_reason);
-}
-
-bool UserManagerBase::FindReauthReason(const AccountId& account_id,
- int* out_value) {
- return GetKnownUserIntegerPref(account_id, kReauthReasonKey, out_value);
-}
-
void UserManagerBase::UpdateUserAccountData(
const AccountId& account_id,
const UserAccountData& account_data) {
@@ -594,7 +528,7 @@ void UserManagerBase::ParseUserList(const base::ListValue& users_list,
continue;
}
- const AccountId account_id = GetKnownUserAccountId(email, std::string());
+ const AccountId account_id = known_user::GetAccountId(email, std::string());
if (existing_users.find(account_id) != existing_users.end() ||
!users_set->insert(account_id).second) {
@@ -852,7 +786,7 @@ void UserManagerBase::EnsureUsersLoaded() {
const AccountId account_id = user->GetAccountId();
user->set_oauth_token_status(LoadUserOAuthStatus(*it));
user->set_force_online_signin(LoadForceOnlineSignin(*it));
- user->set_using_saml(FindUsingSAML(*it));
+ user->set_using_saml(known_user::IsUsingSAML(*it));
users_.push_back(user);
base::string16 display_name;
@@ -1013,7 +947,7 @@ void UserManagerBase::RemoveNonCryptohomeData(const AccountId& account_id) {
prefs_force_online_update->RemoveWithoutPathExpansion(
account_id.GetUserEmail(), nullptr);
- RemoveKnownUserPrefs(account_id);
+ known_user::RemovePrefs(account_id);
const AccountId last_active_user =
AccountId::FromUserEmail(GetLocalState()->GetString(kLastActiveUser));
@@ -1021,211 +955,6 @@ void UserManagerBase::RemoveNonCryptohomeData(const AccountId& account_id) {
GetLocalState()->SetString(kLastActiveUser, std::string());
}
-bool UserManagerBase::FindKnownUserPrefs(
- const AccountId& account_id,
- const base::DictionaryValue** out_value) {
- PrefService* local_state = GetLocalState();
-
- // Local State may not be initialized in tests.
- if (!local_state)
- return false;
-
- if (IsUserNonCryptohomeDataEphemeral(account_id))
- return false;
-
- const base::ListValue* known_users = local_state->GetList(kKnownUsers);
- for (size_t i = 0; i < known_users->GetSize(); ++i) {
- const base::DictionaryValue* element = nullptr;
- if (known_users->GetDictionary(i, &element)) {
- if (UserMatches(account_id, *element)) {
- known_users->GetDictionary(i, out_value);
- return true;
- }
- }
- }
- return false;
-}
-
-void UserManagerBase::UpdateKnownUserPrefs(const AccountId& account_id,
- const base::DictionaryValue& values,
- bool clear) {
- PrefService* local_state = GetLocalState();
-
- // Local State may not be initialized in tests.
- if (!local_state)
- return;
-
- if (IsUserNonCryptohomeDataEphemeral(account_id))
- return;
-
- ListPrefUpdate update(local_state, kKnownUsers);
- for (size_t i = 0; i < update->GetSize(); ++i) {
- base::DictionaryValue* element = nullptr;
- if (update->GetDictionary(i, &element)) {
- if (UserMatches(account_id, *element)) {
- if (clear)
- element->Clear();
- element->MergeDictionary(&values);
- UpdateIdentity(account_id, *element);
- return;
- }
- }
- }
- scoped_ptr<base::DictionaryValue> new_value(new base::DictionaryValue());
- new_value->MergeDictionary(&values);
- UpdateIdentity(account_id, *new_value);
- update->Append(new_value.release());
-}
-
-bool UserManagerBase::GetKnownUserStringPref(const AccountId& account_id,
- const std::string& path,
- std::string* out_value) {
- const base::DictionaryValue* user_pref_dict = nullptr;
- if (!FindKnownUserPrefs(account_id, &user_pref_dict))
- return false;
-
- return user_pref_dict->GetString(path, out_value);
-}
-
-void UserManagerBase::SetKnownUserStringPref(const AccountId& account_id,
- const std::string& path,
- const std::string& in_value) {
- PrefService* local_state = GetLocalState();
-
- // Local State may not be initialized in tests.
- if (!local_state)
- return;
-
- ListPrefUpdate update(local_state, kKnownUsers);
- base::DictionaryValue dict;
- dict.SetString(path, in_value);
- UpdateKnownUserPrefs(account_id, dict, false);
-}
-
-bool UserManagerBase::GetKnownUserBooleanPref(const AccountId& account_id,
- const std::string& path,
- bool* out_value) {
- const base::DictionaryValue* user_pref_dict = nullptr;
- if (!FindKnownUserPrefs(account_id, &user_pref_dict))
- return false;
-
- return user_pref_dict->GetBoolean(path, out_value);
-}
-
-void UserManagerBase::SetKnownUserBooleanPref(const AccountId& account_id,
- const std::string& path,
- const bool in_value) {
- PrefService* local_state = GetLocalState();
-
- // Local State may not be initialized in tests.
- if (!local_state)
- return;
-
- ListPrefUpdate update(local_state, kKnownUsers);
- base::DictionaryValue dict;
- dict.SetBoolean(path, in_value);
- UpdateKnownUserPrefs(account_id, dict, false);
-}
-
-bool UserManagerBase::GetKnownUserIntegerPref(const AccountId& account_id,
- const std::string& path,
- int* out_value) {
- const base::DictionaryValue* user_pref_dict = nullptr;
- if (!FindKnownUserPrefs(account_id, &user_pref_dict))
- return false;
- return user_pref_dict->GetInteger(path, out_value);
-}
-
-void UserManagerBase::SetKnownUserIntegerPref(const AccountId& account_id,
- const std::string& path,
- const int in_value) {
- PrefService* local_state = GetLocalState();
-
- // Local State may not be initialized in tests.
- if (!local_state)
- return;
-
- ListPrefUpdate update(local_state, kKnownUsers);
- base::DictionaryValue dict;
- dict.SetInteger(path, in_value);
- UpdateKnownUserPrefs(account_id, dict, false);
-}
-
-AccountId UserManagerBase::GetKnownUserAccountIdImpl(
- const std::string& user_email,
- const std::string& gaia_id) {
- DCHECK(!(user_email.empty() && gaia_id.empty()));
-
- // We can have several users with the same gaia_id but different e-mails.
- // The opposite case is not possible.
- std::string stored_gaia_id;
- const std::string sanitized_email =
- user_email.empty()
- ? std::string()
- : gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_email));
- if (!sanitized_email.empty() &&
- GetKnownUserStringPref(AccountId::FromUserEmail(sanitized_email),
- kGAIAIdKey, &stored_gaia_id)) {
- if (!gaia_id.empty() && gaia_id != stored_gaia_id)
- LOG(ERROR) << "User gaia id has changed. Sync will not work.";
-
- // gaia_id is associated with cryptohome.
- return AccountId::FromUserEmailGaiaId(sanitized_email, stored_gaia_id);
- }
-
- std::string stored_email;
- // GetKnownUserStringPref() returns the first user record that matches
- // given ID. So we will get the first one if there are multiples.
- if (!gaia_id.empty() &&
- GetKnownUserStringPref(AccountId::FromGaiaId(gaia_id), kCanonicalEmail,
- &stored_email)) {
- return AccountId::FromUserEmailGaiaId(stored_email, gaia_id);
- }
-
- return AccountId::FromUserEmailGaiaId(sanitized_email, gaia_id);
-}
-
-void UserManagerBase::UpdateGaiaID(const AccountId& account_id,
- const std::string& gaia_id) {
- SetKnownUserStringPref(account_id, kGAIAIdKey, gaia_id);
-}
-
-bool UserManagerBase::FindGaiaID(const AccountId& account_id,
- std::string* out_value) {
- return GetKnownUserStringPref(account_id, kGAIAIdKey, out_value);
-}
-
-void UserManagerBase::SetKnownUserDeviceId(const AccountId& account_id,
- const std::string& device_id) {
- const std::string known_device_id = GetKnownUserDeviceId(account_id);
- if (!known_device_id.empty() && device_id != known_device_id) {
- NOTREACHED() << "Trying to change device ID for known user.";
- }
- SetKnownUserStringPref(account_id, kDeviceId, device_id);
-}
-
-std::string UserManagerBase::GetKnownUserDeviceId(const AccountId& account_id) {
- std::string device_id;
- if (GetKnownUserStringPref(account_id, kDeviceId, &device_id)) {
- return device_id;
- }
- return std::string();
-}
-
-void UserManagerBase::SetKnownUserGAPSCookie(const AccountId& account_id,
- const std::string& gaps_cookie) {
- SetKnownUserStringPref(account_id, kGAPSCookie, gaps_cookie);
-}
-
-std::string UserManagerBase::GetKnownUserGAPSCookie(
- const AccountId& account_id) {
- std::string gaps_cookie;
- if (GetKnownUserStringPref(account_id, kGAPSCookie, &gaps_cookie)) {
- return gaps_cookie;
- }
- return std::string();
-}
-
User* UserManagerBase::RemoveRegularOrSupervisedUserFromList(
const AccountId& account_id) {
ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers);
@@ -1247,19 +976,6 @@ User* UserManagerBase::RemoveRegularOrSupervisedUserFromList(
return user;
}
-void UserManagerBase::RemoveKnownUserPrefs(const AccountId& account_id) {
- ListPrefUpdate update(GetLocalState(), kKnownUsers);
- for (size_t i = 0; i < update->GetSize(); ++i) {
- base::DictionaryValue* element = nullptr;
- if (update->GetDictionary(i, &element)) {
- if (UserMatches(account_id, *element)) {
- update->Remove(i, nullptr);
- break;
- }
- }
- }
-}
-
void UserManagerBase::NotifyActiveUserChanged(const User* active_user) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver,
diff --git a/components/user_manager/user_manager_base.h b/components/user_manager/user_manager_base.h
index 138faf0..83dc076 100644
--- a/components/user_manager/user_manager_base.h
+++ b/components/user_manager/user_manager_base.h
@@ -106,46 +106,6 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
UserManager::UserSessionStateObserver* obs) override;
void NotifyLocalStateChanged() override;
void ChangeUserChildStatus(User* user, bool is_child) override;
- bool FindKnownUserPrefs(const AccountId& account_id,
- const base::DictionaryValue** out_value) override;
- void UpdateKnownUserPrefs(const AccountId& account_id,
- const base::DictionaryValue& values,
- bool clear) override;
- bool GetKnownUserStringPref(const AccountId& account_id,
- const std::string& path,
- std::string* out_value) override;
- void SetKnownUserStringPref(const AccountId& account_id,
- const std::string& path,
- const std::string& in_value) override;
- bool GetKnownUserBooleanPref(const AccountId& account_id,
- const std::string& path,
- bool* out_value) override;
- void SetKnownUserBooleanPref(const AccountId& account_id,
- const std::string& path,
- const bool in_value) override;
- bool GetKnownUserIntegerPref(const AccountId& account_id,
- const std::string& path,
- int* out_value) override;
- void SetKnownUserIntegerPref(const AccountId& account_id,
- const std::string& path,
- int in_value) override;
- AccountId GetKnownUserAccountIdImpl(const std::string& user_email,
- const std::string& gaia_id) override;
- void UpdateGaiaID(const AccountId& account_id,
- const std::string& gaia_id) override;
- bool FindGaiaID(const AccountId& account_id, std::string* out_value) override;
- void UpdateUsingSAML(const AccountId& account_id,
- const bool using_saml) override;
- bool FindUsingSAML(const AccountId& account_id) override;
- void SetKnownUserDeviceId(const AccountId& account_id,
- const std::string& device_id) override;
- std::string GetKnownUserDeviceId(const AccountId& account_id) override;
- void SetKnownUserGAPSCookie(const AccountId& account_id,
- const std::string& gaps_cookie) override;
- std::string GetKnownUserGAPSCookie(const AccountId& account_id) override;
- void UpdateReauthReason(const AccountId& account_id,
- int reauth_reason) override;
- bool FindReauthReason(const AccountId& account_id, int* out_value) override;
// This method updates "User was added to the device in this session nad is
// not full initialized yet" flag.
@@ -181,9 +141,6 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
// Returns the locale used by the application.
virtual const std::string& GetApplicationLocale() const = 0;
- // Returns "Local State" PrefService instance.
- virtual PrefService* GetLocalState() const = 0;
-
// Loads |users_| from Local State if the list has not been loaded yet.
// Subsequent calls have no effect. Must be called on the UI thread.
virtual void EnsureUsersLoaded();
@@ -372,9 +329,6 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager {
void DoUpdateAccountLocale(const AccountId& account_id,
scoped_ptr<std::string> resolved_locale);
- // Removes all user preferences associated with |account_id|.
- void RemoveKnownUserPrefs(const AccountId& account_id);
-
// Indicates stage of loading user from prefs.
UserLoadStage user_loading_stage_ = STAGE_NOT_LOADED;