Skip to content

Commit

Permalink
Turning on MultiProfile by default for ChromeOS
Browse files Browse the repository at this point in the history
Merged with issues 184563005, 273653004

BUG=364604, 351244, 349844
TEST=existing tests

Review URL: https://codereview.chromium.org/271533004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270753 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
zelidrag@chromium.org committed May 15, 2014
1 parent be8cd1e commit f9357a4
Show file tree
Hide file tree
Showing 44 changed files with 323 additions and 294 deletions.
6 changes: 0 additions & 6 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -5992,12 +5992,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_DISABLE_SAML_SIGNIN_DESCRIPTION" desc="Description for the flag to disables SAML sign-in support.">
Disables SAML sign-in support for Chrome OS sign-in.
</message>
<message name="IDS_FLAGS_ENABLE_MULTI_PROFILES_NAME" desc="Name for the flag to enable multi-profile support.">
Enable multiprofiles mode.
</message>
<message name="IDS_FLAGS_ENABLE_MULTI_PROFILES_DESCRIPTION" desc="Description for the flag to enable multi-profile support.">
This is an experimental mode to run several profiles/users simultaneously during a browsing session. Features may break or change significantly.
</message>
</if>
<message name="IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_NAME" desc="Name of the flag to disable accelerated video decode where available.">
Disable hardware-accelerated video decode.
Expand Down
7 changes: 0 additions & 7 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 0 additions & 17 deletions chrome/browser/chrome_browser_field_trials_desktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -137,9 +123,6 @@ void SetupDesktopFieldTrials(const CommandLine& parsed_command_line,
DisableShowProfileSwitcherTrialIfNecessary();
SetupShowAppLauncherPromoFieldTrial(local_state);
SetupPreReadFieldTrial();
#if defined(OS_CHROMEOS)
SetupChromeOSMultiProfilesAllowedTrial();
#endif
}

} // namespace chrome
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,6 @@ bool FileBrowserPrivateVisitDesktopFunction::RunSync() {
const std::vector<linked_ptr<api::file_browser_private::ProfileInfo> >&
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand Down
9 changes: 3 additions & 6 deletions chrome/browser/chromeos/file_manager/path_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
25 changes: 16 additions & 9 deletions chrome/browser/chromeos/file_manager/volume_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_) {
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/chromeos/login/chrome_restart_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 7 additions & 13 deletions chrome/browser/chromeos/login/kiosk_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 10 additions & 4 deletions chrome/browser/chromeos/login/login_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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");
}
};

Expand All @@ -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);
}
Expand All @@ -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));
}
};

Expand All @@ -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());
}

Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/chromeos/login/login_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/login/login_manager_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
32 changes: 4 additions & 28 deletions chrome/browser/chromeos/login/login_utils_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_.
Expand Down Expand Up @@ -526,28 +523,11 @@ class LoginUtilsTest : public testing::Test,
DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest);
};

class LoginUtilsParamTest
: public LoginUtilsTest,
public testing::WithParamInterface<bool> {
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<int> {};

TEST_P(LoginUtilsParamTest, NormalLoginDoesntBlock) {
TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) {
UserManager* user_manager = UserManager::Get();
EXPECT_FALSE(user_manager->IsUserLoggedIn());
EXPECT_FALSE(connector_->IsEnterpriseManaged());
Expand All @@ -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());
Expand All @@ -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));

Expand Down Expand Up @@ -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
Loading

0 comments on commit f9357a4

Please sign in to comment.