diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 44185dca385708..4ee0034ab21769 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5992,12 +5992,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Disables SAML sign-in support for Chrome OS sign-in. - - Enable multiprofiles mode. - - - This is an experimental mode to run several profiles/users simultaneously during a browsing session. Features may break or change significantly. - Disable hardware-accelerated video decode. diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 66303f5cad183f..e367947ec1f0c9 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1029,13 +1029,6 @@ const Experiment kExperiments[] = { kOsCrOS, SINGLE_VALUE_TYPE(chromeos::switches::kDisableSamlSignin), }, - { - "enable-multi-profiles", - IDS_FLAGS_ENABLE_MULTI_PROFILES_NAME, - IDS_FLAGS_ENABLE_MULTI_PROFILES_DESCRIPTION, - kOsCrOS, - SINGLE_VALUE_TYPE(switches::kMultiProfiles), - }, { "disable-display-color-calibration", IDS_FLAGS_DISABLE_DISPLAY_COLOR_CALIBRATION_NAME, diff --git a/chrome/browser/chrome_browser_field_trials_desktop.cc b/chrome/browser/chrome_browser_field_trials_desktop.cc index 29871dec70d7b2..eeae4d27d9c9b3 100644 --- a/chrome/browser/chrome_browser_field_trials_desktop.cc +++ b/chrome/browser/chrome_browser_field_trials_desktop.cc @@ -28,10 +28,6 @@ #include "net/spdy/spdy_session.h" #include "ui/base/layout.h" -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/login/user_manager.h" -#endif - namespace chrome { namespace { @@ -115,16 +111,6 @@ void SetupPreReadFieldTrial() { trial->group(); } -#if defined(OS_CHROMEOS) -void SetupChromeOSMultiProfilesAllowedTrial() { - const char kTrialName[] = "ChromeOSMultiProfilesAllowed"; - if (chromeos::UserManager::IsMultipleProfilesAllowed()) - base::FieldTrialList::CreateFieldTrial(kTrialName, "allowed")->group(); - else - base::FieldTrialList::CreateFieldTrial(kTrialName, "not_allowed")->group(); -} -#endif // defined(OS_CHROMEOS) - } // namespace void SetupDesktopFieldTrials(const CommandLine& parsed_command_line, @@ -137,9 +123,6 @@ void SetupDesktopFieldTrials(const CommandLine& parsed_command_line, DisableShowProfileSwitcherTrialIfNecessary(); SetupShowAppLauncherPromoFieldTrial(local_state); SetupPreReadFieldTrial(); -#if defined(OS_CHROMEOS) - SetupChromeOSMultiProfilesAllowedTrial(); -#endif } } // namespace chrome 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 ce1e3aff16ab4e..61657b5c1cda03 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc @@ -394,12 +394,6 @@ bool FileBrowserPrivateVisitDesktopFunction::RunSync() { const std::vector >& profiles = GetLoggedInProfileInfoList(GetAssociatedWebContents()); - // Check the multi-profile support. - if (!profiles::IsMultipleProfilesEnabled()) { - SetError("Multi-profile support is not enabled."); - return false; - } - chrome::MultiUserWindowManager* const window_manager = chrome::MultiUserWindowManager::GetInstance(); DCHECK(window_manager); diff --git a/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc b/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc index e72e76f4f336b2..097a8079955357 100644 --- a/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc +++ b/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc @@ -6,18 +6,22 @@ #include "base/file_util.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" +#include "base/path_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chromeos/drive/drive_integration_service.h" #include "chrome/browser/chromeos/drive/test_util.h" #include "chrome/browser/chromeos/file_manager/drive_test_util.h" #include "chrome/browser/chromeos/file_manager/volume_manager.h" +#include "chrome/browser/chromeos/login/user_manager.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/drive/fake_drive_service.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_paths.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_utils.h" @@ -65,6 +69,11 @@ const char kRestrictedMountPointName[] = "restricted"; // Default file content for the test files. const char kTestFileContent[] = "This is some test content."; +// User account email and directory hash for secondary account for multi-profile +// sensitive test cases. +const char kSecondProfileAccount[] = "profile2@test.com"; +const char kSecondProfileHash[] = "fileBrowserApiTestProfile2"; + // Sets up the initial file system state for native local and restricted native // local file systems. The hierarchy is the same as for the drive file system. // The directory is created at unique_temp_dir/|mount_point_name| path. @@ -501,11 +510,16 @@ class MultiProfileDriveFileSystemExtensionApiTest : MultiProfileDriveFileSystemExtensionApiTest() : second_profile(NULL) {} virtual void SetUpOnMainThread() OVERRIDE { + base::FilePath user_data_directory; + PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); + chromeos::UserManager::Get()->UserLoggedIn(kSecondProfileAccount, + kSecondProfileHash, + false); // Set up the secondary profile. - base::FilePath profile_dir; - base::CreateNewTempDirectory(base::FilePath::StringType(), &profile_dir); - profile_dir = profile_dir.AppendASCII( - std::string(chrome::kProfileDirPrefix) + "fileBrowserApiTestProfile2"); + base::FilePath profile_dir = + user_data_directory.Append( + chromeos::ProfileHelper::GetUserProfileDir( + kSecondProfileHash).BaseName()); second_profile = g_browser_process->profile_manager()->GetProfile(profile_dir); diff --git a/chrome/browser/chromeos/file_manager/path_util.cc b/chrome/browser/chromeos/file_manager/path_util.cc index 27e02fc2c2dd0b..59256ba4d7a6a1 100644 --- a/chrome/browser/chromeos/file_manager/path_util.cc +++ b/chrome/browser/chromeos/file_manager/path_util.cc @@ -33,16 +33,13 @@ const base::FilePath::CharType kBuggyDriveFolderPath[] = } // namespace base::FilePath GetDownloadsFolderForProfile(Profile* profile) { - if (!base::SysInfo::IsRunningOnChromeOS() && - !chromeos::UserManager::IsMultipleProfilesAllowed()) { - // On the developer run on Linux desktop build, if multiple profiles are - // not enabled, use $HOME/Downloads for ease for accessing local files for - // debugging. + if (!base::SysInfo::IsRunningOnChromeOS()) { + // On the developer run on Linux desktop build, use $HOME/Downloads for ease + // for accessing local files for debugging. base::FilePath path; CHECK(PathService::Get(base::DIR_HOME, &path)); return path.AppendASCII(kDownloadsFolderName); } - return profile->GetPath().AppendASCII(kDownloadsFolderName); } diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc index 1d3ea1e5287cb3..9edaa4f7c53512 100644 --- a/chrome/browser/chromeos/file_manager/volume_manager.cc +++ b/chrome/browser/chromeos/file_manager/volume_manager.cc @@ -15,6 +15,7 @@ #include "base/prefs/pref_service.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/sys_info.h" #include "chrome/browser/chromeos/drive/drive_integration_service.h" #include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_system_interface.h" @@ -289,15 +290,21 @@ void VolumeManager::Initialize() { new_path); } - // Register 'Downloads' folder for the profile to the file system. - const base::FilePath downloads = - file_manager::util::GetDownloadsFolderForProfile(profile_); - const bool success = RegisterDownloadsMountPoint(profile_, downloads); - DCHECK(success); - - DoMountEvent(chromeos::MOUNT_ERROR_NONE, - CreateDownloadsVolumeInfo(downloads), - kNotRemounting); + static bool added_downloads = false; + if (base::SysInfo::IsRunningOnChromeOS() || !added_downloads) { + // Register 'Downloads' folder for the profile to the file system. + // On non-ChromeOS system (test+development), we should do this only for + // the first registered profile. + const base::FilePath downloads = + file_manager::util::GetDownloadsFolderForProfile(profile_); + const bool success = RegisterDownloadsMountPoint(profile_, downloads); + added_downloads = success; + DCHECK(success); + + DoMountEvent(chromeos::MOUNT_ERROR_NONE, + CreateDownloadsVolumeInfo(downloads), + kNotRemounting); + } // Subscribe to DriveIntegrationService. if (drive_integration_service_) { diff --git a/chrome/browser/chromeos/login/chrome_restart_request.cc b/chrome/browser/chromeos/login/chrome_restart_request.cc index a477c17c0f2b18..daf7a44fdfdfda 100644 --- a/chrome/browser/chromeos/login/chrome_restart_request.cc +++ b/chrome/browser/chromeos/login/chrome_restart_request.cc @@ -129,7 +129,6 @@ std::string DeriveCommandLine(const GURL& start_url, ::switches::kGpuSandboxAllowSysVShm, ::switches::kGpuSandboxFailuresFatal, ::switches::kGpuSandboxStartAfterInitialization, - ::switches::kMultiProfiles, ::switches::kNoSandbox, ::switches::kNumRasterThreads, ::switches::kPpapiFlashArgs, diff --git a/chrome/browser/chromeos/login/kiosk_browsertest.cc b/chrome/browser/chromeos/login/kiosk_browsertest.cc index 44869e08ab9302..aeec99901e7c57 100644 --- a/chrome/browser/chromeos/login/kiosk_browsertest.cc +++ b/chrome/browser/chromeos/login/kiosk_browsertest.cc @@ -34,6 +34,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/profiles/profile_impl.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" @@ -431,19 +432,12 @@ class KioskTest : public OobeBaseTest { // run. Note this must be called before app profile is loaded. void SetupAppProfile(const std::string& relative_app_profile_dir) { base::FilePath app_profile_dir; - if (CommandLine::ForCurrentProcess()->HasSwitch( - ::switches::kMultiProfiles)) { - KioskAppManager::App app_data; - CHECK(KioskAppManager::Get()->GetApp(test_app_id(), &app_data)); - std::string app_user_id_hash = - CryptohomeClient::GetStubSanitizedUsername(app_data.user_id); - app_profile_dir = - ProfileHelper::GetProfilePathByUserIdHash(app_user_id_hash); - } else { - ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &app_profile_dir)); - app_profile_dir = app_profile_dir.Append( - ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch()); - } + KioskAppManager::App app_data; + CHECK(KioskAppManager::Get()->GetApp(test_app_id(), &app_data)); + std::string app_user_id_hash = + CryptohomeClient::GetStubSanitizedUsername(app_data.user_id); + app_profile_dir = + ProfileHelper::GetProfilePathByUserIdHash(app_user_id_hash); ASSERT_TRUE(base::CreateDirectory(app_profile_dir)); base::FilePath test_data_dir; diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc index 9b996324b28c83..68cf98a80da41d 100644 --- a/chrome/browser/chromeos/login/login_browsertest.cc +++ b/chrome/browser/chromeos/login/login_browsertest.cc @@ -10,6 +10,7 @@ #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -34,7 +35,8 @@ class LoginUserTest : public InProcessBrowserTest { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { command_line->AppendSwitchASCII( chromeos::switches::kLoginUser, "TestUser@gmail.com"); - command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, + "hash"); } }; @@ -43,7 +45,8 @@ class LoginGuestTest : public InProcessBrowserTest { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { command_line->AppendSwitch(chromeos::switches::kGuestSession); command_line->AppendSwitch(::switches::kIncognito); - command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, + "hash"); command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, chromeos::UserManager::kGuestUserName); } @@ -64,7 +67,8 @@ class LoginSigninTest : public InProcessBrowserTest { } virtual void SetUpOnMainThread() OVERRIDE { - ASSERT_TRUE(tracing::BeginTracingWithWatch("ui", "ui", "ShowLoginWebUI", 1)); + ASSERT_TRUE(tracing::BeginTracingWithWatch( + "ui", "ui", "ShowLoginWebUI", 1)); } }; @@ -73,7 +77,9 @@ class LoginSigninTest : public InProcessBrowserTest { // This profile should NOT be an OTR profile. IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) { Profile* profile = browser()->profile(); - EXPECT_EQ("user", profile->GetPath().BaseName().value()); + std::string profile_base_path("hash"); + profile_base_path.insert(0, chrome::kProfileDirPrefix); + EXPECT_EQ(profile_base_path, profile->GetPath().BaseName().value()); EXPECT_FALSE(profile->IsOffTheRecord()); } diff --git a/chrome/browser/chromeos/login/login_manager_test.cc b/chrome/browser/chromeos/login/login_manager_test.cc index 4d8738d6bf01e3..2f103a44018703 100644 --- a/chrome/browser/chromeos/login/login_manager_test.cc +++ b/chrome/browser/chromeos/login/login_manager_test.cc @@ -66,14 +66,14 @@ void LoginManagerTest::SetExpectedCredentials(const std::string& username, bool LoginManagerTest::TryToLogin(const std::string& username, const std::string& password) { - if (!AddUserTosession(username, password)) + if (!AddUserToSession(username, password)) return false; if (const User* active_user = UserManager::Get()->GetActiveUser()) return active_user->email() == username; return false; } -bool LoginManagerTest::AddUserTosession(const std::string& username, +bool LoginManagerTest::AddUserToSession(const std::string& username, const std::string& password) { ExistingUserController* controller = ExistingUserController::current_controller(); @@ -101,7 +101,7 @@ void LoginManagerTest::LoginUser(const std::string& username) { void LoginManagerTest::AddUser(const std::string& username) { SetExpectedCredentials(username, "password"); - EXPECT_TRUE(AddUserTosession(username, "password")); + EXPECT_TRUE(AddUserToSession(username, "password")); } void LoginManagerTest::JSExpect(const std::string& expression) { diff --git a/chrome/browser/chromeos/login/login_manager_test.h b/chrome/browser/chromeos/login/login_manager_test.h index b05db4860117f5..50d23c118ec8db 100644 --- a/chrome/browser/chromeos/login/login_manager_test.h +++ b/chrome/browser/chromeos/login/login_manager_test.h @@ -47,7 +47,7 @@ class LoginManagerTest : public InProcessBrowserTest { // Tries to add user to session with |username| and |password|. Returns false // if attempt has failed. this function does the same as TryToLogin but // doesn't check that new user become active user. - bool AddUserTosession(const std::string& username, + bool AddUserToSession(const std::string& username, const std::string& password); // Login user with |username|. User should be registered using RegisterUser(). diff --git a/chrome/browser/chromeos/login/login_utils_browsertest.cc b/chrome/browser/chromeos/login/login_utils_browsertest.cc index 441e39c7e7a3da..3642cff033247e 100644 --- a/chrome/browser/chromeos/login/login_utils_browsertest.cc +++ b/chrome/browser/chromeos/login/login_utils_browsertest.cc @@ -34,10 +34,10 @@ #include "chrome/browser/net/predictor.h" #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/rlz/rlz.h" #include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_unit_test_suite.h" #include "chrome/test/base/scoped_testing_local_state.h" @@ -207,9 +207,6 @@ class LoginUtilsTest : public testing::Test, command_line->AppendSwitchASCII( policy::switches::kDeviceManagementUrl, kDMServer); - if (!command_line->HasSwitch(::switches::kMultiProfiles)) - command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); - // DBusThreadManager should be initialized before io_thread_state_, as // DBusThreadManager is used from chromeos::ProxyConfigServiceImpl, // which is part of io_thread_state_. @@ -526,28 +523,11 @@ class LoginUtilsTest : public testing::Test, DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); }; -class LoginUtilsParamTest - : public LoginUtilsTest, - public testing::WithParamInterface { - public: - LoginUtilsParamTest() {} - - virtual void SetUp() OVERRIDE { - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (GetParam()) - command_line->AppendSwitch(::switches::kMultiProfiles); - LoginUtilsTest::SetUp(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(LoginUtilsParamTest); -}; - class LoginUtilsBlockingLoginTest : public LoginUtilsTest, public testing::WithParamInterface {}; -TEST_P(LoginUtilsParamTest, NormalLoginDoesntBlock) { +TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) { UserManager* user_manager = UserManager::Get(); EXPECT_FALSE(user_manager->IsUserLoggedIn()); EXPECT_FALSE(connector_->IsEnterpriseManaged()); @@ -563,7 +543,7 @@ TEST_P(LoginUtilsParamTest, NormalLoginDoesntBlock) { EXPECT_EQ(kUsername, user_manager->GetLoggedInUser()->email()); } -TEST_P(LoginUtilsParamTest, EnterpriseLoginDoesntBlockForNormalUser) { +TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) { UserManager* user_manager = UserManager::Get(); EXPECT_FALSE(user_manager->IsUserLoggedIn()); EXPECT_FALSE(connector_->IsEnterpriseManaged()); @@ -588,7 +568,7 @@ TEST_P(LoginUtilsParamTest, EnterpriseLoginDoesntBlockForNormalUser) { } #if defined(ENABLE_RLZ) -TEST_P(LoginUtilsParamTest, RlzInitialized) { +TEST_F(LoginUtilsTest, RlzInitialized) { // No RLZ brand code set initially. EXPECT_FALSE(local_state_.Get()->HasPrefPath(prefs::kRLZBrand)); @@ -723,10 +703,6 @@ INSTANTIATE_TEST_CASE_P( LoginUtilsBlockingLoginTest, testing::Values(0, 1, 2, 3, 4, 5)); -INSTANTIATE_TEST_CASE_P(LoginUtilsParamTestInstantiation, - LoginUtilsParamTest, - testing::Bool()); - } // namespace } // namespace chromeos diff --git a/chrome/browser/chromeos/login/user.h b/chrome/browser/chromeos/login/user.h index ac6457db4656a3..650daf93cffdbf 100644 --- a/chrome/browser/chromeos/login/user.h +++ b/chrome/browser/chromeos/login/user.h @@ -258,7 +258,9 @@ class User : public ash::UserInfo { display_name_ = display_name; } - void set_given_name(const base::string16& given_name) { given_name_ = given_name; } + void set_given_name(const base::string16& given_name) { + given_name_ = given_name; + } void set_display_email(const std::string& display_email) { display_email_ = display_email; diff --git a/chrome/browser/chromeos/login/user_manager.cc b/chrome/browser/chromeos/login/user_manager.cc index 41685d57062f20..c446255b02f431 100644 --- a/chrome/browser/chromeos/login/user_manager.cc +++ b/chrome/browser/chromeos/login/user_manager.cc @@ -58,9 +58,10 @@ PendingUserSessionsRestoreFinished() { UserManager::UserSessionStateObserver::~UserSessionStateObserver() { } -UserManager::UserAccountData::UserAccountData(const base::string16& display_name, - const base::string16& given_name, - const std::string& locale) +UserManager::UserAccountData::UserAccountData( + const base::string16& display_name, + const base::string16& given_name, + const std::string& locale) : display_name_(display_name), given_name_(given_name), locale_(locale) { @@ -91,18 +92,15 @@ UserManager* UserManager::Get() { return g_user_manager; } -// static -bool UserManager::IsMultipleProfilesAllowed() { - return CommandLine::ForCurrentProcess()->HasSwitch( - ::switches::kMultiProfiles); -} - UserManager::~UserManager() { } // static UserManager* UserManager::SetForTesting(UserManager* user_manager) { UserManager* previous_user_manager = g_user_manager; + if (previous_user_manager) + previous_user_manager->Shutdown(); + g_user_manager = user_manager; return previous_user_manager; } diff --git a/chrome/browser/chromeos/login/user_manager.h b/chrome/browser/chromeos/login/user_manager.h index cb76d41709a6bc..ffba8630989c2d 100644 --- a/chrome/browser/chromeos/login/user_manager.h +++ b/chrome/browser/chromeos/login/user_manager.h @@ -122,9 +122,6 @@ class UserManager { // Registers user manager preferences. static void RegisterPrefs(PrefRegistrySimple* registry); - // Returns true if multiple profiles support is allowed. - static bool IsMultipleProfilesAllowed(); - virtual ~UserManager(); virtual MultiProfileUserController* GetMultiProfileUserController() = 0; diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc index f6d486216d9c54..4a56400838ee38 100644 --- a/chrome/browser/chromeos/login/user_manager_impl.cc +++ b/chrome/browser/chromeos/login/user_manager_impl.cc @@ -52,6 +52,7 @@ #include "chrome/browser/net/nss_context.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/chrome_constants.h" @@ -288,6 +289,7 @@ void UserManagerImpl::Shutdown() { multi_profile_user_controller_.reset(); avatar_policy_observer_.reset(); wallpaper_policy_observer_.reset(); + registrar_.RemoveAll(); } MultiProfileUserController* UserManagerImpl::GetMultiProfileUserController() { @@ -314,9 +316,6 @@ const UserList& UserManagerImpl::GetUsers() const { } UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const { - if (!UserManager::IsMultipleProfilesAllowed()) - return UserList(); - // Supervised users are not allowed to use multi profile. if (logged_in_users_.size() == 1 && GetPrimaryUser()->GetType() != User::USER_TYPE_REGULAR) @@ -415,9 +414,6 @@ void UserManagerImpl::UserLoggedIn(const std::string& user_id, bool browser_restart) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kMultiProfiles)) - DCHECK(!IsUserLoggedIn()); - User* user = FindUserInListAndModify(user_id); if (active_user_ && user) { user->set_is_logged_in(true); @@ -493,9 +489,6 @@ void UserManagerImpl::UserLoggedIn(const std::string& user_id, } void UserManagerImpl::SwitchActiveUser(const std::string& user_id) { - if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kMultiProfiles)) - return; - User* user = FindUserAndModify(user_id); if (!user) { NOTREACHED() << "Switching to a non-existing user"; @@ -684,29 +677,37 @@ User* UserManagerImpl::GetUserByProfile(Profile* profile) const { if (ProfileHelper::IsSigninProfile(profile)) return NULL; - if (IsMultipleProfilesAllowed()) { - 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; + // 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_; } - 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 (IsMultipleProfilesAllowed() && user->is_profile_created()) + if (user->is_profile_created()) profile = ProfileHelper::GetProfileByUserIdHash(user->username_hash()); else profile = ProfileManager::GetActiveUserProfile(); @@ -1867,19 +1868,9 @@ base::FilePath UserManagerImpl::GetUserProfileDir( // 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 CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(::switches::kMultiProfiles)) { - const User* user = FindUser(user_id); - if (user && !user->username_hash().empty()) - profile_dir = ProfileHelper::GetUserProfileDir(user->username_hash()); - } else if (command_line.HasSwitch(chromeos::switches::kLoginProfile)) { - profile_dir = ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch(); - } else { - // We should never be logged in with no profile dir unless - // multi-profiles are enabled. - NOTREACHED(); - profile_dir = base::FilePath(); - } + 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); diff --git a/chrome/browser/chromeos/login/user_manager_unittest.cc b/chrome/browser/chromeos/login/user_manager_unittest.cc index 7654601139e1bf..f9d61b755a6150 100644 --- a/chrome/browser/chromeos/login/user_manager_unittest.cc +++ b/chrome/browser/chromeos/login/user_manager_unittest.cc @@ -5,6 +5,8 @@ #include #include +#include "base/command_line.h" +#include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/prefs/pref_service.h" #include "base/run_loop.h" @@ -16,18 +18,46 @@ #include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/device_settings_service.h" #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" +#include "chrome/test/base/testing_profile.h" +#include "chromeos/chromeos_switches.h" +#include "chromeos/dbus/dbus_thread_manager.h" +#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/settings/cros_settings_names.h" #include "chromeos/settings/cros_settings_provider.h" +#include "content/public/common/content_switches.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" namespace chromeos { +class UnittestProfileManager : public ::ProfileManagerWithoutInit { + public: + explicit UnittestProfileManager(const base::FilePath& user_data_dir) + : ::ProfileManagerWithoutInit(user_data_dir) {} + + protected: + virtual Profile* CreateProfileHelper( + const base::FilePath& file_path) OVERRIDE { + if (!base::PathExists(file_path)) { + if (!base::CreateDirectory(file_path)) + return NULL; + } + return new TestingProfile(file_path, NULL); + } +}; + + class UserManagerTest : public testing::Test { protected: virtual void SetUp() OVERRIDE { + CommandLine& command_line = *CommandLine::ForCurrentProcess(); + command_line.AppendSwitch(::switches::kTestType); + command_line.AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); + cros_settings_ = CrosSettings::Get(); // Replace the real DeviceSettingsProvider with a stub. @@ -45,6 +75,14 @@ class UserManagerTest : public testing::Test { local_state_.reset( new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal())); + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + TestingBrowserProcess::GetGlobal()->SetProfileManager( + new UnittestProfileManager(temp_dir_.path())); + + chromeos::FakeDBusThreadManager* dbus_manager = + new chromeos::FakeDBusThreadManager(); + chromeos::DBusThreadManager::InitializeForTesting(dbus_manager); + ResetUserManager(); } @@ -59,8 +97,10 @@ class UserManagerTest : public testing::Test { // Shut down the DeviceSettingsService. DeviceSettingsService::Get()->UnsetSessionManager(); + TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); base::RunLoop().RunUntilIdle(); + chromeos::DBusThreadManager::Shutdown(); } UserManagerImpl* GetUserManagerImpl() const { @@ -120,6 +160,7 @@ class UserManagerTest : public testing::Test { ScopedTestCrosSettings test_cros_settings_; scoped_ptr user_manager_enabler_; + base::ScopedTempDir temp_dir_; }; TEST_F(UserManagerTest, RetrieveTrustedDevicePolicies) { diff --git a/chrome/browser/chromeos/login/wallpaper_manager.cc b/chrome/browser/chromeos/login/wallpaper_manager.cc index fd8c4b20c69eff..22f6b144bbba7b 100644 --- a/chrome/browser/chromeos/login/wallpaper_manager.cc +++ b/chrome/browser/chromeos/login/wallpaper_manager.cc @@ -548,28 +548,24 @@ void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { void WallpaperManager::ClearDisposableWallpaperCache() { // Cancel callback for previous cache requests. weak_factory_.InvalidateWeakPtrs(); - if (!UserManager::IsMultipleProfilesAllowed()) { - wallpaper_cache_.clear(); - } else { - // Keep the wallpaper of logged in users in cache at multi-profile mode. - std::set logged_in_users_names; - const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); - for (UserList::const_iterator it = logged_users.begin(); - it != logged_users.end(); - ++it) { - logged_in_users_names.insert((*it)->email()); - } + // Keep the wallpaper of logged in users in cache at multi-profile mode. + std::set logged_in_users_names; + const UserList& logged_users = UserManager::Get()->GetLoggedInUsers(); + for (UserList::const_iterator it = logged_users.begin(); + it != logged_users.end(); + ++it) { + logged_in_users_names.insert((*it)->email()); + } - CustomWallpaperMap logged_in_users_cache; - for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin(); - it != wallpaper_cache_.end(); ++it) { - if (logged_in_users_names.find(it->first) != - logged_in_users_names.end()) { - logged_in_users_cache.insert(*it); - } + CustomWallpaperMap logged_in_users_cache; + for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin(); + it != wallpaper_cache_.end(); ++it) { + if (logged_in_users_names.find(it->first) != + logged_in_users_names.end()) { + logged_in_users_cache.insert(*it); } - wallpaper_cache_ = logged_in_users_cache; } + wallpaper_cache_ = logged_in_users_cache; } base::FilePath WallpaperManager::GetCustomWallpaperPath( @@ -920,8 +916,7 @@ void WallpaperManager::SetCustomWallpaper(const std::string& user_id, GetPendingWallpaper(user_id, false)->ResetSetWallpaperImage(image, info); } - if (UserManager::IsMultipleProfilesAllowed()) - wallpaper_cache_[user_id] = image; + wallpaper_cache_[user_id] = image; } void WallpaperManager::SetDefaultWallpaperNow(const std::string& user_id) { @@ -1101,8 +1096,7 @@ void WallpaperManager::SetWallpaperFromImageSkia(const std::string& user_id, return; WallpaperInfo info; info.layout = layout; - if (UserManager::IsMultipleProfilesAllowed()) - wallpaper_cache_[user_id] = image; + wallpaper_cache_[user_id] = image; if (update_wallpaper) { GetPendingWallpaper(last_selected_user_, false /* Not delayed */) @@ -1495,11 +1489,7 @@ void WallpaperManager::OnWallpaperDecoded( return; } - // Only cache the user wallpaper at login screen and for multi profile users. - if (!UserManager::Get()->IsUserLoggedIn() || - UserManager::IsMultipleProfilesAllowed()) { - wallpaper_cache_[user_id] = user_image.image(); - } + wallpaper_cache_[user_id] = user_image.image(); if (update_wallpaper) { ash::Shell::GetInstance() diff --git a/chrome/browser/chromeos/profiles/profile_helper.cc b/chrome/browser/chromeos/profiles/profile_helper.cc index cda520eef79767..2fb9304cf640d4 100644 --- a/chrome/browser/chromeos/profiles/profile_helper.cc +++ b/chrome/browser/chromeos/profiles/profile_helper.cc @@ -13,6 +13,7 @@ #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chromeos/chromeos_switches.h" @@ -58,6 +59,11 @@ Profile* ProfileHelper::GetProfileByUserIdHash( // static base::FilePath ProfileHelper::GetProfilePathByUserIdHash( const std::string& user_id_hash) { + // Fails for KioskTest.InstallAndLaunchApp test - crbug.com/238985 + // Will probably fail for Guest session / restart after a crash - + // crbug.com/238998 + // TODO(nkostylev): Remove this check once these bugs are fixed. + DCHECK(!user_id_hash.empty()); ProfileManager* profile_manager = g_browser_process->profile_manager(); base::FilePath profile_path = profile_manager->user_data_dir(); diff --git a/chrome/browser/chromeos/profiles/profile_list_chromeos.cc b/chrome/browser/chromeos/profiles/profile_list_chromeos.cc index 5860dda9cb329c..4091b2f72d5b8d 100644 --- a/chrome/browser/chromeos/profiles/profile_list_chromeos.cc +++ b/chrome/browser/chromeos/profiles/profile_list_chromeos.cc @@ -52,7 +52,7 @@ void ProfileListChromeOS::RebuildMenu() { gfx::Image icon = gfx::Image((*it)->GetImage()); if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement)) { + switches::kNewProfileManagement) && !icon.IsEmpty()) { // old avatar menu uses resized-small images icon = profiles::GetAvatarIconForMenu(icon, true); } diff --git a/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc b/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc index 685290e6ed11e1..6275beaca3e865 100644 --- a/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc +++ b/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc @@ -7,12 +7,11 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" -#include "base/command_line.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part_chromeos.h" #include "chrome/browser/chromeos/net/network_portal_detector.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chrome/common/extensions/api/networking_private.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/shill_manager_client.h" @@ -62,13 +61,8 @@ ShillManagerClient::VerificationProperties ConvertVerificationProperties( } std::string GetUserIdHash(Profile* profile) { - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) { - return g_browser_process->platform_part()-> - profile_helper()->GetUserIdHashFromProfile(profile); - } else { - return g_browser_process->platform_part()-> - profile_helper()->active_user_id_hash(); - } + return g_browser_process->platform_part()-> + profile_helper()->GetUserIdHashFromProfile(profile); } } // namespace diff --git a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc b/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc index 3848a58bad4d63..b17dc80baaeba4 100644 --- a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc +++ b/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc @@ -29,6 +29,10 @@ #include "components/sync_driver/sync_prefs.h" #include "content/public/browser/browser_context.h" +#if defined(OS_CHROMEOS) +#include "chromeos/chromeos_switches.h" +#endif + using extensions::PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction; namespace { @@ -107,6 +111,13 @@ class PreferencesPrivateApiTest : public ExtensionApiTest { PreferencesPrivateApiTest() : browser_(NULL), service_(NULL) {} virtual ~PreferencesPrivateApiTest() {} + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif + } + virtual void SetUpOnMainThread() OVERRIDE { ExtensionApiTest::SetUpOnMainThread(); diff --git a/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chrome/browser/extensions/api/sessions/sessions_apitest.cc index 6d0a7f12825543..e8980ae0f615c7 100644 --- a/chrome/browser/extensions/api/sessions/sessions_apitest.cc +++ b/chrome/browser/extensions/api/sessions/sessions_apitest.cc @@ -25,6 +25,10 @@ #include "sync/api/fake_sync_change_processor.h" #include "sync/api/sync_error_factory_mock.h" +#if defined(OS_CHROMEOS) +#include "chromeos/chromeos_switches.h" +#endif + namespace utils = extension_function_test_utils; namespace extensions { @@ -78,6 +82,7 @@ void BuildTabSpecifics(const std::string& tag, int window_id, int tab_id, class ExtensionSessionsTest : public InProcessBrowserTest { public: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; virtual void SetUpOnMainThread() OVERRIDE; protected: void CreateTestProfileSyncService(); @@ -96,6 +101,13 @@ class ExtensionSessionsTest : public InProcessBrowserTest { scoped_refptr extension_; }; +void ExtensionSessionsTest::SetUpCommandLine(CommandLine* command_line) { +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif +} + void ExtensionSessionsTest::SetUpOnMainThread() { CreateTestProfileSyncService(); CreateTestExtension(); diff --git a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc index f2b97ca60d67f0..93e85c3ad1be4b 100644 --- a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc +++ b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc @@ -10,6 +10,7 @@ #include "base/test/scoped_path_override.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chromeos/customization_document.h" +#include "chrome/browser/chromeos/login/fake_user_manager.h" #include "chrome/browser/extensions/extension_service_unittest.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -33,7 +34,11 @@ const char kExternalAppId[] = "kekdneafjmhmndejhmbcadfiiofngffo"; class ExternalProviderImplChromeOSTest : public ExtensionServiceTestBase { public: - ExternalProviderImplChromeOSTest() {} + ExternalProviderImplChromeOSTest() + : fake_user_manager_(new chromeos::FakeUserManager()), + scoped_user_manager_(fake_user_manager_) { + } + virtual ~ExternalProviderImplChromeOSTest() {} void InitServiceWithExternalProviders() { @@ -78,6 +83,8 @@ class ExternalProviderImplChromeOSTest : public ExtensionServiceTestBase { TestingPrefServiceSimple local_state_; scoped_ptr external_externsions_overrides_; chromeos::system::MockStatisticsProvider mock_statistics_provider_; + chromeos::FakeUserManager* fake_user_manager_; + chromeos::ScopedUserManagerEnabler scoped_user_manager_; DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplChromeOSTest); }; diff --git a/chrome/browser/extensions/external_provider_impl_unittest.cc b/chrome/browser/extensions/external_provider_impl_unittest.cc index 27e8c5559baec8..219ef9460af765 100644 --- a/chrome/browser/extensions/external_provider_impl_unittest.cc +++ b/chrome/browser/extensions/external_provider_impl_unittest.cc @@ -28,6 +28,7 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/customization_document.h" +#include "chrome/browser/chromeos/login/fake_user_manager.h" #include "chromeos/system/mock_statistics_provider.h" #include "chromeos/system/statistics_provider.h" #endif @@ -51,6 +52,10 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase { virtual ~ExternalProviderImplTest() {} void InitServiceWithExternalProviders() { +#if defined(OS_CHROMEOS) + chromeos::ScopedUserManagerEnabler scoped_user_manager( + new chromeos::FakeUserManager); +#endif InitializeExtensionServiceWithUpdater(); ProviderCollection providers; diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 29a65ea48f6011..ae45e0d55c910c 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -102,7 +102,6 @@ #endif #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" #endif @@ -546,17 +545,15 @@ void IOThread::InitAsync() { globals_->host_resolver = CreateGlobalHostResolver(net_log_); UpdateDnsClientEnabled(); #if defined(OS_CHROMEOS) - if (chromeos::UserManager::IsMultipleProfilesAllowed()) { - // Creates a CertVerifyProc that doesn't allow any profile-provided certs. - globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( - new chromeos::CertVerifyProcChromeOS())); - } else // NOLINT Fallthrough to normal verifier if multiprofiles not allowed. -#endif - { + // Creates a CertVerifyProc that doesn't allow any profile-provided certs. + globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( + new chromeos::CertVerifyProcChromeOS())); +#else globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( net::CertVerifyProc::CreateDefault())); - } - globals_->transport_security_state.reset(new net::TransportSecurityState()); +#endif + + globals_->transport_security_state.reset(new net::TransportSecurityState()); #if !defined(USE_OPENSSL) // For now, Certificate Transparency is only implemented for platforms // that use NSS. diff --git a/chrome/browser/lifetime/browser_close_manager_browsertest.cc b/chrome/browser/lifetime/browser_close_manager_browsertest.cc index 42c96c4ec9234c..ef424b8f40e235 100644 --- a/chrome/browser/lifetime/browser_close_manager_browsertest.cc +++ b/chrome/browser/lifetime/browser_close_manager_browsertest.cc @@ -43,6 +43,10 @@ #include "content/test/net/url_request_slow_download_job.h" #include "net/test/embedded_test_server/embedded_test_server.h" +#if defined(OS_CHROMEOS) +#include "chromeos/chromeos_switches.h" +#endif + namespace { class AppModalDialogObserver { @@ -248,6 +252,10 @@ class BrowserCloseManagerBrowserTest virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { if (GetParam()) command_line->AppendSwitch(switches::kEnableFastUnload); +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif } void CreateStalledDownload(Browser* browser) { diff --git a/chrome/browser/metrics/metrics_log_chromeos.cc b/chrome/browser/metrics/metrics_log_chromeos.cc index 517447feb25416..45a36ac85867ba 100644 --- a/chrome/browser/metrics/metrics_log_chromeos.cc +++ b/chrome/browser/metrics/metrics_log_chromeos.cc @@ -201,8 +201,7 @@ void MetricsLogChromeOS::UpdateMultiProfileUserCount() { metrics::SystemProfileProto* system_profile = uma_proto_->mutable_system_profile(); - if (chromeos::UserManager::IsInitialized() && - chromeos::UserManager::Get()->IsMultipleProfilesAllowed()) { + if (chromeos::UserManager::IsInitialized()) { size_t user_count = chromeos::UserManager::Get()->GetLoggedInUsers().size(); // We invalidate the user count if it changed while the log was open. diff --git a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc index 2dc6001a54aad3..071991180a134b 100644 --- a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc +++ b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc @@ -290,8 +290,10 @@ class PerformanceMonitorUncleanExitBrowserTest public: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { PerformanceMonitorBrowserTest::SetUpCommandLine(command_line); - if (GetParam()) - command_line->AppendSwitch(::switches::kMultiProfiles); +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif } virtual bool SetUpUserDataDirectory() OVERRIDE { diff --git a/chrome/browser/prefs/pref_hash_browsertest.cc b/chrome/browser/prefs/pref_hash_browsertest.cc index 4cfd45b8a700f7..d818c6aaf30a2c 100644 --- a/chrome/browser/prefs/pref_hash_browsertest.cc +++ b/chrome/browser/prefs/pref_hash_browsertest.cc @@ -32,6 +32,10 @@ #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" +#if defined(OS_CHROMEOS) +#include "chromeos/chromeos_switches.h" +#endif + namespace { // An observer that returns back to test code after a new profile is @@ -106,6 +110,10 @@ class PrefHashBrowserTest : public InProcessBrowserTest, switches::kForceFieldTrials, std::string(chrome_prefs::internals::kSettingsEnforcementTrialName) + "/" + GetParam() + "/"); +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif } virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { @@ -164,8 +172,6 @@ class PrefHashBrowserTest : public InProcessBrowserTest, IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, MAYBE_PRE_PRE_InitializeUnloadedProfiles) { - if (!profiles::IsMultipleProfilesEnabled()) - return; ProfileManager* profile_manager = g_browser_process->profile_manager(); // Create an additional profile. @@ -194,9 +200,6 @@ IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, MAYBE_PRE_InitializeUnloadedProfiles) { - if (!profiles::IsMultipleProfilesEnabled()) - return; - // Creating the profile would have initialized its hash store. Also, we don't // know whether the newly created or original profile will be launched (does // creating a profile cause it to be the most recently used?). @@ -231,9 +234,6 @@ IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, MAYBE_InitializeUnloadedProfiles) { - if (!profiles::IsMultipleProfilesEnabled()) - return; - const base::DictionaryValue* hashes = g_browser_process->local_state()->GetDictionary( prefs::kProfilePreferenceHashes); diff --git a/chrome/browser/profiles/profile_browsertest.cc b/chrome/browser/profiles/profile_browsertest.cc index 2a06e5eae029a8..0cc502f4ea4b0a 100644 --- a/chrome/browser/profiles/profile_browsertest.cc +++ b/chrome/browser/profiles/profile_browsertest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/profiles/profile.h" +#include "base/command_line.h" #include "base/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/prefs/pref_service.h" @@ -22,6 +23,10 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#if defined(OS_CHROMEOS) +#include "chromeos/chromeos_switches.h" +#endif + namespace { class MockProfileDelegate : public Profile::Delegate { @@ -84,7 +89,15 @@ void SpinThreads() { } // namespace -typedef InProcessBrowserTest ProfileBrowserTest; +class ProfileBrowserTest : public InProcessBrowserTest { + protected: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif + } +}; // Test OnProfileCreate is called with is_new_profile set to true when // creating a new profile synchronously. diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 9a4234f032ce89..1f49bbb428821f 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -990,15 +990,11 @@ void ProfileIOData::Init( #if defined(OS_CHROMEOS) username_hash_ = profile_params_->username_hash; scoped_refptr verify_proc; - if (chromeos::UserManager::IsMultipleProfilesAllowed()) { - crypto::ScopedPK11Slot public_slot = - crypto::GetPublicSlotForChromeOSUser(username_hash_); - // The private slot won't be ready by this point. It shouldn't be necessary - // for cert trust purposes anyway. - verify_proc = new chromeos::CertVerifyProcChromeOS(public_slot.Pass()); - } else { - verify_proc = net::CertVerifyProc::CreateDefault(); - } + crypto::ScopedPK11Slot public_slot = + crypto::GetPublicSlotForChromeOSUser(username_hash_); + // The private slot won't be ready by this point. It shouldn't be necessary + // for cert trust purposes anyway. + verify_proc = new chromeos::CertVerifyProcChromeOS(public_slot.Pass()); if (cert_verifier_) { cert_verifier_->InitializeOnIOThread(verify_proc); main_request_context_->set_cert_verifier(cert_verifier_.get()); diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index 9e25b1da6fc2a6..e5985b9f39ff3e 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -83,6 +83,7 @@ #include "chrome/browser/chromeos/login/user.h" #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -326,11 +327,12 @@ Profile* ProfileManager::GetPrimaryUserProfile() { Profile* ProfileManager::GetActiveUserProfile() { ProfileManager* profile_manager = g_browser_process->profile_manager(); #if defined(OS_CHROMEOS) - if (!chromeos::UserManager::IsMultipleProfilesAllowed() || - !profile_manager->IsLoggedIn() || - !chromeos::UserManager::IsInitialized()) + if (!profile_manager->IsLoggedIn() || + !chromeos::UserManager::IsInitialized()) { return profile_manager->GetActiveUserOrOffTheRecordProfileFromPath( profile_manager->user_data_dir()); + } + chromeos::UserManager* manager = chromeos::UserManager::Get(); const chromeos::User* user = manager->GetActiveUser(); // To avoid an endless loop (crbug.com/334098) we have to additionally check @@ -454,20 +456,13 @@ base::FilePath ProfileManager::GetInitialProfileDir() { // by default. http://crbug.com/294628 profile_dir = chromeos::ProfileHelper:: GetProfileDirByLegacyLoginProfileSwitch(); - } else if (!command_line.HasSwitch(switches::kMultiProfiles)) { - // We should never be logged in with no profile dir unless - // multi-profiles are enabled. - // In that case profile dir will be defined by user_id hash. - NOTREACHED(); - return base::FilePath(""); } // 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 (command_line.HasSwitch(switches::kMultiProfiles) && - !user_id_hash.empty()) { + if (!user_id_hash.empty()) { profile_dir = g_browser_process->platform_part()-> profile_helper()->GetActiveUserProfileDir(); } @@ -491,20 +486,12 @@ Profile* ProfileManager::GetLastUsedProfile( // CrOS multi-profiles implementation is different so GetLastUsedProfile // has custom implementation too. base::FilePath profile_dir; - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kMultiProfiles)) { - // In case of multi-profiles we ignore "last used profile" preference - // 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(); - } else { - // For legacy (not multi-profiles) implementation always default to - // --login-profile value. - profile_dir = - chromeos::ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch(); - } + // In case of multi-profiles we ignore "last used profile" preference + // 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(); base::FilePath profile_path(user_data_dir); Profile* profile = GetProfile(profile_path.Append(profile_dir)); diff --git a/chrome/browser/profiles/profile_manager_browsertest.cc b/chrome/browser/profiles/profile_manager_browsertest.cc index def46bc0713846..9c95d5a27af033 100644 --- a/chrome/browser/profiles/profile_manager_browsertest.cc +++ b/chrome/browser/profiles/profile_manager_browsertest.cc @@ -15,7 +15,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/host_desktop.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/test_switches.h" @@ -94,6 +93,13 @@ class ProfileRemovalObserver : public ProfileInfoCacheObserver { // TODO(jeremy): crbug.com/103355 - These tests should be enabled on all // platforms. class ProfileManagerBrowserTest : public InProcessBrowserTest { + protected: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif + } }; #if defined(OS_MACOSX) @@ -179,21 +185,17 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DISABLED_DeleteAllProfiles) { #if defined(OS_CHROMEOS) -class ProfileManagerCrOSBrowserTest : public ProfileManagerBrowserTest, - public testing::WithParamInterface { +class ProfileManagerCrOSBrowserTest : public ProfileManagerBrowserTest { protected: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - if (GetParam()) { - command_line->AppendSwitch(::switches::kMultiProfiles); - // Use a user hash other than the default chrome::kTestUserProfileDir - // so that the prefix case is tested. - command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, - "test-user-hash"); - } + // Use a user hash other than the default chrome::kTestUserProfileDir + // so that the prefix case is tested. + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, + "test-user-hash"); } }; -IN_PROC_BROWSER_TEST_P(ProfileManagerCrOSBrowserTest, GetLastUsedProfile) { +IN_PROC_BROWSER_TEST_F(ProfileManagerCrOSBrowserTest, GetLastUsedProfile) { // Make sure that last used profile is correct. Profile* last_used_profile = ProfileManager::GetLastUsedProfile(); EXPECT_TRUE(last_used_profile != NULL); @@ -201,20 +203,11 @@ IN_PROC_BROWSER_TEST_P(ProfileManagerCrOSBrowserTest, GetLastUsedProfile) { base::FilePath profile_path; PathService::Get(chrome::DIR_USER_DATA, &profile_path); - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kMultiProfiles)) { - profile_path = profile_path.AppendASCII( - std::string(chrome::kProfileDirPrefix) + "test-user-hash"); - } else { - profile_path = profile_path.AppendASCII(chrome::kTestUserProfileDir); - } + profile_path = profile_path.AppendASCII( + std::string(chrome::kProfileDirPrefix) + "test-user-hash"); EXPECT_EQ(profile_path.value(), last_used_profile->GetPath().value()); } -INSTANTIATE_TEST_CASE_P(ProfileManagerCrOSBrowserTestInstantiation, - ProfileManagerCrOSBrowserTest, - testing::Bool()); - #endif // OS_CHROMEOS // Times out (http://crbug.com/159002) diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc index 82e8fd9eb80abb..07c6e9fa651487 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc @@ -36,6 +36,7 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/notification_service.h" +#include "content/public/common/content_switches.h" #include "content/public/test/test_browser_thread_bundle.h" #include "grit/generated_resources.h" #include "testing/gmock/include/gmock/gmock.h" @@ -392,7 +393,7 @@ class ProfileManagerGuestTest : public ProfileManagerTest, cl->AppendSwitch(switches::kMultiProfiles); cl->AppendSwitch(switches::kTestType); - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) { + if (profiles::IsMultipleProfilesEnabled()) { cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, std::string(chrome::kProfileDirPrefix) + chromeos::UserManager::kGuestUserName); diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc index 282ffd3f3544b2..dbb330cd65c795 100644 --- a/chrome/browser/profiles/profiles_state.cc +++ b/chrome/browser/profiles/profiles_state.cc @@ -20,20 +20,12 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/login/user_manager.h" -#endif - namespace profiles { bool IsMultipleProfilesEnabled() { #if defined(OS_ANDROID) return false; #endif -#if defined(OS_CHROMEOS) - return chromeos::UserManager::IsMultipleProfilesAllowed(); -#endif - return true; } diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc index 5ba5da999320ef..8caf1c59006841 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc @@ -9,6 +9,7 @@ #include #include "base/bind.h" +#include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" @@ -35,6 +36,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -44,6 +46,10 @@ #include "sql/statement.h" #include "testing/gmock/include/gmock/gmock.h" +#if defined(OS_CHROMEOS) +#include "chromeos/chromeos_switches.h" +#endif + using content::BrowserThread; using content::InterstitialPage; using content::WebContents; @@ -394,6 +400,17 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest { SafeBrowsingService::RegisterFactory(NULL); } + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + // Makes sure the auto update is not triggered during the test. + // This test will fill up the database using testing prefixes + // and urls. + command_line->AppendSwitch(switches::kSbDisableAutoUpdate); +#if defined(OS_CHROMEOS) + command_line->AppendSwitch( + chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif + } + virtual void SetUpInProcessBrowserTestFixture() { ASSERT_TRUE(test_server()->Start()); } diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc index e3355f50dbb0f3..9f79709747d0b0 100644 --- a/chrome/browser/sync/test/integration/sync_test.cc +++ b/chrome/browser/sync/test/integration/sync_test.cc @@ -75,6 +75,10 @@ #include "sync/test/fake_server/fake_server_network_resources.h" #include "url/gurl.h" +#if defined(OS_CHROMEOS) +#include "chromeos/chromeos_switches.h" +#endif + using content::BrowserThread; using invalidation::InvalidationServiceFactory; @@ -242,6 +246,10 @@ void SyncTest::TearDown() { void SyncTest::SetUpCommandLine(base::CommandLine* cl) { AddTestSwitches(cl); AddOptionalTypesToCommandLine(cl); + +#if defined(OS_CHROMEOS) + cl->AppendSwitch(chromeos::switches::kIgnoreUserProfileMappingForTests); +#endif } void SyncTest::AddTestSwitches(base::CommandLine* cl) { diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc index bbcaa5d9317fa4..4f6ffe321e8c8e 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc @@ -10,10 +10,10 @@ #include "ash/magnifier/magnifier_constants.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" -#include "base/command_line.h" #include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/ui/app_list/app_list_service.h" #include "chrome/browser/ui/app_list/app_list_view_delegate.h" #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" @@ -21,7 +21,6 @@ #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" #include "chrome/browser/ui/browser_commands.h" -#include "chrome/common/chrome_switches.h" #include "components/signin/core/common/profile_management_switches.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -48,10 +47,7 @@ ChromeShellDelegate::~ChromeShellDelegate() { } bool ChromeShellDelegate::IsMultiProfilesEnabled() const { - // TODO(skuhne): There is a function named profiles::IsMultiProfilesEnabled - // which does similar things - but it is not the same. We should investigate - // if these two could be folded together. - if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) + if (!profiles::IsMultipleProfilesEnabled()) return false; #if defined(OS_CHROMEOS) // If there is a user manager, we need to see that we can at least have 2 diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 982f3f248177a0..74265799fa0f3a 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1716,6 +1716,8 @@ '../apps/load_and_launch_browsertest.cc', 'browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc', 'browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc', + # chromeos does not support profile list avatar menu + 'browser/profiles/profile_list_desktop_browsertest.cc', 'browser/service_process/service_process_control_browsertest.cc', 'browser/signin/signin_browsertest.cc', # chromeos does not use cross-platform panels diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index 93114258135c54..7398a897e747a9 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -224,10 +224,9 @@ base::FilePath GetSessionLogFile(const CommandLine& command_line) { } void RedirectChromeLogging(const CommandLine& command_line) { - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles) && - chrome_logging_redirected_) { + if (chrome_logging_redirected_) { // TODO(nkostylev): Support multiple active users. http://crbug.com/230345 - LOG(ERROR) << "NOT redirecting logging for multi-profiles case."; + LOG(WARNING) << "NOT redirecting logging for multi-profiles case."; return; } diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index 77cf81ba93670c..91c825f4d5c9ad 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -142,6 +142,13 @@ const char kHasChromeOSKeyboard[] = "has-chromeos-keyboard"; // If true, the Chromebook has a keyboard with a diamond key. const char kHasChromeOSDiamondKey[] = "has-chromeos-diamond-key"; +// If true, profile selection in UserManager will always return active user's +// profile. +// TODO(nkostlyev): http://crbug.com/364604 - Get rid of this switch after we +// turn on multi-profile feature on ChromeOS. +const char kIgnoreUserProfileMappingForTests[] = + "ignore-user-profile-mapping-for-tests"; + // Path for the screensaver used in Kiosk mode const char kKioskModeScreensaverPath[] = "kiosk-mode-screensaver-path"; diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 0290c2bb452a7b..a2a12680236152 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -57,6 +57,7 @@ CHROMEOS_EXPORT extern const char kForceLoginManagerInTests[]; CHROMEOS_EXPORT extern const char kGuestSession[]; CHROMEOS_EXPORT extern const char kHasChromeOSDiamondKey[]; CHROMEOS_EXPORT extern const char kHasChromeOSKeyboard[]; +CHROMEOS_EXPORT extern const char kIgnoreUserProfileMappingForTests[]; CHROMEOS_EXPORT extern const char kKioskModeScreensaverPath[]; CHROMEOS_EXPORT extern const char kLoginManager[]; CHROMEOS_EXPORT extern const char kLoginPassword[];