summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-30 14:22:47 +0000
committernkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-30 14:22:47 +0000
commit052e3ac81f105c8149a7b3e27feabc9bb243a1e6 (patch)
tree4e47ed302cf193729d07d3000b3fc2279cc0ba3c
parent2738127a2e64984abc89b5637a799528b1ed5c79 (diff)
downloadchromium_src-052e3ac81f105c8149a7b3e27feabc9bb243a1e6.zip
chromium_src-052e3ac81f105c8149a7b3e27feabc9bb243a1e6.tar.gz
chromium_src-052e3ac81f105c8149a7b3e27feabc9bb243a1e6.tar.bz2
CrOS user management cleanup - profiles
* Add ProfileHelper::Get() which hides dependency g_browser_process()->platform_part()->profile_helper() * Move OverrideHomedir() to SessionManager * Move GetUserProfileDir() to ProfileHelper * Move GetUserByProfile/GetProfileByUser to ProfileHelper BUG=387614 TBR=jyasskin@chromium.org, pneubeck@chromium.org Review URL: https://codereview.chromium.org/351063002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280596 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover.cc6
-rw-r--r--chrome/browser/chromeos/attestation/platform_verification_flow.cc4
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc11
-rw-r--r--chrome/browser/chromeos/drive/drive_notification_manager_factory_browsertest.cc5
-rw-r--r--chrome/browser/chromeos/drive/file_system_util.cc7
-rw-r--r--chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc4
-rw-r--r--chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc5
-rw-r--r--chrome/browser/chromeos/extensions/first_run_private_api.cc6
-rw-r--r--chrome/browser/chromeos/file_manager/path_util.cc11
-rw-r--r--chrome/browser/chromeos/file_system_provider/mount_path_util.cc2
-rw-r--r--chrome/browser/chromeos/first_run/first_run.cc5
-rw-r--r--chrome/browser/chromeos/first_run/first_run_controller.cc4
-rw-r--r--chrome/browser/chromeos/login/auth/parallel_authenticator_unittest.cc5
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller_browsertest.cc3
-rw-r--r--chrome/browser/chromeos/login/fake_login_utils.cc3
-rw-r--r--chrome/browser/chromeos/login/kiosk_browsertest.cc6
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc3
-rw-r--r--chrome/browser/chromeos/login/managed/locally_managed_user_creation_flow.cc5
-rw-r--r--chrome/browser/chromeos/login/managed/managed_user_test_base.cc5
-rw-r--r--chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.cc5
-rw-r--r--chrome/browser/chromeos/login/screens/user_image_screen.cc3
-rw-r--r--chrome/browser/chromeos/login/session/session_manager.cc44
-rw-r--r--chrome/browser/chromeos/login/session/session_manager.h3
-rw-r--r--chrome/browser/chromeos/login/signin/auth_sync_observer.cc3
-rw-r--r--chrome/browser/chromeos/login/ui/user_adding_screen_browsertest.cc19
-rw-r--r--chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc3
-rw-r--r--chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.cc3
-rw-r--r--chrome/browser/chromeos/login/users/fake_user_manager.cc34
-rw-r--r--chrome/browser/chromeos/login/users/fake_user_manager.h12
-rw-r--r--chrome/browser/chromeos/login/users/mock_user_manager.cc18
-rw-r--r--chrome/browser/chromeos/login/users/mock_user_manager.h4
-rw-r--r--chrome/browser/chromeos/login/users/multi_profile_user_controller.cc4
-rw-r--r--chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc4
-rw-r--r--chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc2
-rw-r--r--chrome/browser/chromeos/login/users/user_manager.cc3
-rw-r--r--chrome/browser/chromeos/login/users/user_manager.h10
-rw-r--r--chrome/browser/chromeos/login/users/user_manager_impl.cc99
-rw-r--r--chrome/browser/chromeos/login/users/user_manager_impl.h4
-rw-r--r--chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc3
-rw-r--r--chrome/browser/chromeos/ownership/owner_settings_service_factory.cc2
-rw-r--r--chrome/browser/chromeos/policy/cloud_external_data_policy_observer.cc4
-rw-r--r--chrome/browser/chromeos/policy/policy_cert_service_factory.cc5
-rw-r--r--chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc5
-rw-r--r--chrome/browser/chromeos/policy/user_network_configuration_updater_factory.cc6
-rw-r--r--chrome/browser/chromeos/preferences_browsertest.cc8
-rw-r--r--chrome/browser/chromeos/profiles/profile_helper.cc140
-rw-r--r--chrome/browser/chromeos/profiles/profile_helper.h58
-rw-r--r--chrome/browser/chromeos/profiles/profile_list_chromeos_unittest.cc3
-rw-r--r--chrome/browser/chromeos/settings/device_settings_test_helper.cc6
-rw-r--r--chrome/browser/extensions/extension_assets_manager_chromeos.cc4
-rw-r--r--chrome/browser/extensions/extension_garbage_collector_chromeos.cc5
-rw-r--r--chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc3
-rw-r--r--chrome/browser/extensions/external_provider_impl.cc3
-rw-r--r--chrome/browser/invalidation/profile_invalidation_provider_factory_browsertest.cc5
-rw-r--r--chrome/browser/net/nss_context_chromeos_browsertest.cc9
-rw-r--r--chrome/browser/notifications/message_center_settings_controller.cc12
-rw-r--r--chrome/browser/policy/profile_policy_connector_factory.cc4
-rw-r--r--chrome/browser/policy/schema_registry_service_factory.cc4
-rw-r--r--chrome/browser/profiles/profile_impl.cc4
-rw-r--r--chrome/browser/profiles/profile_io_data.cc6
-rw-r--r--chrome/browser/profiles/profile_manager.cc22
-rw-r--r--chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc6
-rw-r--r--chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc3
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_chromeos.cc9
-rw-r--r--chrome/browser/ui/ash/system_tray_delegate_chromeos.cc3
-rw-r--r--chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc3
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator.cc4
-rw-r--r--chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc7
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc4
-rw-r--r--chrome/browser/ui/webui/net_internals/net_internals_ui.cc4
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc3
-rw-r--r--chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc3
-rw-r--r--chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc3
-rw-r--r--chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc2
-rw-r--r--chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc3
-rw-r--r--chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc15
76 files changed, 454 insertions, 316 deletions
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
index 3ae6978..8b06610 100644
--- a/chrome/browser/browsing_data/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/chrome_notification_types.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/users/user.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
#endif
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/domain_reliability/service_factory.h"
@@ -58,6 +57,7 @@
#include "components/domain_reliability/service.h"
#include "components/password_manager/core/browser/password_store.h"
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chromeos/attestation/attestation_constants.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -648,8 +648,8 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs);
#if defined(OS_CHROMEOS)
// On Chrome OS, also delete any content protection platform keys.
- chromeos::User* user = chromeos::UserManager::Get()->
- GetUserByProfile(profile_);
+ chromeos::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
if (!user) {
LOG(WARNING) << "Failed to find user for current profile.";
} else {
diff --git a/chrome/browser/chromeos/attestation/platform_verification_flow.cc b/chrome/browser/chromeos/attestation/platform_verification_flow.cc
index 56f4c5b..f95ebeb 100644
--- a/chrome/browser/chromeos/attestation/platform_verification_flow.cc
+++ b/chrome/browser/chromeos/attestation/platform_verification_flow.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h"
#include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
#include "chrome/browser/chromeos/login/users/user.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/profiles/profile.h"
@@ -88,7 +88,7 @@ class DefaultDelegate : public PlatformVerificationFlow::Delegate {
}
virtual User* GetUser(content::WebContents* web_contents) OVERRIDE {
- return UserManager::Get()->GetUserByProfile(
+ return ProfileHelper::Get()->GetUserByProfile(
Profile::FromBrowserContext(web_contents->GetBrowserContext()));
}
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 396b1b0..96febb5 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -468,7 +468,7 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
g_browser_process->profile_manager();
// ProfileHelper has to be initialized after UserManager instance is created.
- g_browser_process->platform_part()->profile_helper()->Initialize();
+ ProfileHelper::Get()->Initialize();
// TODO(abarth): Should this move to InitializeNetworkOptions()?
// Allow access to file:// on ChromeOS for tests.
@@ -599,13 +599,13 @@ void GuestLanguageSetCallbackData::Callback(
ime_manager->ChangeInputMethod(login_input_methods[0]);
}
-void SetGuestLocale(UserManager* const user_manager, Profile* const profile) {
+void SetGuestLocale(Profile* const profile) {
scoped_ptr<GuestLanguageSetCallbackData> data(
new GuestLanguageSetCallbackData(profile));
scoped_ptr<locale_util::SwitchLanguageCallback> callback(
new locale_util::SwitchLanguageCallback(base::Bind(
&GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass()))));
- User* const user = user_manager->GetUserByProfile(profile);
+ User* const user = ProfileHelper::Get()->GetUserByProfile(profile);
SessionManager::GetInstance()->RespectLocalePreference(
profile, user, callback.Pass());
}
@@ -681,9 +681,8 @@ void ChromeBrowserMainPartsChromeos::PostProfileInit() {
// Guest user profile is never initialized with locale settings,
// so we need special handling for Guest session.
- UserManager* const user_manager = UserManager::Get();
- if (user_manager->IsLoggedInAsGuest())
- SetGuestLocale(user_manager, profile());
+ if (UserManager::Get()->IsLoggedInAsGuest())
+ SetGuestLocale(profile());
// These observers must be initialized after the profile because
// they use the profile to dispatch extension events.
diff --git a/chrome/browser/chromeos/drive/drive_notification_manager_factory_browsertest.cc b/chrome/browser/chromeos/drive/drive_notification_manager_factory_browsertest.cc
index 6bd5aac..52fcc19 100644
--- a/chrome/browser/chromeos/drive/drive_notification_manager_factory_browsertest.cc
+++ b/chrome/browser/chromeos/drive/drive_notification_manager_factory_browsertest.cc
@@ -53,8 +53,9 @@ IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryGuestBrowserTest,
NoDriveNotificationManager) {
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
EXPECT_TRUE(user_manager->IsLoggedInAsGuest());
- Profile* guest_profile = user_manager->GetProfileByUser(
- user_manager->GetActiveUser())->GetOriginalProfile();
+ Profile* guest_profile = chromeos::ProfileHelper::Get()
+ ->GetProfileByUser(user_manager->GetActiveUser())
+ ->GetOriginalProfile();
Profile* signin_profile =
chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile();
EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext(
diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc
index 416bbc5..b97defc 100644
--- a/chrome/browser/chromeos/drive/file_system_util.cc
+++ b/chrome/browser/chromeos/drive/file_system_util.cc
@@ -121,9 +121,10 @@ base::FilePath GetDriveMountPointPath(Profile* profile) {
// returns currently active users's hash in such a case.) I still try
// ProfileHelper first because it works better in tests.
chromeos::User* const user =
- chromeos::UserManager::IsInitialized() ?
- chromeos::UserManager::Get()->GetUserByProfile(
- profile->GetOriginalProfile()) : NULL;
+ chromeos::UserManager::IsInitialized()
+ ? chromeos::ProfileHelper::Get()->GetUserByProfile(
+ profile->GetOriginalProfile())
+ : NULL;
if (user)
id = user->username_hash();
}
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
index 4173359..e0685b2 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/file_manager/url_util.h"
#include "chrome/browser/chromeos/fileapi/file_system_backend.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/drive/drive_app_registry.h"
#include "chrome/browser/drive/event_logger.h"
#include "chrome/browser/profiles/profile.h"
@@ -851,7 +851,7 @@ bool FileBrowserPrivateRequestDriveShareFunction::RunAsync() {
return false;
const chromeos::User* const user =
- chromeos::UserManager::Get()->GetUserByProfile(GetProfile());
+ chromeos::ProfileHelper::Get()->GetUserByProfile(GetProfile());
if (!user || !user->is_logged_in())
return false;
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc
index a708b37..41783b3 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/file_manager/app_installer.h"
#include "chrome/browser/chromeos/file_manager/zip_file_creator.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/drive/event_logger.h"
@@ -75,7 +76,7 @@ GetLoggedInProfileInfoList(content::WebContents* contents) {
continue;
original_profiles.insert(profile);
const chromeos::User* const user =
- chromeos::UserManager::Get()->GetUserByProfile(profile);
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (!user || !user->is_logged_in())
continue;
@@ -108,7 +109,7 @@ GetLoggedInProfileInfoList(content::WebContents* contents) {
bool FileBrowserPrivateLogoutUserForReauthenticationFunction::RunSync() {
chromeos::User* user =
- chromeos::UserManager::Get()->GetUserByProfile(GetProfile());
+ chromeos::ProfileHelper::Get()->GetUserByProfile(GetProfile());
if (user) {
chromeos::UserManager::Get()->SaveUserOAuthStatus(
user->email(),
diff --git a/chrome/browser/chromeos/extensions/first_run_private_api.cc b/chrome/browser/chromeos/extensions/first_run_private_api.cc
index 7158439..43db16d 100644
--- a/chrome/browser/chromeos/extensions/first_run_private_api.cc
+++ b/chrome/browser/chromeos/extensions/first_run_private_api.cc
@@ -5,9 +5,9 @@
#include "chrome/browser/chromeos/extensions/first_run_private_api.h"
#include "base/metrics/histogram.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/first_run/first_run.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/login/users/user.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -18,7 +18,7 @@ bool FirstRunPrivateGetLocalizedStringsFunction::RunSync() {
UMA_HISTOGRAM_COUNTS("CrosFirstRun.DialogShown", 1);
base::DictionaryValue* localized_strings = new base::DictionaryValue();
chromeos::User* user =
- chromeos::UserManager::Get()->GetUserByProfile(GetProfile());
+ chromeos::ProfileHelper::Get()->GetUserByProfile(GetProfile());
if (!user->GetGivenName().empty()) {
localized_strings->SetString(
"greetingHeader",
diff --git a/chrome/browser/chromeos/file_manager/path_util.cc b/chrome/browser/chromeos/file_manager/path_util.cc
index f93f979..ab8272c 100644
--- a/chrome/browser/chromeos/file_manager/path_util.cc
+++ b/chrome/browser/chromeos/file_manager/path_util.cc
@@ -37,7 +37,7 @@ base::FilePath GetDownloadsFolderForProfile(Profile* profile) {
if (!base::SysInfo::IsRunningOnChromeOS() &&
chromeos::UserManager::IsInitialized()) {
const chromeos::User* const user =
- chromeos::UserManager::Get()->GetUserByProfile(
+ chromeos::ProfileHelper::Get()->GetUserByProfile(
profile->GetOriginalProfile());
const chromeos::User* const primary_user =
chromeos::UserManager::Get()->GetPrimaryUser();
@@ -78,7 +78,7 @@ bool MigratePathFromOldFormat(Profile* profile,
// some edge cases (crbug.com/356322) that u-<hash> path is temporarily used.
if (chromeos::UserManager::IsInitialized()) {
const chromeos::User* const user =
- chromeos::UserManager::Get()->GetUserByProfile(profile);
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (user) {
const base::FilePath hashed_downloads =
chromeos::ProfileHelper::GetProfilePathByUserIdHash(
@@ -107,9 +107,10 @@ std::string GetDownloadsMountPointName(Profile* profile) {
// are not associated with an user account. In that case, no suffix is added
// because such a profile never belongs to a multi-profile session.
chromeos::User* const user =
- chromeos::UserManager::IsInitialized() ?
- chromeos::UserManager::Get()->GetUserByProfile(
- profile->GetOriginalProfile()) : NULL;
+ chromeos::UserManager::IsInitialized()
+ ? chromeos::ProfileHelper::Get()->GetUserByProfile(
+ profile->GetOriginalProfile())
+ : NULL;
const std::string id = user ? "-" + user->username_hash() : "";
return net::EscapePath(kDownloadsFolderName + id);
}
diff --git a/chrome/browser/chromeos/file_system_provider/mount_path_util.cc b/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
index 5ad64fa..3f20f3a 100644
--- a/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
+++ b/chrome/browser/chromeos/file_system_provider/mount_path_util.cc
@@ -52,7 +52,7 @@ base::FilePath GetMountPath(Profile* profile,
const std::string& file_system_id) {
chromeos::User* const user =
chromeos::UserManager::IsInitialized()
- ? chromeos::UserManager::Get()->GetUserByProfile(
+ ? chromeos::ProfileHelper::Get()->GetUserByProfile(
profile->GetOriginalProfile())
: NULL;
const std::string safe_file_system_id = EscapeFileSystemId(file_system_id);
diff --git a/chrome/browser/chromeos/first_run/first_run.cc b/chrome/browser/chromeos/first_run/first_run.cc
index 1f285946..f35d0d1 100644
--- a/chrome/browser/chromeos/first_run/first_run.cc
+++ b/chrome/browser/chromeos/first_run/first_run.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/first_run/first_run_controller.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/common/chrome_switches.h"
@@ -61,7 +62,7 @@ class DialogLauncher : public content::NotificationObserver {
const content::NotificationDetails& details) OVERRIDE {
DCHECK(type == chrome::NOTIFICATION_SESSION_STARTED);
DCHECK(content::Details<const User>(details).ptr() ==
- UserManager::Get()->GetUserByProfile(profile_));
+ ProfileHelper::Get()->GetUserByProfile(profile_));
CommandLine* command_line = CommandLine::ForCurrentProcess();
bool launched_in_test = command_line->HasSwitch(::switches::kTestType);
bool launched_in_telemetry =
@@ -97,7 +98,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
void MaybeLaunchDialogAfterSessionStart() {
UserManager* user_manager = UserManager::Get();
new DialogLauncher(
- user_manager->GetProfileByUser(user_manager->GetActiveUser()));
+ ProfileHelper::Get()->GetProfileByUser(user_manager->GetActiveUser()));
}
void LaunchTutorial() {
diff --git a/chrome/browser/chromeos/first_run/first_run_controller.cc b/chrome/browser/chromeos/first_run/first_run_controller.cc
index 379340d..1b24e58 100644
--- a/chrome/browser/chromeos/first_run/first_run_controller.cc
+++ b/chrome/browser/chromeos/first_run/first_run_controller.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/first_run/steps/help_step.h"
#include "chrome/browser/chromeos/first_run/steps/tray_step.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "ui/views/widget/widget.h"
@@ -71,7 +72,8 @@ FirstRunController::FirstRunController()
void FirstRunController::Init() {
start_time_ = base::Time::Now();
UserManager* user_manager = UserManager::Get();
- user_profile_ = user_manager->GetProfileByUser(user_manager->GetActiveUser());
+ user_profile_ =
+ ProfileHelper::Get()->GetProfileByUser(user_manager->GetActiveUser());
shell_helper_.reset(ash::Shell::GetInstance()->CreateFirstRunHelper());
shell_helper_->AddObserver(this);
diff --git a/chrome/browser/chromeos/login/auth/parallel_authenticator_unittest.cc b/chrome/browser/chromeos/login/auth/parallel_authenticator_unittest.cc
index f088c58..b7ae858 100644
--- a/chrome/browser/chromeos/login/auth/parallel_authenticator_unittest.cc
+++ b/chrome/browser/chromeos/login/auth/parallel_authenticator_unittest.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
@@ -57,7 +58,9 @@ class ParallelAuthenticatorTest : public testing::Test {
user_context_.SetKey(Key("fakepass"));
const User* user = user_manager_->AddUser(user_context_.GetUserID());
profile_.set_profile_name(user_context_.GetUserID());
- user_manager_->SetProfileForUser(user, &profile_);
+
+ ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, &profile_);
+
transformed_key_ = *user_context_.GetKey();
transformed_key_.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF,
SystemSaltGetter::ConvertRawSaltToHexString(
diff --git a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
index f96c316..39c5ed3 100644
--- a/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller_browsertest.cc
@@ -160,9 +160,6 @@ class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest {
.WillRepeatedly(Return(false));
EXPECT_CALL(*mock_user_manager_, Shutdown())
.Times(1);
- EXPECT_CALL(*mock_user_manager_, GetProfileByUser(_))
- .Times(AnyNumber())
- .WillRepeatedly(Return(testing_profile_.get()));
}
virtual void SetUpOnMainThread() OVERRIDE {
diff --git a/chrome/browser/chromeos/login/fake_login_utils.cc b/chrome/browser/chromeos/login/fake_login_utils.cc
index 4d90276..8719af0 100644
--- a/chrome/browser/chromeos/login/fake_login_utils.cc
+++ b/chrome/browser/chromeos/login/fake_login_utils.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
@@ -65,7 +66,7 @@ void FakeLoginUtils::PrepareProfile(const UserContext& user_context,
// Make sure that we get the real Profile instead of the login Profile.
user->set_profile_is_created();
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
user_context.GetUserID());
diff --git a/chrome/browser/chromeos/login/kiosk_browsertest.cc b/chrome/browser/chromeos/login/kiosk_browsertest.cc
index 30511e4..c0f0451 100644
--- a/chrome/browser/chromeos/login/kiosk_browsertest.cc
+++ b/chrome/browser/chromeos/login/kiosk_browsertest.cc
@@ -238,12 +238,18 @@ class KioskTest : public OobeBaseTest {
virtual void SetUp() OVERRIDE {
test_app_id_ = kTestKioskApp;
mock_user_manager_.reset(new MockUserManager);
+ ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true);
AppLaunchController::SkipSplashWaitForTesting();
AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds);
OobeBaseTest::SetUp();
}
+ virtual void TearDown() OVERRIDE {
+ ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(false);
+ OobeBaseTest::TearDown();
+ }
+
virtual void CleanUpOnMainThread() OVERRIDE {
AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL);
AppLaunchSigninScreen::SetUserManagerForTesting(NULL);
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index 40fad56..d48cb3d 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -52,6 +52,7 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/first_run/first_run.h"
@@ -305,7 +306,7 @@ void LoginUtilsImpl::DoBrowserLaunch(Profile* profile,
if (browser_shutdown::IsTryingToQuit())
return;
- User* const user = UserManager::Get()->GetUserByProfile(profile);
+ User* const user = ProfileHelper::Get()->GetUserByProfile(profile);
scoped_ptr<DoBrowserLaunchOnLocaleLoadedData> data(
new DoBrowserLaunchOnLocaleLoadedData(this, profile, login_host));
diff --git a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_flow.cc b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_flow.cc
index 37d235c..b1235db 100644
--- a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_flow.cc
+++ b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_flow.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -93,9 +92,7 @@ void LocallyManagedUserCreationFlow::LaunchExtraSteps(
Profile* profile) {
logged_in_ = true;
manager_profile_ = profile;
- g_browser_process->platform_part()->profile_helper()->ProfileStartup(
- profile,
- true);
+ ProfileHelper::Get()->ProfileStartup(profile, true);
if (token_validated_ && logged_in_) {
if (!session_started_)
diff --git a/chrome/browser/chromeos/login/managed/managed_user_test_base.cc b/chrome/browser/chromeos/login/managed/managed_user_test_base.cc
index 22e7aaa..a69d22f 100644
--- a/chrome/browser/chromeos/login/managed/managed_user_test_base.cc
+++ b/chrome/browser/chromeos/login/managed/managed_user_test_base.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/browser/supervised_user/supervised_user_constants.h"
@@ -367,7 +368,7 @@ void ManagedUserTestBase::SigninAsSupervisedUser(
LoginUser(user->email());
if (check_homedir_calls)
::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_);
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
shared_settings_adapter_.reset(
new ManagedUsersSharedSettingsSyncTestAdapter(profile));
@@ -383,7 +384,7 @@ void ManagedUserTestBase::SigninAsManager(int user_index) {
// Created supervised user have to be first in a list.
const User* user = UserManager::Get()->GetUsers().at(user_index);
LoginUser(user->email());
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
shared_settings_adapter_.reset(
new ManagedUsersSharedSettingsSyncTestAdapter(profile));
managed_users_adapter_.reset(new ManagedUsersSyncTestAdapter(profile));
diff --git a/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.cc b/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.cc
index 3c05056..a5042e7 100644
--- a/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.cc
+++ b/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.cc
@@ -15,6 +15,7 @@
#include "base/time/time.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
@@ -42,7 +43,7 @@ void SAMLOfflineSigninLimiter::RegisterProfilePrefs(
void SAMLOfflineSigninLimiter::SignedIn(UserContext::AuthFlow auth_flow) {
PrefService* prefs = profile_->GetPrefs();
- const User* user = UserManager::Get()->GetUserByProfile(profile_);
+ const User* user = ProfileHelper::Get()->GetUserByProfile(profile_);
if (!user) {
NOTREACHED();
return;
@@ -139,7 +140,7 @@ void SAMLOfflineSigninLimiter::UpdateLimit() {
}
void SAMLOfflineSigninLimiter::ForceOnlineLogin() {
- User* user = UserManager::Get()->GetUserByProfile(profile_);
+ User* user = ProfileHelper::Get()->GetUserByProfile(profile_);
if (!user) {
NOTREACHED();
return;
diff --git a/chrome/browser/chromeos/login/screens/user_image_screen.cc b/chrome/browser/chromeos/login/screens/user_image_screen.cc
index ea11737..1c48f27 100644
--- a/chrome/browser/chromeos/login/screens/user_image_screen.cc
+++ b/chrome/browser/chromeos/login/screens/user_image_screen.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -263,7 +264,7 @@ void UserImageScreen::Show() {
return;
DCHECK(!policy_registrar_);
- Profile* profile = UserManager::Get()->GetProfileByUser(GetUser());
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(GetUser());
if (profile) {
policy::PolicyService* policy_service =
policy::ProfilePolicyConnectorFactory::GetForProfile(profile)->
diff --git a/chrome/browser/chromeos/login/session/session_manager.cc b/chrome/browser/chromeos/login/session/session_manager.cc
index 98050cc..e3ebfce 100644
--- a/chrome/browser/chromeos/login/session/session_manager.cc
+++ b/chrome/browser/chromeos/login/session/session_manager.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/google/google_brand_chromeos.h"
#include "chrome/browser/lifetime/application_lifetime.h"
@@ -135,6 +136,25 @@ SessionManager* SessionManager::GetInstance() {
}
// static
+void SessionManager::OverrideHomedir() {
+ // Override user homedir, check for ProfileManager being initialized as
+ // it may not exist in unit tests.
+ if (g_browser_process->profile_manager()) {
+ UserManager* user_manager = UserManager::Get();
+ if (user_manager->GetLoggedInUsers().size() == 1) {
+ base::FilePath homedir = ProfileHelper::GetProfilePathByUserIdHash(
+ user_manager->GetPrimaryUser()->username_hash());
+ // This path has been either created by cryptohome (on real Chrome OS
+ // device) or by ProfileManager (on chromeos=1 desktop builds).
+ PathService::OverrideAndCreateIfNeeded(base::DIR_HOME,
+ homedir,
+ true /* path is absolute */,
+ false /* don't create */);
+ }
+ }
+}
+
+// static
void SessionManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterStringPref(prefs::kRLZBrand, std::string());
registry->RegisterBooleanPref(prefs::kRLZDisabled, false);
@@ -204,7 +224,7 @@ void SessionManager::RestoreAuthenticationSession(Profile* user_profile) {
return;
}
- User* user = user_manager->GetUserByProfile(user_profile);
+ User* user = ProfileHelper::Get()->GetUserByProfile(user_profile);
DCHECK(user);
if (!net::NetworkChangeNotifier::IsOffline()) {
pending_restore_sessions_.erase(user->email());
@@ -421,7 +441,7 @@ void SessionManager::OnConnectionTypeChanged(
if (!(*it)->is_profile_created())
continue;
- Profile* user_profile = user_manager->GetProfileByUser(*it);
+ Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(*it);
bool should_restore_session =
pending_restore_sessions_.find((*it)->email()) !=
pending_restore_sessions_.end();
@@ -471,17 +491,20 @@ void SessionManager::NotifyUserLoggedIn() {
}
void SessionManager::PrepareProfile() {
- UserManager* user_manager = UserManager::Get();
bool is_demo_session =
DemoAppLauncher::IsDemoAppSession(user_context_.GetUserID());
// TODO(nkostylev): Figure out whether demo session is using the right profile
// path or not. See https://codereview.chromium.org/171423009
g_browser_process->profile_manager()->CreateProfileAsync(
- user_manager->GetUserProfileDir(user_context_.GetUserID()),
- base::Bind(&SessionManager::OnProfileCreated, AsWeakPtr(),
- user_context_.GetUserID(), is_demo_session),
- base::string16(), base::string16(), std::string());
+ ProfileHelper::GetUserProfileDirByUserId(user_context_.GetUserID()),
+ base::Bind(&SessionManager::OnProfileCreated,
+ AsWeakPtr(),
+ user_context_.GetUserID(),
+ is_demo_session),
+ base::string16(),
+ base::string16(),
+ std::string());
}
void SessionManager::OnProfileCreated(const std::string& user_id,
@@ -613,10 +636,9 @@ void SessionManager::FinalizePrepareProfile(Profile* profile) {
InitializeCertsForPrimaryUser(profile);
// Initialize RLZ only for primary user.
- if (user_manager->GetPrimaryUser() ==
- user_manager->GetUserByProfile(profile)) {
+ const User* user = ProfileHelper::Get()->GetUserByProfile(profile);
+ if (user_manager->GetPrimaryUser() == user)
InitRlz(profile);
- }
// TODO(altimofeev): This pointer should probably never be NULL, but it looks
// like LoginUtilsImpl::OnProfileCreated() may be getting called before
@@ -727,7 +749,7 @@ void SessionManager::InitializeCertsForPrimaryUser(Profile* profile) {
const User* primary_user = user_manager->GetPrimaryUser();
if (user_manager->IsUserLoggedIn() &&
primary_user &&
- profile == user_manager->GetProfileByUser(primary_user) &&
+ profile == ProfileHelper::Get()->GetProfileByUser(primary_user) &&
CertLoader::IsInitialized() &&
base::SysInfo::IsRunningOnChromeOS()) {
GetNSSCertDatabaseForProfile(profile,
diff --git a/chrome/browser/chromeos/login/session/session_manager.h b/chrome/browser/chromeos/login/session/session_manager.h
index 62ddc77..ab843ce 100644
--- a/chrome/browser/chromeos/login/session/session_manager.h
+++ b/chrome/browser/chromeos/login/session/session_manager.h
@@ -48,6 +48,9 @@ class SessionManager :
// Returns SessionManager instance.
static SessionManager* GetInstance();
+ // Called when user is logged in to override base::DIR_HOME path.
+ static void OverrideHomedir();
+
// Registers session related preferences.
static void RegisterPrefs(PrefRegistrySimple* registry);
diff --git a/chrome/browser/chromeos/login/signin/auth_sync_observer.cc b/chrome/browser/chromeos/login/signin/auth_sync_observer.cc
index f867072..5f328eda 100644
--- a/chrome/browser/chromeos/login/signin/auth_sync_observer.cc
+++ b/chrome/browser/chromeos/login/signin/auth_sync_observer.cc
@@ -9,6 +9,7 @@
#include "base/prefs/pref_service.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/pref_names.h"
@@ -46,7 +47,7 @@ void AuthSyncObserver::OnStateChanged() {
UserManager::Get()->IsLoggedInAsLocallyManagedUser());
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile_);
- User* user = UserManager::Get()->GetUserByProfile(profile_);
+ User* user = ProfileHelper::Get()->GetUserByProfile(profile_);
GoogleServiceAuthError::State state =
sync_service->GetAuthError().state();
if (state != GoogleServiceAuthError::NONE &&
diff --git a/chrome/browser/chromeos/login/ui/user_adding_screen_browsertest.cc b/chrome/browser/chromeos/login/ui/user_adding_screen_browsertest.cc
index fc16589..b76c90b 100644
--- a/chrome/browser/chromeos/login/ui/user_adding_screen_browsertest.cc
+++ b/chrome/browser/chromeos/login/ui/user_adding_screen_browsertest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/test_utils.h"
@@ -163,12 +164,18 @@ IN_PROC_BROWSER_TEST_F(UserAddingScreenTest, AddingSeveralUsers) {
GetSessionState());
// Now check how unlock policy works for these users.
- PrefService* prefs1 = user_manager->
- GetProfileByUser(user_manager->GetLoggedInUsers()[0])->GetPrefs();
- PrefService* prefs2 = user_manager->
- GetProfileByUser(user_manager->GetLoggedInUsers()[1])->GetPrefs();
- PrefService* prefs3 = user_manager->
- GetProfileByUser(user_manager->GetLoggedInUsers()[2])->GetPrefs();
+ PrefService* prefs1 =
+ ProfileHelper::Get()
+ ->GetProfileByUser(user_manager->GetLoggedInUsers()[0])
+ ->GetPrefs();
+ PrefService* prefs2 =
+ ProfileHelper::Get()
+ ->GetProfileByUser(user_manager->GetLoggedInUsers()[1])
+ ->GetPrefs();
+ PrefService* prefs3 =
+ ProfileHelper::Get()
+ ->GetProfileByUser(user_manager->GetLoggedInUsers()[2])
+ ->GetPrefs();
ASSERT_TRUE(prefs1 != NULL);
ASSERT_TRUE(prefs2 != NULL);
ASSERT_TRUE(prefs3 != NULL);
diff --git a/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc b/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc
index cdc5ab8..8e9bf0c 100644
--- a/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc
+++ b/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc
@@ -38,6 +38,7 @@
#include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_util.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_downloader.h"
#include "chrome/common/chrome_paths.h"
@@ -78,7 +79,7 @@ const char kTestUser1[] = "test-user@example.com";
const char kTestUser2[] = "test-user2@example.com";
policy::CloudPolicyStore* GetStoreForUser(const User* user) {
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
if (!profile) {
ADD_FAILURE();
return NULL;
diff --git a/chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.cc b/chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.cc
index b8e9e9f..2294563 100644
--- a/chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.cc
+++ b/chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/chromeos/login/users/avatar/user_image_sync_observer.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_downloader.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_paths.h"
@@ -724,7 +725,7 @@ int UserImageManagerImpl::GetDesiredImageSideLength() const {
}
Profile* UserImageManagerImpl::GetBrowserProfile() {
- return user_manager_->GetProfileByUser(GetUser());
+ return ProfileHelper::Get()->GetProfileByUser(GetUser());
}
std::string UserImageManagerImpl::GetCachedPictureURL() const {
diff --git a/chrome/browser/chromeos/login/users/fake_user_manager.cc b/chrome/browser/chromeos/login/users/fake_user_manager.cc
index 57e7129..8b493d2 100644
--- a/chrome/browser/chromeos/login/users/fake_user_manager.cc
+++ b/chrome/browser/chromeos/login/users/fake_user_manager.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/login/users/fake_user_manager.h"
#include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
namespace {
@@ -18,9 +19,13 @@ namespace chromeos {
FakeUserManager::FakeUserManager()
: supervised_user_manager_(new FakeSupervisedUserManager),
primary_user_(NULL),
- multi_profile_user_controller_(NULL) {}
+ multi_profile_user_controller_(NULL) {
+ ProfileHelper::SetProfileToUserForTestingEnabled(true);
+}
FakeUserManager::~FakeUserManager() {
+ ProfileHelper::SetProfileToUserForTestingEnabled(false);
+
// Can't use STLDeleteElements because of the private destructor of User.
for (UserList::iterator it = user_list_.begin(); it != user_list_.end();
it = user_list_.erase(it)) {
@@ -33,6 +38,7 @@ const User* FakeUserManager::AddUser(const std::string& email) {
user->set_username_hash(email + kUserIdHashSuffix);
user->SetStubImage(User::kProfileImageIndex, false);
user_list_.push_back(user);
+ ProfileHelper::Get()->SetProfileToUserMappingForTesting(user);
return user;
}
@@ -40,16 +46,13 @@ void FakeUserManager::AddKioskAppUser(const std::string& kiosk_app_username) {
User* user = User::CreateKioskAppUser(kiosk_app_username);
user->set_username_hash(kiosk_app_username + kUserIdHashSuffix);
user_list_.push_back(user);
+ ProfileHelper::Get()->SetProfileToUserMappingForTesting(user);
}
void FakeUserManager::LoginUser(const std::string& email) {
UserLoggedIn(email, email + kUserIdHashSuffix, false);
}
-void FakeUserManager::SetProfileForUser(const User* user, Profile* profile) {
- user_to_profile_[user] = profile;
-}
-
const UserList& FakeUserManager::GetUsers() const {
return user_list_;
}
@@ -178,22 +181,6 @@ const User* FakeUserManager::GetPrimaryUser() const {
return primary_user_;
}
-User* FakeUserManager::GetUserByProfile(Profile* profile) const {
- const std::string& user_name = profile->GetProfileName();
- for (UserList::const_iterator it = user_list_.begin();
- it != user_list_.end(); ++it) {
- if ((*it)->email() == user_name)
- return *it;
- }
- return primary_user_;
-}
-
-Profile* FakeUserManager::GetProfileByUser(const User* user) const {
- std::map<const User*, Profile*>::const_iterator it =
- user_to_profile_.find(user);
- return it == user_to_profile_.end() ? NULL : it->second;
-}
-
base::string16 FakeUserManager::GetUserDisplayName(
const std::string& username) const {
return base::string16();
@@ -280,9 +267,4 @@ bool FakeUserManager::AreLocallyManagedUsersAllowed() const {
return true;
}
-base::FilePath FakeUserManager::GetUserProfileDir(
- const std::string&email) const {
- return base::FilePath();
-}
-
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/users/fake_user_manager.h b/chrome/browser/chromeos/login/users/fake_user_manager.h
index 2cd7131..36be3f3 100644
--- a/chrome/browser/chromeos/login/users/fake_user_manager.h
+++ b/chrome/browser/chromeos/login/users/fake_user_manager.h
@@ -31,11 +31,8 @@ class FakeUserManager : public UserManager {
// Create and add a kiosk app user.
void AddKioskAppUser(const std::string& kiosk_app_username);
- // Calculates the user name hash and calls UserLoggedIn to login a user.
- void LoginUser(const std::string& email);
-
- // Associates |profile| with |user|, for GetProfileByUser().
- void SetProfileForUser(const User* user, Profile* profile);
+ // Calculates the user name hash and calls UserLoggedIn to login a user.
+ void LoginUser(const std::string& email);
// UserManager overrides.
virtual const UserList& GetUsers() const OVERRIDE;
@@ -76,8 +73,6 @@ class FakeUserManager : public UserManager {
virtual const User* GetLoggedInUser() const OVERRIDE;
virtual User* GetLoggedInUser() OVERRIDE;
virtual const User* GetPrimaryUser() const OVERRIDE;
- virtual Profile* GetProfileByUser(const User* profile) const OVERRIDE;
- virtual User* GetUserByProfile(Profile* profile) const OVERRIDE;
virtual void SaveUserOAuthStatus(
const std::string& username,
User::OAuthTokenStatus oauth_token_status) OVERRIDE {}
@@ -117,8 +112,6 @@ class FakeUserManager : public UserManager {
UserSessionStateObserver* obs) OVERRIDE {}
virtual void NotifyLocalStateChanged() OVERRIDE {}
virtual bool AreLocallyManagedUsersAllowed() const OVERRIDE;
- virtual base::FilePath GetUserProfileDir(const std::string& email) const
- OVERRIDE;
void set_owner_email(const std::string& owner_email) {
owner_email_ = owner_email;
@@ -138,7 +131,6 @@ class FakeUserManager : public UserManager {
UserList logged_in_users_;
std::string owner_email_;
User* primary_user_;
- std::map<const User*, Profile*> user_to_profile_;
// If set this is the active user. If empty, the first created user is the
// active user.
diff --git a/chrome/browser/chromeos/login/users/mock_user_manager.cc b/chrome/browser/chromeos/login/users/mock_user_manager.cc
index 24e2430..bb6caa8 100644
--- a/chrome/browser/chromeos/login/users/mock_user_manager.cc
+++ b/chrome/browser/chromeos/login/users/mock_user_manager.cc
@@ -5,14 +5,18 @@
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
#include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
namespace chromeos {
MockUserManager::MockUserManager()
: user_flow_(new DefaultUserFlow()),
- supervised_user_manager_(new FakeSupervisedUserManager()) {}
+ supervised_user_manager_(new FakeSupervisedUserManager()) {
+ ProfileHelper::SetProfileToUserForTestingEnabled(true);
+}
MockUserManager::~MockUserManager() {
+ ProfileHelper::SetProfileToUserForTestingEnabled(false);
ClearUserList();
}
@@ -48,10 +52,6 @@ const User* MockUserManager::GetPrimaryUser() const {
return GetLoggedInUser();
}
-User* MockUserManager::GetUserByProfile(Profile* profile) const {
- return user_list_.empty() ? NULL : user_list_.front();
-}
-
MultiProfileUserController* MockUserManager::GetMultiProfileUserController() {
return NULL;
}
@@ -81,12 +81,16 @@ UserFlow* MockUserManager::GetUserFlow(const std::string&) const {
User* MockUserManager::CreatePublicAccountUser(const std::string& email) {
ClearUserList();
- user_list_.push_back(User::CreatePublicAccountUser(email));
+ User* user = User::CreatePublicAccountUser(email);
+ user_list_.push_back(user);
+ ProfileHelper::Get()->SetProfileToUserMappingForTesting(user);
return user_list_.back();
}
void MockUserManager::AddUser(const std::string& email) {
- user_list_.push_back(User::CreateRegularUser(email));
+ User* user = User::CreateRegularUser(email);
+ user_list_.push_back(user);
+ ProfileHelper::Get()->SetProfileToUserMappingForTesting(user);
}
void MockUserManager::ClearUserList() {
diff --git a/chrome/browser/chromeos/login/users/mock_user_manager.h b/chrome/browser/chromeos/login/users/mock_user_manager.h
index 330b74d..feb24b8 100644
--- a/chrome/browser/chromeos/login/users/mock_user_manager.h
+++ b/chrome/browser/chromeos/login/users/mock_user_manager.h
@@ -41,7 +41,6 @@ class MockUserManager : public UserManager {
MOCK_METHOD1(FindUserAndModify, User*(const std::string&));
MOCK_METHOD2(SaveUserOAuthStatus, void(const std::string&,
User::OAuthTokenStatus));
- MOCK_CONST_METHOD1(GetProfileByUser, Profile*(const User*));
MOCK_METHOD2(SaveForceOnlineSignin, void(const std::string&, bool));
MOCK_METHOD2(SaveUserDisplayName, void(const std::string&,
const base::string16&));
@@ -78,8 +77,6 @@ class MockUserManager : public UserManager {
MOCK_METHOD1(ResetUserFlow, void(const std::string&));
MOCK_CONST_METHOD0(AreLocallyManagedUsersAllowed, bool(void));
- MOCK_CONST_METHOD1(GetUserProfileDir,
- base::FilePath(const std::string& email));
// You can't mock these functions easily because nobody can create
// User objects but the UserManagerImpl and us.
@@ -91,7 +88,6 @@ class MockUserManager : public UserManager {
virtual const User* GetActiveUser() const OVERRIDE;
virtual User* GetActiveUser() OVERRIDE;
virtual const User* GetPrimaryUser() const OVERRIDE;
- virtual User* GetUserByProfile(Profile* profile) const OVERRIDE;
virtual MultiProfileUserController* GetMultiProfileUserController() OVERRIDE;
virtual UserImageManager* GetUserImageManager(
diff --git a/chrome/browser/chromeos/login/users/multi_profile_user_controller.cc b/chrome/browser/chromeos/login/users/multi_profile_user_controller.cc
index 23df4be..980955a 100644
--- a/chrome/browser/chromeos/login/users/multi_profile_user_controller.cc
+++ b/chrome/browser/chromeos/login/users/multi_profile_user_controller.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/policy/policy_cert_service.h"
#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
@@ -117,7 +118,8 @@ MultiProfileUserController::IsUserAllowedInSession(
// used them yet then it can become tainted at any time during this session;
// disable secondary profiles in this case too.
Profile* primary_user_profile =
- primary_user ? user_manager->GetProfileByUser(primary_user) : NULL;
+ primary_user ? ProfileHelper::Get()->GetProfileByUser(primary_user)
+ : NULL;
policy::PolicyCertService* service =
primary_user_profile ? policy::PolicyCertServiceFactory::GetForProfile(
primary_user_profile)
diff --git a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
index aa1b1af..dba0cd2 100644
--- a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
+++ b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/policy/policy_cert_service.h"
#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
#include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
@@ -123,7 +124,8 @@ class MultiProfileUserControllerTest
user_profile->set_profile_name(user_email);
user_profiles_.push_back(user_profile);
- fake_user_manager_->SetProfileForUser(user, user_profile);
+ ProfileHelper::Get()->SetUserToProfileMappingForTesting(user,
+ user_profile);
}
}
diff --git a/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc b/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc
index 531e9b2..311df5c 100644
--- a/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/users/supervised_user_manager_impl.cc
@@ -505,7 +505,7 @@ void SupervisedUserManagerImpl::LoadSupervisedUserToken(
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());
+ ProfileHelper::Get()->GetUserByProfile(profile)->username_hash());
PostTaskAndReplyWithResult(
content::BrowserThread::GetBlockingPool(),
FROM_HERE,
diff --git a/chrome/browser/chromeos/login/users/user_manager.cc b/chrome/browser/chromeos/login/users/user_manager.cc
index bc0b3e4..ccac4b1 100644
--- a/chrome/browser/chromeos/login/users/user_manager.cc
+++ b/chrome/browser/chromeos/login/users/user_manager.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "base/prefs/pref_registry_simple.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chrome/browser/chromeos/login/users/user_manager_impl.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
@@ -119,7 +118,7 @@ ScopedTestUserManager::ScopedTestUserManager() {
UserManager::Initialize();
// ProfileHelper has to be initialized after UserManager instance is created.
- g_browser_process->platform_part()->profile_helper()->Initialize();
+ ProfileHelper::Get()->Initialize();
}
ScopedTestUserManager::~ScopedTestUserManager() {
diff --git a/chrome/browser/chromeos/login/users/user_manager.h b/chrome/browser/chromeos/login/users/user_manager.h
index e5652a2..dbd8a29 100644
--- a/chrome/browser/chromeos/login/users/user_manager.h
+++ b/chrome/browser/chromeos/login/users/user_manager.h
@@ -226,12 +226,6 @@ class UserManager {
// first signed-in user and does not change thereafter.
virtual const User* GetPrimaryUser() const = 0;
- // Returns NULL if User is not created.
- virtual User* GetUserByProfile(Profile* profile) const = 0;
-
- /// Returns NULL if profile for user is not found or is not fully loaded.
- virtual Profile* GetProfileByUser(const User* user) const = 0;
-
// Saves user's oauth token status in local state preferences.
virtual void SaveUserOAuthStatus(
const std::string& user_id,
@@ -352,10 +346,6 @@ class UserManager {
// Returns true if locally managed users allowed.
virtual bool AreLocallyManagedUsersAllowed() const = 0;
- // Returns profile dir for the user identified by |user_id|.
- virtual base::FilePath GetUserProfileDir(const std::string& user_id)
- const = 0;
-
private:
friend class ScopedUserManagerEnabler;
diff --git a/chrome/browser/chromeos/login/users/user_manager_impl.cc b/chrome/browser/chromeos/login/users/user_manager_impl.cc
index 0d8c01a..2262398 100644
--- a/chrome/browser/chromeos/login/users/user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/users/user_manager_impl.cc
@@ -49,8 +49,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -60,8 +58,6 @@
#include "chromeos/cryptohome/async_method_caller.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/login/login_state.h"
-#include "chromeos/network/portal_detector/network_portal_detector.h"
-#include "chromeos/network/portal_detector/network_portal_detector_strategy.h"
#include "chromeos/settings/cros_settings_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -149,17 +145,6 @@ void ParseUserList(const base::ListValue& users_list,
}
}
-class UserHashMatcher {
- public:
- explicit UserHashMatcher(const std::string& h) : username_hash(h) {}
- bool operator()(const User* user) const {
- return user->username_hash() == username_hash;
- }
-
- private:
- const std::string& username_hash;
-};
-
// Runs on SequencedWorkerPool thread. Passes resolved locale to
// |on_resolve_callback| on UI thread.
void ResolveLocale(
@@ -353,7 +338,7 @@ UserList UserManagerImpl::GetUnlockUsers() const {
return UserList();
UserList unlock_users;
- Profile* profile = GetProfileByUser(primary_user_);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(primary_user_);
std::string primary_behavior =
profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior);
@@ -368,7 +353,7 @@ UserList UserManagerImpl::GetUnlockUsers() const {
for (UserList::const_iterator it = logged_in_users.begin();
it != logged_in_users.end(); ++it) {
User* user = (*it);
- Profile* profile = GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
const std::string behavior =
profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior);
if (behavior == MultiProfileUserController::kBehaviorUnrestricted &&
@@ -651,53 +636,6 @@ const User* UserManagerImpl::GetPrimaryUser() const {
return primary_user_;
}
-User* UserManagerImpl::GetUserByProfile(Profile* profile) const {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (ProfileHelper::IsSigninProfile(profile))
- return NULL;
-
- // Special case for non-CrOS tests that do create several profiles
- // and don't really care about mapping to the real user.
- // Without multi-profiles on Chrome OS such tests always got active_user_.
- // Now these tests will specify special flag to continue working.
- // In future those tests can get a proper CrOS configuration i.e. register
- // and login several users if they want to work with an additional profile.
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kIgnoreUserProfileMappingForTests)) {
- return active_user_;
- }
-
- const std::string username_hash =
- ProfileHelper::GetUserIdHashFromProfile(profile);
- const UserList& users = GetUsers();
- const UserList::const_iterator pos = std::find_if(
- users.begin(), users.end(), UserHashMatcher(username_hash));
- if (pos != users.end())
- return *pos;
-
- // Many tests do not have their users registered with UserManager and
- // runs here. If |active_user_| matches |profile|, returns it.
- return active_user_ &&
- ProfileHelper::GetProfilePathByUserIdHash(
- active_user_->username_hash()) == profile->GetPath()
- ? active_user_
- : NULL;
-}
-
-Profile* UserManagerImpl::GetProfileByUser(const User* user) const {
- Profile* profile = NULL;
- if (user->is_profile_created())
- profile = ProfileHelper::GetProfileByUserIdHash(user->username_hash());
- else
- profile = ProfileManager::GetActiveUserProfile();
-
- // GetActiveUserProfile() or GetProfileByUserIdHash() returns a new instance
- // of ProfileImpl(), but actually its OffTheRecordProfile() should be used.
- if (profile && IsLoggedInAsGuest())
- profile = profile->GetOffTheRecordProfile();
- return profile;
-}
-
void UserManagerImpl::SaveUserOAuthStatus(
const std::string& user_id,
User::OAuthTokenStatus oauth_token_status) {
@@ -860,7 +798,7 @@ void UserManagerImpl::Observe(int type,
}
case chrome::NOTIFICATION_PROFILE_CREATED: {
Profile* profile = content::Source<Profile>(source).ptr();
- User* user = GetUserByProfile(profile);
+ User* user = ProfileHelper::Get()->GetUserByProfile(profile);
if (user != NULL)
user->set_profile_is_created();
// If there is pending user switch, do it now.
@@ -1442,20 +1380,7 @@ void UserManagerImpl::RetailModeUserLoggedIn() {
void UserManagerImpl::NotifyOnLogin() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Override user homedir, check for ProfileManager being initialized as
- // it may not exist in unit tests.
- if (g_browser_process->profile_manager()) {
- if (GetLoggedInUsers().size() == 1) {
- base::FilePath homedir = ProfileHelper::GetProfilePathByUserIdHash(
- primary_user_->username_hash());
- // This path has been either created by cryptohome (on real Chrome OS
- // device) or by ProfileManager (on chromeos=1 desktop builds).
- PathService::OverrideAndCreateIfNeeded(base::DIR_HOME,
- homedir,
- true /* path is absolute */,
- false /* don't create */);
- }
- }
+ SessionManager::OverrideHomedir();
UpdateNumberOfUsers();
NotifyActiveUserHashChanged(active_user_->username_hash());
@@ -1734,22 +1659,6 @@ bool UserManagerImpl::AreLocallyManagedUsersAllowed() const {
return locally_managed_users_allowed;
}
-base::FilePath UserManagerImpl::GetUserProfileDir(
- const std::string& user_id) const {
- // TODO(dpolukhin): Remove Chrome OS specific profile path logic from
- // ProfileManager and use only this function to construct profile path.
- // TODO(nkostylev): Cleanup profile dir related code paths crbug.com/294233
- base::FilePath profile_dir;
- const User* user = FindUser(user_id);
- if (user && !user->username_hash().empty())
- profile_dir = ProfileHelper::GetUserProfileDir(user->username_hash());
-
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- profile_dir = profile_manager->user_data_dir().Append(profile_dir);
-
- return profile_dir;
-}
-
UserFlow* UserManagerImpl::GetDefaultUserFlow() const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!default_flow_.get())
diff --git a/chrome/browser/chromeos/login/users/user_manager_impl.h b/chrome/browser/chromeos/login/users/user_manager_impl.h
index d6ac323..9540af2 100644
--- a/chrome/browser/chromeos/login/users/user_manager_impl.h
+++ b/chrome/browser/chromeos/login/users/user_manager_impl.h
@@ -84,8 +84,6 @@ class UserManagerImpl
virtual const User* GetActiveUser() const OVERRIDE;
virtual User* GetActiveUser() OVERRIDE;
virtual const User* GetPrimaryUser() const OVERRIDE;
- virtual User* GetUserByProfile(Profile* profile) const OVERRIDE;
- virtual Profile* GetProfileByUser(const User* user) const OVERRIDE;
virtual void SaveUserOAuthStatus(
const std::string& user_id,
User::OAuthTokenStatus oauth_token_status) OVERRIDE;
@@ -131,8 +129,6 @@ class UserManagerImpl
virtual void SetUserFlow(const std::string& user_id, UserFlow* flow) OVERRIDE;
virtual void ResetUserFlow(const std::string& user_id) OVERRIDE;
virtual bool AreLocallyManagedUsersAllowed() const OVERRIDE;
- virtual base::FilePath GetUserProfileDir(
- const std::string& user_id) const OVERRIDE;
// content::NotificationObserver implementation.
virtual void Observe(int type,
diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc
index a4df012..83aa5d5 100644
--- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc
+++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_util.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_paths.h"
#include "chromeos/chromeos_paths.h"
@@ -63,7 +64,7 @@ const SkColor kRedImageColor = SkColorSetARGB(255, 199, 6, 7);
const SkColor kGreenImageColor = SkColorSetARGB(255, 38, 196, 15);
policy::CloudPolicyStore* GetStoreForUser(const User* user) {
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
if (!profile) {
ADD_FAILURE();
return NULL;
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_factory.cc b/chrome/browser/chromeos/ownership/owner_settings_service_factory.cc
index a25222b..e69f77e 100644
--- a/chrome/browser/chromeos/ownership/owner_settings_service_factory.cc
+++ b/chrome/browser/chromeos/ownership/owner_settings_service_factory.cc
@@ -41,7 +41,7 @@ void OwnerSettingsServiceFactory::SetUsername(const std::string& username) {
const User* user = UserManager::Get()->FindUser(username_);
if (!user || !user->is_profile_created())
return;
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
if (!profile)
return;
OwnerSettingsService* service = GetForProfile(profile);
diff --git a/chrome/browser/chromeos/policy/cloud_external_data_policy_observer.cc b/chrome/browser/chromeos/policy/cloud_external_data_policy_observer.cc
index 1734068..3304bd9 100644
--- a/chrome/browser/chromeos/policy/cloud_external_data_policy_observer.cc
+++ b/chrome/browser/chromeos/policy/cloud_external_data_policy_observer.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -170,7 +171,8 @@ void CloudExternalDataPolicyObserver::Observe(
}
Profile* profile = content::Details<Profile>(details).ptr();
- const chromeos::User* user = user_manager_->GetUserByProfile(profile);
+ const chromeos::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (!user) {
NOTREACHED();
return;
diff --git a/chrome/browser/chromeos/policy/policy_cert_service_factory.cc b/chrome/browser/chromeos/policy/policy_cert_service_factory.cc
index 4e33307..2cf0fb6 100644
--- a/chrome/browser/chromeos/policy/policy_cert_service_factory.cc
+++ b/chrome/browser/chromeos/policy/policy_cert_service_factory.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/policy/policy_cert_service.h"
#include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
#include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
@@ -94,8 +95,8 @@ KeyedService* PolicyCertServiceFactory::BuildServiceInstanceFor(
Profile* profile = static_cast<Profile*>(context);
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
- chromeos::User* user =
- user_manager->GetUserByProfile(profile->GetOriginalProfile());
+ chromeos::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile(
+ profile->GetOriginalProfile());
if (!user)
return NULL;
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
index f6fa6ec..2e949c9 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/users/user.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/user_cloud_external_data_manager.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
@@ -123,8 +122,8 @@ scoped_ptr<UserCloudPolicyManagerChromeOS>
// |user| should never be NULL except for the signin profile. This object is
// created as part of the Profile creation, which happens right after
// sign-in. The just-signed-in User is the active user during that time.
- chromeos::UserManager* user_manager = chromeos::UserManager::Get();
- chromeos::User* user = user_manager->GetUserByProfile(profile);
+ chromeos::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
CHECK(user);
// Only USER_TYPE_REGULAR users have user cloud policy.
diff --git a/chrome/browser/chromeos/policy/user_network_configuration_updater_factory.cc b/chrome/browser/chromeos/policy/user_network_configuration_updater_factory.cc
index 63bc5e6..37046a4 100644
--- a/chrome/browser/chromeos/policy/user_network_configuration_updater_factory.cc
+++ b/chrome/browser/chromeos/policy/user_network_configuration_updater_factory.cc
@@ -65,12 +65,12 @@ KeyedService* UserNetworkConfigurationUpdaterFactory::BuildServiceInstanceFor(
if (chromeos::ProfileHelper::IsSigninProfile(profile))
return NULL; // On the login screen only device network policies apply.
- chromeos::UserManager* user_manager = chromeos::UserManager::Get();
- chromeos::User* user = user_manager->GetUserByProfile(profile);
+ chromeos::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
DCHECK(user);
// Currently, only the network policy of the primary user is supported. See
// also http://crbug.com/310685 .
- if (user != user_manager->GetPrimaryUser())
+ if (user != chromeos::UserManager::Get()->GetPrimaryUser())
return NULL;
const bool allow_trusted_certs_from_policy =
diff --git a/chrome/browser/chromeos/preferences_browsertest.cc b/chrome/browser/chromeos/preferences_browsertest.cc
index 6bb458b..7b60662 100644
--- a/chrome/browser/chromeos/preferences_browsertest.cc
+++ b/chrome/browser/chromeos/preferences_browsertest.cc
@@ -13,7 +13,9 @@
#include "chrome/browser/chromeos/login/login_manager_test.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
+#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/preferences.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/chromeos/system/fake_input_device_settings.h"
@@ -143,7 +145,8 @@ IN_PROC_BROWSER_TEST_F(PreferencesTest, MultiProfiles) {
// settings has been changed.
LoginUser(kTestUsers[0]);
const User* user1 = user_manager->FindUser(kTestUsers[0]);
- PrefService* prefs1 = user_manager->GetProfileByUser(user1)->GetPrefs();
+ PrefService* prefs1 =
+ ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs();
SetPrefs(prefs1, false);
content::RunAllPendingInMessageLoop();
CheckSettingsCorrespondToPrefs(prefs1);
@@ -156,7 +159,8 @@ IN_PROC_BROWSER_TEST_F(PreferencesTest, MultiProfiles) {
content::RunAllPendingInMessageLoop();
const User* user2 = user_manager->FindUser(kTestUsers[1]);
EXPECT_TRUE(user2->is_active());
- PrefService* prefs2 = user_manager->GetProfileByUser(user2)->GetPrefs();
+ PrefService* prefs2 =
+ ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs();
SetPrefs(prefs2, true);
// Check that settings were changed accordingly.
diff --git a/chrome/browser/chromeos/profiles/profile_helper.cc b/chrome/browser/chromeos/profiles/profile_helper.cc
index a341a642..70edd29 100644
--- a/chrome/browser/chromeos/profiles/profile_helper.cc
+++ b/chrome/browser/chromeos/profiles/profile_helper.cc
@@ -17,6 +17,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/chromeos_switches.h"
+#include "content/public/browser/browser_thread.h"
namespace chromeos {
@@ -33,13 +34,28 @@ bool ShouldAddProfileDirPrefix(const std::string& user_id_hash) {
user_id_hash != chrome::kTestUserProfileDir;
}
+class UsernameHashMatcher {
+ public:
+ explicit UsernameHashMatcher(const std::string& h) : username_hash(h) {}
+ bool operator()(const User* user) const {
+ return user->username_hash() == username_hash;
+ }
+
+ private:
+ const std::string& username_hash;
+};
+
} // anonymous namespace
+// static
+bool ProfileHelper::enable_profile_to_user_testing = false;
+bool ProfileHelper::always_return_primary_user_for_testing = false;
+
////////////////////////////////////////////////////////////////////////////////
// ProfileHelper, public
ProfileHelper::ProfileHelper()
- : signin_profile_clear_requested_(false) {
+ : signin_profile_clear_requested_(false) {
}
ProfileHelper::~ProfileHelper() {
@@ -50,6 +66,11 @@ ProfileHelper::~ProfileHelper() {
}
// static
+ProfileHelper* ProfileHelper::Get() {
+ return g_browser_process->platform_part()->profile_helper();
+}
+
+// static
Profile* ProfileHelper::GetProfileByUserIdHash(
const std::string& user_id_hash) {
ProfileManager* profile_manager = g_browser_process->profile_manager();
@@ -124,6 +145,23 @@ base::FilePath ProfileHelper::GetUserProfileDir(
}
// static
+base::FilePath ProfileHelper::GetUserProfileDirByUserId(
+ const std::string& user_id) {
+ // TODO(dpolukhin): Remove Chrome OS specific profile path logic from
+ // ProfileManager and use only this function to construct profile path.
+ // TODO(nkostylev): Cleanup profile dir related code paths crbug.com/294233
+ base::FilePath profile_dir;
+ const User* user = UserManager::Get()->FindUser(user_id);
+ if (user && !user->username_hash().empty())
+ profile_dir = ProfileHelper::GetUserProfileDir(user->username_hash());
+
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ profile_dir = profile_manager->user_data_dir().Append(profile_dir);
+
+ return profile_dir;
+}
+
+// static
bool ProfileHelper::IsSigninProfile(Profile* profile) {
return profile->GetPath().BaseName().value() == chrome::kInitialProfile;
}
@@ -132,11 +170,11 @@ bool ProfileHelper::IsSigninProfile(Profile* profile) {
bool ProfileHelper::IsOwnerProfile(Profile* profile) {
if (!profile)
return false;
- chromeos::UserManager* manager = chromeos::UserManager::Get();
- chromeos::User* user = manager->GetUserByProfile(profile);
+ chromeos::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
return false;
- return user->email() == manager->GetOwnerEmail();
+
+ return user->email() == chromeos::UserManager::Get()->GetOwnerEmail();
}
void ProfileHelper::ProfileStartup(Profile* profile, bool process_startup) {
@@ -186,6 +224,80 @@ void ProfileHelper::ClearSigninProfile(const base::Closure& on_clear_callback) {
BrowsingDataHelper::ALL);
}
+Profile* ProfileHelper::GetProfileByUser(const User* user) {
+ // This map is non-empty only in tests.
+ if (!user_to_profile_for_testing_.empty()) {
+ std::map<const User*, Profile*>::const_iterator it =
+ user_to_profile_for_testing_.find(user);
+ return it == user_to_profile_for_testing_.end() ? NULL : it->second;
+ }
+
+ Profile* profile = NULL;
+ if (user->is_profile_created())
+ profile = ProfileHelper::GetProfileByUserIdHash(user->username_hash());
+ else
+ profile = ProfileManager::GetActiveUserProfile();
+
+ // GetActiveUserProfile() or GetProfileByUserIdHash() returns a new instance
+ // of ProfileImpl(), but actually its OffTheRecordProfile() should be used.
+ if (profile && UserManager::Get()->IsLoggedInAsGuest())
+ profile = profile->GetOffTheRecordProfile();
+ return profile;
+}
+
+User* ProfileHelper::GetUserByProfile(Profile* profile) {
+ // This map is non-empty only in tests.
+ if (enable_profile_to_user_testing || !user_list_for_testing_.empty()) {
+ if (always_return_primary_user_for_testing)
+ return const_cast<User*>(UserManager::Get()->GetPrimaryUser());
+
+ const std::string& user_name = profile->GetProfileName();
+ for (UserList::const_iterator it = user_list_for_testing_.begin();
+ it != user_list_for_testing_.end();
+ ++it) {
+ if ((*it)->email() == user_name)
+ return *it;
+ }
+
+ // In case of test setup we should always default to primary user.
+ return const_cast<User*>(UserManager::Get()->GetPrimaryUser());
+ }
+
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (ProfileHelper::IsSigninProfile(profile))
+ return NULL;
+
+ UserManager* user_manager = UserManager::Get();
+
+ // Special case for non-CrOS tests that do create several profiles
+ // and don't really care about mapping to the real user.
+ // Without multi-profiles on Chrome OS such tests always got active_user_.
+ // Now these tests will specify special flag to continue working.
+ // In future those tests can get a proper CrOS configuration i.e. register
+ // and login several users if they want to work with an additional profile.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kIgnoreUserProfileMappingForTests)) {
+ return user_manager->GetActiveUser();
+ }
+
+ const std::string username_hash =
+ ProfileHelper::GetUserIdHashFromProfile(profile);
+ const UserList& users = user_manager->GetUsers();
+ const UserList::const_iterator pos = std::find_if(
+ users.begin(), users.end(), UsernameHashMatcher(username_hash));
+ if (pos != users.end())
+ return *pos;
+
+ // Many tests do not have their users registered with UserManager and
+ // runs here. If |active_user_| matches |profile|, returns it.
+ const User* active_user = user_manager->GetActiveUser();
+ return active_user &&
+ ProfileHelper::GetProfilePathByUserIdHash(
+ active_user->username_hash()) == profile->GetPath()
+ ? const_cast<User*>(active_user)
+ : NULL;
+}
+
////////////////////////////////////////////////////////////////////////////////
// ProfileHelper, BrowsingDataRemover::Observer implementation:
@@ -224,4 +336,24 @@ void ProfileHelper::ActiveUserHashChanged(const std::string& hash) {
VLOG(1) << "Switching to profile path: " << profile_path.value();
}
+void ProfileHelper::SetProfileToUserMappingForTesting(User* user) {
+ user_list_for_testing_.push_back(user);
+}
+
+// static
+void ProfileHelper::SetProfileToUserForTestingEnabled(bool enabled) {
+ enable_profile_to_user_testing = enabled;
+}
+
+// static
+void ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(bool value) {
+ always_return_primary_user_for_testing = true;
+ ProfileHelper::SetProfileToUserForTestingEnabled(true);
+}
+
+void ProfileHelper::SetUserToProfileMappingForTesting(const User* user,
+ Profile* profile) {
+ user_to_profile_for_testing_[user] = profile;
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/profiles/profile_helper.h b/chrome/browser/chromeos/profiles/profile_helper.h
index da9fccb..bd1295df 100644
--- a/chrome/browser/chromeos/profiles/profile_helper.h
+++ b/chrome/browser/chromeos/profiles/profile_helper.h
@@ -16,11 +16,16 @@
#include "chrome/browser/chromeos/login/users/user_manager.h"
class Profile;
+class User;
namespace base {
class FilePath;
}
+namespace extensions {
+class ExtensionGarbageCollectorChromeOSUnitTest;
+}
+
namespace chromeos {
// This helper class is used on Chrome OS to keep track of currently
@@ -41,6 +46,11 @@ class ProfileHelper : public BrowsingDataRemover::Observer,
ProfileHelper();
virtual ~ProfileHelper();
+ // Returns ProfileHelper instance. This class is not singleton and is owned
+ // by BrowserProcess/BrowserProcessPlatformPart. This method keeps that
+ // knowledge in one place.
+ static ProfileHelper* Get();
+
// Returns Profile instance that corresponds to |user_id_hash|.
static Profile* GetProfileByUserIdHash(const std::string& user_id_hash);
@@ -61,6 +71,9 @@ class ProfileHelper : public BrowsingDataRemover::Observer,
// could not be extracted from |profile|.
static std::string GetUserIdHashFromProfile(Profile* profile);
+ // Returns profile dir for the user identified by |user_id|.
+ static base::FilePath GetUserProfileDirByUserId(const std::string& user_id);
+
// Returns user profile dir in a format [u-user_id_hash].
static base::FilePath GetUserProfileDir(const std::string& user_id_hash);
@@ -90,7 +103,20 @@ class ProfileHelper : public BrowsingDataRemover::Observer,
// Callback can be empty. Not thread-safe.
void ClearSigninProfile(const base::Closure& on_clear_callback);
+ // Returns NULL if profile for user is not found or is not fully loaded.
+ Profile* GetProfileByUser(const User* user);
+
+ // Returns NULL if User is not created.
+ User* GetUserByProfile(Profile* profile);
+
private:
+ friend class DeviceSettingsTestBase;
+ friend class extensions::ExtensionGarbageCollectorChromeOSUnitTest;
+ friend class FakeUserManager;
+ friend class KioskTest;
+ friend class MockUserManager;
+ friend class MultiProfileUserControllerTest;
+ friend class ParallelAuthenticatorTest;
friend class ProfileHelperTest;
friend class ProfileListChromeOSTest;
@@ -105,6 +131,22 @@ class ProfileHelper : public BrowsingDataRemover::Observer,
// UserManager::UserSessionStateObserver implementation:
virtual void ActiveUserHashChanged(const std::string& hash) OVERRIDE;
+ // Associates |user| with profile with the same user_id,
+ // for GetUserByProfile() testing.
+ void SetProfileToUserMappingForTesting(User* user);
+
+ // Enables/disables testing code path in GetUserByProfile() like
+ // always return primary user (when always_return_primary_user_for_testing is
+ // set).
+ static void SetProfileToUserForTestingEnabled(bool enabled);
+
+ // Enables/disables testing GetUserByProfile() by always returning
+ // primary user.
+ static void SetAlwaysReturnPrimaryUserForTesting(bool value);
+
+ // Associates |profile| with |user|, for GetProfileByUser() testing.
+ void SetUserToProfileMappingForTesting(const User* user, Profile* profile);
+
// Identifies path to active user profile on Chrome OS.
std::string active_user_id_hash_;
@@ -114,6 +156,22 @@ class ProfileHelper : public BrowsingDataRemover::Observer,
// List of callbacks called after signin profile clearance.
std::vector<base::Closure> on_clear_callbacks_;
+ // Used for testing by unit tests and FakeUserManager/MockUserManager.
+ std::map<const User*, Profile*> user_to_profile_for_testing_;
+
+ // When this list is not empty GetUserByProfile() will find user that has
+ // the same user_id as |profile|->GetProfileName().
+ UserList user_list_for_testing_;
+
+ // If true testing code path is used in GetUserByProfile() even if
+ // user_list_for_testing_ list is empty. In that case primary user will always
+ // be returned.
+ static bool enable_profile_to_user_testing;
+
+ // If true and enable_profile_to_user_testing is true then primary user will
+ // always be returned by GetUserByProfile().
+ static bool always_return_primary_user_for_testing;
+
DISALLOW_COPY_AND_ASSIGN(ProfileHelper);
};
diff --git a/chrome/browser/chromeos/profiles/profile_list_chromeos_unittest.cc b/chrome/browser/chromeos/profiles/profile_list_chromeos_unittest.cc
index 183e146..37f6900b1 100644
--- a/chrome/browser/chromeos/profiles/profile_list_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/profiles/profile_list_chromeos_unittest.cc
@@ -223,8 +223,7 @@ TEST_F(ProfileListChromeOSTest, ActiveItem) {
// Initialize ProfileHelper, it will be accessed from GetActiveProfileIndex.
std::string email_string = base::UTF16ToASCII(name1) + "@example.com";
std::string hash = email_string + kUserIdHashSuffix;
- ActiveUserChanged(
- g_browser_process->platform_part()->profile_helper(), hash);
+ ActiveUserChanged(ProfileHelper::Get(), hash);
AvatarMenu* menu = GetAvatarMenu();
diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.cc b/chrome/browser/chromeos/settings/device_settings_test_helper.cc
index 8aa4311..e1e553d 100644
--- a/chrome/browser/chromeos/settings/device_settings_test_helper.cc
+++ b/chrome/browser/chromeos/settings/device_settings_test_helper.cc
@@ -10,8 +10,10 @@
#include "chrome/browser/chromeos/ownership/owner_settings_service.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/chromeos/settings/mock_owner_key_util.h"
+#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_dbus_thread_manager.h"
@@ -258,7 +260,9 @@ void DeviceSettingsTestBase::InitOwner(const std::string& user_id,
if (!user) {
user = user_manager_->AddUser(user_id);
profile_->set_profile_name(user_id);
- user_manager_->SetProfileForUser(user, profile_.get());
+
+ ProfileHelper::Get()->SetUserToProfileMappingForTesting(user,
+ profile_.get());
}
OwnerSettingsService* service =
OwnerSettingsServiceFactory::GetForProfile(profile_.get());
diff --git a/chrome/browser/extensions/extension_assets_manager_chromeos.cc b/chrome/browser/extensions/extension_assets_manager_chromeos.cc
index e237aba..aa16ac8 100644
--- a/chrome/browser/extensions/extension_assets_manager_chromeos.cc
+++ b/chrome/browser/extensions/extension_assets_manager_chromeos.cc
@@ -17,6 +17,7 @@
#include "base/sys_info.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -536,7 +537,8 @@ bool ExtensionAssetsManagerChromeOS::CleanUpExtension(
} else if (user->is_logged_in()) {
// For logged in user also check that this path is actually used as
// installed extension or as delayed install.
- Profile* profile = user_manager->GetProfileByUser(user);
+ Profile* profile =
+ chromeos::ProfileHelper::Get()->GetProfileByUser(user);
ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile);
if (!extension_prefs || extension_prefs->pref_service()->ReadOnly())
return false;
diff --git a/chrome/browser/extensions/extension_garbage_collector_chromeos.cc b/chrome/browser/extensions/extension_garbage_collector_chromeos.cc
index fe630b3..7be83e3 100644
--- a/chrome/browser/extensions/extension_garbage_collector_chromeos.cc
+++ b/chrome/browser/extensions/extension_garbage_collector_chromeos.cc
@@ -3,8 +3,8 @@
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_garbage_collector_chromeos.h"
-
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
#include "chrome/browser/extensions/extension_service.h"
#include "extensions/browser/extension_system.h"
@@ -57,7 +57,8 @@ bool ExtensionGarbageCollectorChromeOS::CanGarbageCollectSharedExtensions() {
const chromeos::UserList& active_users = user_manager->GetLoggedInUsers();
for (size_t i = 0; i < active_users.size(); i++) {
- Profile* profile = user_manager->GetProfileByUser(active_users[i]);
+ Profile* profile =
+ chromeos::ProfileHelper::Get()->GetProfileByUser(active_users[i]);
ExtensionGarbageCollectorChromeOS* gc =
ExtensionGarbageCollectorChromeOS::Get(profile);
if (gc && gc->crx_installs_in_progress_ > 0)
diff --git a/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc b/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc
index 14cb076..d8a8a78 100644
--- a/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc
+++ b/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc
@@ -10,6 +10,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/login/users/fake_user_manager.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
#include "chrome/browser/extensions/extension_garbage_collector_chromeos.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -64,7 +65,7 @@ class ExtensionGarbageCollectorChromeOSUnitTest
GetFakeUserManager()->AddUser(chromeos::UserManager::kStubUser);
GetFakeUserManager()->LoginUser(chromeos::UserManager::kStubUser);
- GetFakeUserManager()->SetProfileForUser(
+ chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(
GetFakeUserManager()->GetActiveUser(), profile_.get());
}
diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc
index dd2a6ad4..ed1a417 100644
--- a/chrome/browser/extensions/external_provider_impl.cc
+++ b/chrome/browser/extensions/external_provider_impl.cc
@@ -42,6 +42,7 @@
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#else
#include "chrome/browser/extensions/default_apps.h"
#endif
@@ -363,7 +364,7 @@ void ExternalProviderImpl::CreateExternalProviders(
g_browser_process->platform_part()->browser_policy_connector_chromeos();
bool is_chrome_os_public_session = false;
const chromeos::User* user =
- chromeos::UserManager::Get()->GetUserByProfile(profile);
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
policy::DeviceLocalAccount::Type account_type;
if (user && policy::IsDeviceLocalAccountUser(user->email(), &account_type)) {
if (account_type == policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)
diff --git a/chrome/browser/invalidation/profile_invalidation_provider_factory_browsertest.cc b/chrome/browser/invalidation/profile_invalidation_provider_factory_browsertest.cc
index 41b939c..8c8d556 100644
--- a/chrome/browser/invalidation/profile_invalidation_provider_factory_browsertest.cc
+++ b/chrome/browser/invalidation/profile_invalidation_provider_factory_browsertest.cc
@@ -116,8 +116,9 @@ IN_PROC_BROWSER_TEST_F(ProfileInvalidationProviderFactoryGuestBrowserTest,
NoInvalidationService) {
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
EXPECT_TRUE(user_manager->IsLoggedInAsGuest());
- Profile* guest_profile = user_manager->GetProfileByUser(
- user_manager->GetActiveUser())->GetOriginalProfile();
+ Profile* guest_profile = chromeos::ProfileHelper::Get()
+ ->GetProfileByUser(user_manager->GetActiveUser())
+ ->GetOriginalProfile();
Profile* login_profile =
chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile();
EXPECT_FALSE(CanConstructProfileInvalidationProvider(guest_profile));
diff --git a/chrome/browser/net/nss_context_chromeos_browsertest.cc b/chrome/browser/net/nss_context_chromeos_browsertest.cc
index 48c9d3a..8eec6e6 100644
--- a/chrome/browser/net/nss_context_chromeos_browsertest.cc
+++ b/chrome/browser/net/nss_context_chromeos_browsertest.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "content/public/browser/browser_thread.h"
#include "net/cert/nss_cert_database.h"
@@ -134,8 +135,8 @@ IN_PROC_BROWSER_TEST_F(NSSContextChromeOSBrowserTest, TwoUsers) {
// Log in first user and get their DB.
LoginUser(kTestUser1);
- Profile* profile1 =
- user_manager->GetProfileByUser(user_manager->FindUser(kTestUser1));
+ Profile* profile1 = chromeos::ProfileHelper::Get()->GetProfileByUser(
+ user_manager->FindUser(kTestUser1));
ASSERT_TRUE(profile1);
DBTester tester1(profile1);
@@ -146,8 +147,8 @@ IN_PROC_BROWSER_TEST_F(NSSContextChromeOSBrowserTest, TwoUsers) {
base::RunLoop().RunUntilIdle();
AddUser(kTestUser2);
- Profile* profile2 =
- user_manager->GetProfileByUser(user_manager->FindUser(kTestUser2));
+ Profile* profile2 = chromeos::ProfileHelper::Get()->GetProfileByUser(
+ user_manager->FindUser(kTestUser2));
ASSERT_TRUE(profile2);
DBTester tester2(profile2);
diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc
index 06f48ce..69e9ca9 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -457,7 +457,7 @@ void MessageCenterSettingsController::CreateNotifierGroupForGuestLogin() {
return;
chromeos::User* user = user_manager->GetActiveUser();
- Profile* profile = user_manager->GetProfileByUser(user);
+ Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(user);
DCHECK(profile);
notifier_groups_.push_back(
new message_center::ProfileNotifierGroup(gfx::Image(user->GetImage()),
@@ -494,7 +494,7 @@ void MessageCenterSettingsController::RebuildNotifierGroups() {
// UserManager may not exist in some tests.
if (chromeos::UserManager::IsInitialized()) {
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
- if (user_manager->GetUserByProfile(group->profile()) !=
+ if (chromeos::ProfileHelper::Get()->GetUserByProfile(group->profile()) !=
user_manager->GetActiveUser()) {
continue;
}
@@ -516,10 +516,10 @@ void MessageCenterSettingsController::RebuildNotifierGroups() {
chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
// Do not invoke CreateNotifierGroupForGuestLogin() directly. In some tests,
// this method may be called before the primary profile is created, which
- // means user_manager->GetProfileByUser() will create a new primary profile.
- // But creating a primary profile causes an Observe() before registreing it
- // as the primary one, which causes this method which causes another
- // creating a primary profile, and causes an infinite loop.
+ // means ProfileHelper::Get()->GetProfileByUser() will create a new primary
+ // profile. But creating a primary profile causes an Observe() before
+ // registering it as the primary one, which causes this method which causes
+ // another creating a primary profile, and causes an infinite loop.
// Thus, it would be better to delay creating group for guest login.
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
diff --git a/chrome/browser/policy/profile_policy_connector_factory.cc b/chrome/browser/policy/profile_policy_connector_factory.cc
index 6f00201..57cb2e6 100644
--- a/chrome/browser/policy/profile_policy_connector_factory.cc
+++ b/chrome/browser/policy/profile_policy_connector_factory.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/policy/schema_registry_service_factory.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/users/user.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
@@ -97,8 +96,7 @@ ProfilePolicyConnectorFactory::CreateForProfileInternal(
#if defined(OS_CHROMEOS)
chromeos::User* user = NULL;
if (!chromeos::ProfileHelper::IsSigninProfile(profile)) {
- chromeos::UserManager* user_manager = chromeos::UserManager::Get();
- user = user_manager->GetUserByProfile(profile);
+ user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
CHECK(user);
}
user_cloud_policy_manager =
diff --git a/chrome/browser/policy/schema_registry_service_factory.cc b/chrome/browser/policy/schema_registry_service_factory.cc
index 9da5afd..2972850 100644
--- a/chrome/browser/policy/schema_registry_service_factory.cc
+++ b/chrome/browser/policy/schema_registry_service_factory.cc
@@ -38,8 +38,8 @@ DeviceLocalAccountPolicyBroker* GetBroker(content::BrowserContext* context) {
return NULL;
}
- chromeos::UserManager* user_manager = chromeos::UserManager::Get();
- chromeos::User* user = user_manager->GetUserByProfile(profile);
+ chromeos::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
return NULL;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index d3d00e9..14786933 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -1172,7 +1172,7 @@ void ProfileImpl::ChangeAppLocale(
local_state->SetString(prefs::kApplicationLocale, new_locale);
if (chromeos::UserManager::Get()->GetOwnerEmail() ==
- chromeos::UserManager::Get()->GetUserByProfile(this)->email())
+ chromeos::ProfileHelper::Get()->GetUserByProfile(this)->email())
local_state->SetString(prefs::kOwnerLocale, new_locale);
}
@@ -1186,7 +1186,7 @@ void ProfileImpl::InitChromeOSPreferences() {
chromeos_preferences_.reset(new chromeos::Preferences());
chromeos_preferences_->Init(
PrefServiceSyncable::FromProfile(this),
- chromeos::UserManager::Get()->GetUserByProfile(this));
+ chromeos::ProfileHelper::Get()->GetUserByProfile(this));
}
#endif // defined(OS_CHROMEOS)
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 2cad2d9..0999308 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -108,6 +108,7 @@
#include "chrome/browser/chromeos/policy/policy_cert_service.h"
#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
#include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -227,7 +228,7 @@ class DebugDevToolsInterceptor : public net::URLRequestInterceptor {
//
// ProfileIOData::InitializeOnUIThread
// |
-// chromeos::UserManager::GetUserByProfile
+// ProfileHelper::Get()->GetUserByProfile()
// \---------------------------------------v
// StartNSSInitOnIOThread
// |
@@ -357,7 +358,8 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
#if defined(OS_CHROMEOS)
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
if (user_manager) {
- chromeos::User* user = user_manager->GetUserByProfile(profile);
+ chromeos::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (user) {
params->username_hash = user->username_hash();
bool is_primary_user = (user_manager->GetPrimaryUser() == user);
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 004960b..845f33c 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -315,8 +315,9 @@ Profile* ProfileManager::GetPrimaryUserProfile() {
return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
profile_manager->user_data_dir());
chromeos::UserManager* manager = chromeos::UserManager::Get();
- // Note: The user manager will take care of guest profiles.
- return manager->GetProfileByUser(manager->GetPrimaryUser());
+ // Note: The ProfileHelper will take care of guest profiles.
+ return chromeos::ProfileHelper::Get()->GetProfileByUser(
+ manager->GetPrimaryUser());
#else
return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
profile_manager->user_data_dir());
@@ -340,7 +341,8 @@ Profile* ProfileManager::GetActiveUserProfile() {
// created we load the profile using the profile directly.
// TODO: This should be cleaned up with the new profile manager.
if (user && user->is_profile_created())
- return manager->GetProfileByUser(user);
+ return chromeos::ProfileHelper::Get()->GetProfileByUser(user);
+
#endif
Profile* profile =
profile_manager->GetActiveUserOrOffTheRecordProfileFromPath(
@@ -472,12 +474,11 @@ base::FilePath ProfileManager::GetInitialProfileDir() {
// In case of multi-profiles ignore --login-profile switch.
// TODO(nkostylev): Some cases like Guest mode will have empty username_hash
// so default kLoginProfile dir will be used.
- std::string user_id_hash = g_browser_process->platform_part()->
- profile_helper()->active_user_id_hash();
- if (!user_id_hash.empty()) {
- profile_dir = g_browser_process->platform_part()->
- profile_helper()->GetActiveUserProfileDir();
- }
+ std::string user_id_hash =
+ chromeos::ProfileHelper::Get()->active_user_id_hash();
+ if (!user_id_hash.empty())
+ profile_dir = chromeos::ProfileHelper::Get()->GetActiveUserProfileDir();
+
relative_profile_dir = relative_profile_dir.Append(profile_dir);
return relative_profile_dir;
}
@@ -502,8 +503,7 @@ Profile* ProfileManager::GetLastUsedProfile(
// since it may refer to profile that has been in use in previous session.
// That profile dir may not be mounted in this session so instead return
// active profile from current session.
- profile_dir = g_browser_process->platform_part()->
- profile_helper()->GetActiveUserProfileDir();
+ profile_dir = chromeos::ProfileHelper::Get()->GetActiveUserProfileDir();
base::FilePath profile_path(user_data_dir);
Profile* profile = GetProfile(profile_path.Append(profile_dir));
diff --git a/chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc b/chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc
index 0778b82..ba44761 100644
--- a/chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc
+++ b/chrome/browser/supervised_user/chromeos/manager_password_service_factory.cc
@@ -6,7 +6,7 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/chromeos/manager_password_service.h"
@@ -43,8 +43,8 @@ ManagerPasswordServiceFactory::
KeyedService* ManagerPasswordServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile= static_cast<Profile*>(context);
- chromeos::User* user = chromeos::UserManager::Get()->
- GetUserByProfile(profile);
+ chromeos::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (chromeos::UserManager::Get()->GetSupervisedUserManager()->
HasSupervisedUsers(user->email())) {
ManagerPasswordService* result = new ManagerPasswordService();
diff --git a/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc b/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc
index 842f43b..17fcab2 100644
--- a/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc
+++ b/chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/chromeos/supervised_user_password_service.h"
@@ -41,7 +42,7 @@ SupervisedUserPasswordServiceFactory::
KeyedService* SupervisedUserPasswordServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile= static_cast<Profile*>(context);
- User* user = UserManager::Get()->GetUserByProfile(profile);
+ User* user = ProfileHelper::Get()->GetUserByProfile(profile);
if (user->GetType() != User::USER_TYPE_LOCALLY_MANAGED)
return NULL;
SupervisedUserPasswordService* result = new SupervisedUserPasswordService();
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
index 171bca5..ad073e6 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
@@ -51,7 +52,7 @@ content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex(
chromeos::User* user =
chromeos::UserManager::Get()->GetLRULoggedInUsers()[index];
DCHECK(user);
- return chromeos::UserManager::Get()->GetProfileByUser(user);
+ return chromeos::ProfileHelper::Get()->GetProfileByUser(user);
}
content::BrowserContext*
@@ -61,7 +62,7 @@ SessionStateDelegateChromeos::GetBrowserContextForWindow(
chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window);
const chromeos::User* user = chromeos::UserManager::Get()->FindUser(user_id);
DCHECK(user);
- return chromeos::UserManager::Get()->GetProfileByUser(user);
+ return chromeos::ProfileHelper::Get()->GetProfileByUser(user);
}
int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const {
@@ -98,7 +99,7 @@ bool SessionStateDelegateChromeos::ShouldLockScreenBeforeSuspending() const {
for (chromeos::UserList::const_iterator it = logged_in_users.begin();
it != logged_in_users.end(); ++it) {
chromeos::User* user = (*it);
- Profile* profile = chromeos::UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(user);
if (profile->GetPrefs()->GetBoolean(prefs::kEnableAutoScreenLock))
return true;
}
@@ -141,7 +142,7 @@ const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo(
const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo(
content::BrowserContext* context) const {
DCHECK(context);
- return chromeos::UserManager::Get()->GetUserByProfile(
+ return chromeos::ProfileHelper::Get()->GetUserByProfile(
Profile::FromBrowserContext(context));
}
diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
index 1163322..c0f0219 100644
--- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
@@ -66,6 +66,7 @@
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/set_time_dialog.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/sim_dialog_delegate.h"
@@ -915,7 +916,7 @@ SystemTrayDelegateChromeOS::GetUserAccountsDelegate(
const std::string& user_id) {
if (!accounts_delegates_.contains(user_id)) {
const User* user = UserManager::Get()->FindUser(user_id);
- Profile* user_profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user);
CHECK(user_profile);
accounts_delegates_.set(
user_id,
diff --git a/chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc b/chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc
index e15e854..90b9f42 100644
--- a/chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/user_accounts_delegate_chromeos.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/ui/inline_login_dialog.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
@@ -53,7 +54,7 @@ UserAccountsDelegateChromeOS::GetSecondaryAccountIds() {
std::string UserAccountsDelegateChromeOS::GetAccountDisplayName(
const std::string& account_id) {
- User* user = UserManager::Get()->GetUserByProfile(user_profile_);
+ User* user = ProfileHelper::Get()->GetUserByProfile(user_profile_);
if (gaia::AreEmailsSame(user->email(), account_id) &&
!user->display_email().empty())
return user->display_email();
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc
index 647208c..25344d7 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -330,9 +330,7 @@ bool StartupBrowserCreator::LaunchBrowser(
profile_launch_observer.Get().AddLaunched(profile);
#if defined(OS_CHROMEOS)
- g_browser_process->platform_part()->profile_helper()->ProfileStartup(
- profile,
- process_startup);
+ chromeos::ProfileHelper::Get()->ProfileStartup(profile, process_startup);
#endif
return true;
}
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 cae1a74..a811fff 100644
--- a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
@@ -387,8 +387,7 @@ void GaiaScreenHandler::OnDnsCleared() {
void GaiaScreenHandler::StartClearingCookies(
const base::Closure& on_clear_callback) {
cookies_cleared_ = false;
- ProfileHelper* profile_helper =
- g_browser_process->platform_part()->profile_helper();
+ ProfileHelper* profile_helper = ProfileHelper::Get();
LOG_ASSERT(Profile::FromWebUI(web_ui()) ==
profile_helper->GetSigninProfile());
profile_helper->ClearSigninProfile(
@@ -416,9 +415,9 @@ void GaiaScreenHandler::ShowSigninScreenForCreds(const std::string& username,
// Submit login form for test if gaia is ready. If gaia is loading, login
// will be attempted in HandleLoginWebuiReady after gaia is ready. Otherwise,
// reload gaia then follow the loading case.
- if (FrameState() == GaiaScreenHandler::FRAME_STATE_LOADED)
+ if (FrameState() == GaiaScreenHandler::FRAME_STATE_LOADED) {
SubmitLoginFormForTest();
- else if (FrameState() != GaiaScreenHandler::FRAME_STATE_LOADING) {
+ } else if (FrameState() != GaiaScreenHandler::FRAME_STATE_LOADING) {
DCHECK(signin_screen_handler_);
signin_screen_handler_->OnShowAddUser();
}
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 99a8494..7ef1bb2 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -884,7 +884,7 @@ void SigninScreenHandler::ShowUserPodCustomIcon(
if (!user)
return;
PrefService* profile_prefs =
- user_manager->GetProfileByUser(user)->GetPrefs();
+ ProfileHelper::Get()->GetProfileByUser(user)->GetPrefs();
if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) {
CallJS("login.AccountPickerScreen.showEasyUnlockBubble");
profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false);
@@ -996,7 +996,7 @@ void SigninScreenHandler::HandleAttemptUnlock(const std::string& username) {
if (!unlock_user)
return;
- Profile* profile = UserManager::Get()->GetProfileByUser(unlock_user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(unlock_user);
extensions::ScreenlockPrivateEventRouter* router =
extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(
profile);
diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
index 45ed8af..6f2d627 100644
--- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
@@ -80,8 +80,8 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/users/user.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/net/onc_utils.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/system/syslogs_provider.h"
#include "chrome/browser/net/nss_context.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -1477,7 +1477,7 @@ void NetInternalsMessageHandler::ImportONCFileToNSSDB(
const std::string& passcode,
net::NSSCertDatabase* nssdb) {
std::string error;
- chromeos::User* user = chromeos::UserManager::Get()->GetUserByProfile(
+ chromeos::User* user = chromeos::ProfileHelper::Get()->GetUserByProfile(
Profile::FromWebUI(web_ui()));
if (user) {
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index be88b99..4b5913d 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -108,6 +108,7 @@
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/reset/metrics.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/system/timezone_util.h"
@@ -502,7 +503,7 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
std::string username = profile->GetProfileName();
if (username.empty()) {
chromeos::User* user =
- chromeos::UserManager::Get()->GetUserByProfile(profile);
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (user && (user->GetType() != chromeos::User::USER_TYPE_GUEST))
username = user->email();
diff --git a/chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc b/chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc
index b34d3f0..2877e63 100644
--- a/chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc
+++ b/chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/ui/browser.h"
@@ -61,7 +62,7 @@ class AccountsOptionsTest : public LoginManagerTest {
protected:
void CheckAccountsUI(const User* user, bool is_owner) {
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
user->email());
diff --git a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc
index 65b0f81..4ec5354 100644
--- a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/login/users/avatar/user_image.h"
#include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
@@ -464,7 +465,7 @@ void ChangePictureOptionsHandler::OnDecodeImageFailed(
User* ChangePictureOptionsHandler::GetUser() const {
Profile* profile = Profile::FromWebUI(web_ui());
- User* user = UserManager::Get()->GetUserByProfile(profile);
+ User* user = ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
return UserManager::Get()->GetActiveUser();
return user;
diff --git a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
index 66307a5..da65089 100644
--- a/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
@@ -285,7 +285,7 @@ void CoreChromeOSOptionsHandler::GetLocalizedValues(
// Check at load time whether this is a secondary user in a multi-profile
// session.
- User* user = user_manager->GetUserByProfile(profile);
+ User* user = ProfileHelper::Get()->GetUserByProfile(profile);
if (user && user->email() != user_manager->GetPrimaryUser()->email()) {
const std::string& primary_email = user_manager->GetPrimaryUser()->email();
diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
index e586411..3c31fcc 100644
--- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/chromeos/customization_document.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
@@ -449,7 +450,7 @@ void CrosLanguageOptionsHandler::SetApplicationLocale(
UserManager* user_manager = UserManager::Get();
// Only the primary user can change the locale.
- User* user = user_manager->GetUserByProfile(profile);
+ User* user = ProfileHelper::Get()->GetUserByProfile(profile);
if (user && user->email() == user_manager->GetPrimaryUser()->email()) {
profile->ChangeAppLocale(language_code,
Profile::APP_LOCALE_CHANGED_VIA_SETTINGS);
diff --git a/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc b/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc
index 5b61824b..4cd5c94 100644
--- a/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc
+++ b/chrome/browser/ui/webui/options/chromeos/shared_options_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
#include "chrome/browser/ui/browser.h"
@@ -128,7 +129,7 @@ class SharedOptionsTest : public LoginManagerTest {
// Creates a browser and navigates to the Settings page.
Browser* CreateBrowserForUser(const User* user) {
- Profile* profile = UserManager::Get()->GetProfileByUser(user);
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
user->email());
@@ -305,8 +306,10 @@ IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferencePrimary) {
const User* user1 = manager->FindUser(kTestOwner);
const User* user2 = manager->FindUser(kTestNonOwner);
- PrefService* prefs1 = manager->GetProfileByUser(user1)->GetPrefs();
- PrefService* prefs2 = manager->GetProfileByUser(user2)->GetPrefs();
+ PrefService* prefs1 =
+ ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs();
+ PrefService* prefs2 =
+ ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs();
// Set both users' preference to false, then change the secondary user's to
// true. We'll do the opposite in the next test. Doesn't provide 100% coverage
@@ -374,8 +377,10 @@ IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferenceSecondary) {
const User* user1 = manager->FindUser(kTestOwner);
const User* user2 = manager->FindUser(kTestNonOwner);
- PrefService* prefs1 = manager->GetProfileByUser(user1)->GetPrefs();
- PrefService* prefs2 = manager->GetProfileByUser(user2)->GetPrefs();
+ PrefService* prefs1 =
+ ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs();
+ PrefService* prefs2 =
+ ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs();
// Set both users' preference to true, then change the secondary user's to
// false.