From f52c94fc32b42a121aab3448d8647b99d21bcd71 Mon Sep 17 00:00:00 2001 From: "xiyuan@chromium.org" Date: Fri, 14 Feb 2014 17:09:14 +0000 Subject: [PATCH] Revert 251352 "cros: Enable multiprofile for everyone." > cros: Enable multiprofile for everyone. > > BUG=338941 > R=dpolukhin@chromium.org, nkostylev@chromium.org > > Review URL: https://codereview.chromium.org/146193005 TBR=xiyuan@chromium.org Review URL: https://codereview.chromium.org/167173002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251357 0039d316-1c4b-4281-b951-d872f2087c98 --- .../chromeos/file_manager/file_manager_browsertest.cc | 1 + .../browser/chromeos/login/multi_profile_user_controller.cc | 13 ++++++++++++- .../login/saml/saml_offline_signin_limiter_unittest.cc | 5 +++++ chrome/browser/chromeos/login/screen_locker_browsertest.cc | 1 + .../chromeos/login/user_adding_screen_browsertest.cc | 1 + .../webui/options/chromeos/accounts_options_browsertest.cc | 1 + chromeos/chromeos_switches.cc | 5 +++++ chromeos/chromeos_switches.h | 1 + 8 files changed, 27 insertions(+), 1 deletion(-) diff --git a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc index 7e17544dabf3..7513d5c139e3 100644 --- a/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/chromeos/file_manager/file_manager_browsertest.cc @@ -832,6 +832,7 @@ class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { FileManagerBrowserTestBase::SetUpCommandLine(command_line); command_line->AppendSwitch(switches::kMultiProfiles); + command_line->AppendSwitch(chromeos::switches::kForceMultiProfileInTests); // Logs in to a dummy profile (For making MultiProfileWindowManager happy; // browser test creates a default window and the manager tries to assign a // user for it, and we need a profile connected to a user.) diff --git a/chrome/browser/chromeos/login/multi_profile_user_controller.cc b/chrome/browser/chromeos/login/multi_profile_user_controller.cc index 847c27b89468..f5eb9a9ccb57 100644 --- a/chrome/browser/chromeos/login/multi_profile_user_controller.cc +++ b/chrome/browser/chromeos/login/multi_profile_user_controller.cc @@ -5,6 +5,7 @@ #include "chrome/browser/chromeos/login/multi_profile_user_controller.h" #include "base/bind.h" +#include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "base/prefs/pref_change_registrar.h" #include "base/prefs/pref_registry_simple.h" @@ -18,6 +19,7 @@ #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" +#include "chromeos/chromeos_switches.h" #include "google_apis/gaia/gaia_auth_util.h" namespace chromeos { @@ -59,9 +61,18 @@ void MultiProfileUserController::RegisterPrefs( // static void MultiProfileUserController::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { + // Use "disabled" default if there is no user manager or no logged in user. + // This is true for signin profile (where the value does not matter) or + // for the primary user's profile. This essentially disables multiprofile + // unless the primary user has a policy to say otherwise. + const bool use_disable_default = + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kForceMultiProfileInTests) && + (!UserManager::IsInitialized() || + UserManager::Get()->GetLoggedInUsers().size() == 1); registry->RegisterStringPref( prefs::kMultiProfileUserBehavior, - kBehaviorUnrestricted, + use_disable_default ? kBehaviorNotAllowed : kBehaviorUnrestricted, user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); } diff --git a/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_unittest.cc b/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_unittest.cc index beefccda8026..2747f3c84256 100644 --- a/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_unittest.cc +++ b/chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_unittest.cc @@ -84,7 +84,12 @@ void SAMLOfflineSigninLimiterTest::CreateLimiter() { } void SAMLOfflineSigninLimiterTest::SetUp() { + const UserList user_list; + EXPECT_CALL(*user_manager_, GetLoggedInUsers()) + .Times(1) + .WillOnce(ReturnRef(user_list)); profile_.reset(new TestingProfile); + Mock::VerifyAndClearExpectations(user_manager_); SAMLOfflineSigninLimiterFactory::SetClockForTesting(&clock_); user_manager_->AddUser(kTestUser); diff --git a/chrome/browser/chromeos/login/screen_locker_browsertest.cc b/chrome/browser/chromeos/login/screen_locker_browsertest.cc index ba6bf9743336..d80e3264c9a1 100644 --- a/chrome/browser/chromeos/login/screen_locker_browsertest.cc +++ b/chrome/browser/chromeos/login/screen_locker_browsertest.cc @@ -132,6 +132,7 @@ class ScreenLockerTest : public InProcessBrowserTest { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); + command_line->AppendSwitch(switches::kForceMultiProfileInTests); } scoped_ptr zero_duration_mode_; diff --git a/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc b/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc index 669eb6c8a887..cd077a26cd95 100644 --- a/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/user_adding_screen_browsertest.cc @@ -39,6 +39,7 @@ class UserAddingScreenTest : public LoginManagerTest, virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { LoginManagerTest::SetUpCommandLine(command_line); command_line->AppendSwitch(::switches::kMultiProfiles); + command_line->AppendSwitch(switches::kForceMultiProfileInTests); } virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 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 c121930ab9a1..33fbebf48eee 100644 --- a/chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc +++ b/chrome/browser/ui/webui/options/chromeos/accounts_options_browsertest.cc @@ -59,6 +59,7 @@ class AccountsOptionsTest : public LoginManagerTest { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { LoginManagerTest::SetUpCommandLine(command_line); command_line->AppendSwitch(::switches::kMultiProfiles); + command_line->AppendSwitch(switches::kForceMultiProfileInTests); } protected: diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index 619d14b2e1ae..fede17d63445 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -149,6 +149,11 @@ const char kFirstExecAfterBoot[] = "first-exec-after-boot"; // tests can change how it's brought up. This flag disables that. const char kForceLoginManagerInTests[] = "force-login-manager-in-tests"; +// Sets primary user's default multiprofile behavior to 'unrestricted' for +// tests so that multiprofile is enabled for any user. +// TODO(xiyuan): Remove when multiprofile is released to everyone. +const char kForceMultiProfileInTests[] = "force-multi-profiles-in-tests"; + // Makes GPU sandbox failures nonfatal. const char kGpuSandboxFailuresNonfatal[] = "gpu-sandbox-failures-nonfatal"; diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index eb23bf3c8e74..d2c5cf1a3da7 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -58,6 +58,7 @@ CHROMEOS_EXPORT extern const char kFileManagerEnableNewAudioPlayer[]; CHROMEOS_EXPORT extern const char kFileManagerEnableMultiProfile[]; CHROMEOS_EXPORT extern const char kFirstExecAfterBoot[]; CHROMEOS_EXPORT extern const char kForceLoginManagerInTests[]; +CHROMEOS_EXPORT extern const char kForceMultiProfileInTests[]; CHROMEOS_EXPORT extern const char kGpuSandboxFailuresNonfatal[]; CHROMEOS_EXPORT extern const char kGuestSession[]; CHROMEOS_EXPORT extern const char kHasChromeOSDiamondKey[]; -- 2.11.4.GIT