summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoribraaaa@chromium.org <ibraaaa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-05 14:13:13 +0000
committeribraaaa@chromium.org <ibraaaa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-05 14:13:13 +0000
commita6e01b4079bf48ed481b44fb577ab8b40e86effb (patch)
treee37cf68b1487e189b3a83af0b6743ddb1fb082fc
parent131eb68a409292e6b7728fa09c0ce8333d59f444 (diff)
downloadchromium_src-a6e01b4079bf48ed481b44fb577ab8b40e86effb.zip
chromium_src-a6e01b4079bf48ed481b44fb577ab8b40e86effb.tar.gz
chromium_src-a6e01b4079bf48ed481b44fb577ab8b40e86effb.tar.bz2
Store the managed user ID in |ProfileInfoCache| instead of |is_managed| flag.
Updates |ProfileManager::CreateMultiProfileAsync| to take |managed_user_id| instead of the |is_managed| flag, the user is managed if |managed_user_id| is not empty. The preference |prefs::kManagedUserId| is added to hold the managed user ID. |prefs::kProfileIsManaged| should eventually be deleted. TBR=nkostylev@chromium.org, tapted@chromium.org, jochen@chromium.org BUG=None Review URL: https://chromiumcodereview.appspot.com/21496004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215610 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac.cc2
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc2
-rw-r--r--chrome/browser/chromeos/login/managed/locally_managed_user_creation_controller.cc1
-rw-r--r--chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc4
-rw-r--r--chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc2
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility.cc15
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility.h5
-rw-r--r--chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc4
-rw-r--r--chrome/browser/managed_mode/managed_user_service.cc2
-rw-r--r--chrome/browser/managed_mode/managed_user_service.h1
-rw-r--r--chrome/browser/profiles/avatar_menu_model.cc2
-rw-r--r--chrome/browser/profiles/avatar_menu_model_browsertest.cc2
-rw-r--r--chrome/browser/profiles/avatar_menu_model_unittest.cc30
-rw-r--r--chrome/browser/profiles/profile_impl.cc7
-rw-r--r--chrome/browser/profiles/profile_info_cache.cc47
-rw-r--r--chrome/browser/profiles/profile_info_cache.h6
-rw-r--r--chrome/browser/profiles/profile_info_cache_unittest.cc67
-rw-r--r--chrome/browser/profiles/profile_info_interface.h2
-rw-r--r--chrome/browser/profiles/profile_loader.cc6
-rw-r--r--chrome/browser/profiles/profile_loader.h2
-rw-r--r--chrome/browser/profiles/profile_loader_unittest.cc8
-rw-r--r--chrome/browser/profiles/profile_manager.cc27
-rw-r--r--chrome/browser/profiles/profile_manager.h4
-rw-r--r--chrome/browser/profiles/profile_manager_browsertest.cc6
-rw-r--r--chrome/browser/profiles/profile_manager_unittest.cc18
-rw-r--r--chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc10
-rw-r--r--chrome/browser/profiles/profile_window.cc2
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc2
-rw-r--r--chrome/browser/signin/signin_names_io_thread_unittest.cc2
-rw-r--r--chrome/browser/signin/signin_promo.cc2
-rw-r--r--chrome/browser/ui/app_list/app_list_controller_browsertest.cc2
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_browsertest.cc2
-rw-r--r--chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm6
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm2
-rw-r--r--chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator.cc3
-rw-r--r--chrome/browser/ui/sync/one_click_signin_helper_unittest.cc2
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_starter.cc2
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc11
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.h1
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--chrome/test/base/testing_profile.cc3
-rw-r--r--chrome/test/base/testing_profile_manager.cc6
-rw-r--r--chrome/test/base/testing_profile_manager.h4
45 files changed, 211 insertions, 129 deletions
diff --git a/apps/app_shim/extension_app_shim_handler_mac.cc b/apps/app_shim/extension_app_shim_handler_mac.cc
index f663de0b..cc09641 100644
--- a/apps/app_shim/extension_app_shim_handler_mac.cc
+++ b/apps/app_shim/extension_app_shim_handler_mac.cc
@@ -83,7 +83,7 @@ void ExtensionAppShimHandler::Delegate::LoadProfileAsync(
profile_manager->CreateProfileAsync(
full_path,
base::Bind(&ProfileLoadedCallback, callback),
- string16(), string16(), false);
+ string16(), string16(), std::string());
}
ShellWindowList ExtensionAppShimHandler::Delegate::GetWindows(
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index baef984..e57efad 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1048,7 +1048,7 @@ void TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile(
ProfileManager* profile_manager = g_browser_process->profile_manager();
new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message);
profile_manager->CreateMultiProfileAsync(
- string16(), string16(), ProfileManager::CreateCallback(), false);
+ string16(), string16(), ProfileManager::CreateCallback(), std::string());
}
// Sample json input: { "command": "GetMultiProfileInfo" }
diff --git a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_controller.cc b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_controller.cc
index f1cd9a1..242a5a5 100644
--- a/chrome/browser/chromeos/login/managed/locally_managed_user_creation_controller.cc
+++ b/chrome/browser/chromeos/login/managed/locally_managed_user_creation_controller.cc
@@ -158,6 +158,7 @@ void LocallyManagedUserCreationController::OnAddKeySuccess() {
ManagedUserRegistrationInfo info(creation_context_->display_name);
info.master_key = creation_context_->master_key;
creation_context_->registration_utility->Register(
+ ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
info,
base::Bind(&LocallyManagedUserCreationController::RegistrationCallback,
weak_factory_.GetWeakPtr()));
diff --git a/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc b/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc
index f0e9477..c452286 100644
--- a/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc
+++ b/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc
@@ -129,7 +129,7 @@ void RecommendationRestorerTest::CreateLoginProfile() {
ASSERT_FALSE(restorer_);
TestingProfile* profile = profile_manager_.CreateTestingProfile(
chrome::kInitialProfile, prefs_owner_.Pass(),
- UTF8ToUTF16(chrome::kInitialProfile), 0, false);
+ UTF8ToUTF16(chrome::kInitialProfile), 0, std::string());
restorer_ = RecommendationRestorerFactory::GetForProfile(profile);
EXPECT_TRUE(restorer_);
}
@@ -137,7 +137,7 @@ void RecommendationRestorerTest::CreateLoginProfile() {
void RecommendationRestorerTest::CreateUserProfile() {
ASSERT_FALSE(restorer_);
TestingProfile* profile = profile_manager_.CreateTestingProfile(
- "user", prefs_owner_.Pass(), UTF8ToUTF16("user"), 0, false);
+ "user", prefs_owner_.Pass(), UTF8ToUTF16("user"), 0, std::string());
restorer_ = RecommendationRestorerFactory::GetForProfile(profile);
EXPECT_TRUE(restorer_);
}
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc
index 23c6ed8..eb1f266 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc
@@ -89,7 +89,7 @@ class UserCloudPolicyManagerChromeOSTest : public testing::Test {
ASSERT_TRUE(profile_manager_->SetUp());
profile_ = profile_manager_->CreateTestingProfile(
chrome::kInitialProfile, scoped_ptr<PrefServiceSyncable>(),
- UTF8ToUTF16("testing_profile"), 0, false);
+ UTF8ToUTF16("testing_profile"), 0, std::string());
signin_profile_ = profile_manager_->CreateTestingProfile(kSigninProfile);
signin_profile_->set_incognito(true);
// Usually the signin Profile and the main Profile are separate, but since
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.cc b/chrome/browser/managed_mode/managed_user_registration_utility.cc
index 79feee9..90e9748 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility.cc
+++ b/chrome/browser/managed_mode/managed_user_registration_utility.cc
@@ -68,7 +68,17 @@ ManagedUserRegistrationUtility::Create(Profile* profile) {
profile->GetPrefs(), token_fetcher.Pass(), managed_user_sync_service));
}
+// static
+std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() {
+ std::string new_managed_user_id;
+ bool success = base::Base64Encode(base::RandBytesAsString(8),
+ &new_managed_user_id);
+ DCHECK(success);
+ return new_managed_user_id;
+}
+
void ManagedUserRegistrationUtility::Register(
+ const std::string& managed_user_id,
const ManagedUserRegistrationInfo& info,
const RegistrationCallback& callback) {
DCHECK(pending_managed_user_id_.empty());
@@ -86,10 +96,7 @@ void ManagedUserRegistrationUtility::Register(
GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED)));
}
- std::string id_raw = base::RandBytesAsString(8);
- bool success = base::Base64Encode(id_raw, &pending_managed_user_id_);
- DCHECK(success);
-
+ pending_managed_user_id_ = managed_user_id;
managed_user_sync_service_->AddManagedUser(pending_managed_user_id_,
base::UTF16ToUTF8(info.name),
info.master_key);
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.h b/chrome/browser/managed_mode/managed_user_registration_utility.h
index 5a35ac0..c7798a3 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility.h
+++ b/chrome/browser/managed_mode/managed_user_registration_utility.h
@@ -55,12 +55,15 @@ class ManagedUserRegistrationUtility
static scoped_ptr<ManagedUserRegistrationUtility> Create(Profile* profile);
+ static std::string GenerateNewManagedUserId();
+
// Registers a new managed user with the server. |info| contains necessary
// information like the display name of the the user. |callback| is called
// with the result of the registration. We use the info here and not the
// profile, because on Chrome OS the profile of the managed user does
// not yet exist.
- void Register(const ManagedUserRegistrationInfo& info,
+ void Register(const std::string& managed_user_id,
+ const ManagedUserRegistrationInfo& info,
const RegistrationCallback& callback);
// ManagedUserSyncServiceObserver:
diff --git a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc b/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
index 60a84bb..76962a9 100644
--- a/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
+++ b/chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc
@@ -214,6 +214,7 @@ TEST_F(ManagedUserRegistrationUtilityTest, Register) {
token_fetcher.Pass(),
service());
registration_utility.Register(
+ ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Dug")),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
@@ -231,6 +232,7 @@ TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
token_fetcher.Pass(),
service());
registration_utility.Register(
+ ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Nemo")),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
@@ -250,6 +252,7 @@ TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
token_fetcher.Pass(),
service());
registration_utility.Register(
+ ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Remy")),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
@@ -268,6 +271,7 @@ TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) {
token_fetcher.Pass(),
service());
registration_utility.Register(
+ ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
ManagedUserRegistrationInfo(ASCIIToUTF16("Mike")),
GetRegistrationCallback());
EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
diff --git a/chrome/browser/managed_mode/managed_user_service.cc b/chrome/browser/managed_mode/managed_user_service.cc
index 42452f4..de4ec76 100644
--- a/chrome/browser/managed_mode/managed_user_service.cc
+++ b/chrome/browser/managed_mode/managed_user_service.cc
@@ -561,6 +561,7 @@ void ManagedUserService::Init() {
void ManagedUserService::RegisterAndInitSync(
ManagedUserRegistrationUtility* registration_utility,
Profile* custodian_profile,
+ const std::string& managed_user_id,
const ProfileManager::CreateCallback& callback) {
DCHECK(ProfileIsManaged());
DCHECK(!custodian_profile->IsManaged());
@@ -569,6 +570,7 @@ void ManagedUserService::RegisterAndInitSync(
profile_->GetPrefs()->GetString(prefs::kProfileName));
ManagedUserRegistrationInfo info(name);
registration_utility->Register(
+ managed_user_id,
info,
base::Bind(&ManagedUserService::OnManagedUserRegistered,
weak_ptr_factory_.GetWeakPtr(), callback, custodian_profile));
diff --git a/chrome/browser/managed_mode/managed_user_service.h b/chrome/browser/managed_mode/managed_user_service.h
index a336f5a..c3769a5 100644
--- a/chrome/browser/managed_mode/managed_user_service.h
+++ b/chrome/browser/managed_mode/managed_user_service.h
@@ -125,6 +125,7 @@ class ManagedUserService : public BrowserContextKeyedService,
// in which case the callback will be ignored.
void RegisterAndInitSync(ManagedUserRegistrationUtility* registration_utility,
Profile* custodian_profile,
+ const std::string& managed_user_id,
const ProfileManager::CreateCallback& callback);
// Returns a pseudo-email address for systems that expect well-formed email
diff --git a/chrome/browser/profiles/avatar_menu_model.cc b/chrome/browser/profiles/avatar_menu_model.cc
index 88db32d..8b1a4d1 100644
--- a/chrome/browser/profiles/avatar_menu_model.cc
+++ b/chrome/browser/profiles/avatar_menu_model.cc
@@ -207,7 +207,7 @@ void AvatarMenuModel::SwitchToGuestProfileWindow(Browser* browser) {
browser->host_desktop_type()),
string16(),
string16(),
- false);
+ std::string());
}
size_t AvatarMenuModel::GetNumberOfItems() {
diff --git a/chrome/browser/profiles/avatar_menu_model_browsertest.cc b/chrome/browser/profiles/avatar_menu_model_browsertest.cc
index cd155fe..2be0903 100644
--- a/chrome/browser/profiles/avatar_menu_model_browsertest.cc
+++ b/chrome/browser/profiles/avatar_menu_model_browsertest.cc
@@ -77,7 +77,7 @@ IN_PROC_BROWSER_TEST_F(AvatarMenuModelTest, SwitchToProfile) {
FILE_PATH_LITERAL("New Profile 2"));
profile_manager->CreateProfileAsync(path_profile2,
base::Bind(&OnUnblockOnProfileCreation),
- string16(), string16(), false);
+ string16(), string16(), std::string());
// Spin to allow profile creation to take place, loop is terminated
// by OnUnblockOnProfileCreation when the profile is created.
diff --git a/chrome/browser/profiles/avatar_menu_model_unittest.cc b/chrome/browser/profiles/avatar_menu_model_unittest.cc
index c999931..3a140f8 100644
--- a/chrome/browser/profiles/avatar_menu_model_unittest.cc
+++ b/chrome/browser/profiles/avatar_menu_model_unittest.cc
@@ -63,9 +63,9 @@ TEST_F(AvatarMenuModelTest, InitialCreation) {
string16 name2(ASCIIToUTF16("Test 2"));
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- name1, 0, false);
+ name1, 0, std::string());
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0, false);
+ name2, 0, std::string());
MockObserver observer;
EXPECT_EQ(0, observer.change_count());
@@ -89,9 +89,9 @@ TEST_F(AvatarMenuModelTest, ActiveItem) {
string16 name2(ASCIIToUTF16("Test 2"));
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- name1, 0, false);
+ name1, 0, std::string());
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0, false);
+ name2, 0, std::string());
MockObserver observer;
AvatarMenuModel model(manager()->profile_info_cache(), &observer, browser());
@@ -107,9 +107,9 @@ TEST_F(AvatarMenuModelTest, ModifyingNameResortsCorrectly) {
string16 newname1(ASCIIToUTF16("Gamma"));
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- name1, 0, false);
+ name1, 0, std::string());
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0, false);
+ name2, 0, std::string());
MockObserver observer;
AvatarMenuModel model(manager()->profile_info_cache(), &observer, browser());
@@ -143,9 +143,9 @@ TEST_F(AvatarMenuModelTest, ChangeOnNotify) {
string16 name2(ASCIIToUTF16("Test 2"));
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- name1, 0, false);
+ name1, 0, std::string());
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0, false);
+ name2, 0, std::string());
MockObserver observer;
EXPECT_EQ(0, observer.change_count());
@@ -156,7 +156,7 @@ TEST_F(AvatarMenuModelTest, ChangeOnNotify) {
string16 name3(ASCIIToUTF16("Test 3"));
manager()->CreateTestingProfile("p3", scoped_ptr<PrefServiceSyncable>(),
- name3, 0, false);
+ name3, 0, std::string());
// Four changes happened via the call to CreateTestingProfile: adding the
// profile to the cache, setting the user name, rebuilding the list of
@@ -198,7 +198,7 @@ TEST_F(AvatarMenuModelTest, ShowAvatarMenuInTrial) {
TEST_F(AvatarMenuModelTest, DontShowAvatarMenu) {
string16 name1(ASCIIToUTF16("Test 1"));
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- name1, 0, false);
+ name1, 0, std::string());
EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu());
@@ -209,7 +209,7 @@ TEST_F(AvatarMenuModelTest, DontShowAvatarMenu) {
string16 name2(ASCIIToUTF16("Test 2"));
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0, false);
+ name2, 0, std::string());
EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu());
}
@@ -223,9 +223,9 @@ TEST_F(AvatarMenuModelTest, ShowAvatarMenu) {
string16 name2(ASCIIToUTF16("Test 2"));
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- name1, 0, false);
+ name1, 0, std::string());
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0, false);
+ name2, 0, std::string());
#if defined(OS_CHROMEOS)
EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu());
@@ -240,13 +240,13 @@ TEST_F(AvatarMenuModelTest, SyncState) {
return;
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- ASCIIToUTF16("Test 1"), 0, false);
+ ASCIIToUTF16("Test 1"), 0, std::string());
// Add a managed user profile.
ProfileInfoCache* cache = manager()->profile_info_cache();
manager()->profile_info_cache()->AddProfileToCache(
cache->GetUserDataDir().AppendASCII("p2"), ASCIIToUTF16("Test 2"),
- string16(), 0, true);
+ string16(), 0, "TEST_ID");
MockObserver observer;
AvatarMenuModel model(manager()->profile_info_cache(), &observer, browser());
EXPECT_EQ(2U, model.GetNumberOfItems());
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 09be43e..c3650e8 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -299,6 +299,9 @@ void ProfileImpl::RegisterProfilePrefs(
prefs::kProfileAvatarIndex,
-1,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+ registry->RegisterStringPref(prefs::kManagedUserId,
+ std::string(),
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterStringPref(prefs::kProfileName,
std::string(),
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
@@ -702,7 +705,9 @@ Profile* ProfileImpl::GetOriginalProfile() {
}
bool ProfileImpl::IsManaged() {
- return GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
+ // TODO(ibraaaa): migrate away from |prefs::kProfileIsManaged|.
+ return GetPrefs()->GetBoolean(prefs::kProfileIsManaged) ||
+ !GetPrefs()->GetString(prefs::kManagedUserId).empty();
}
ExtensionService* ProfileImpl::GetExtensionService() {
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index cc37007..c662a0c 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -49,6 +49,7 @@ const char kHasMigratedToGAIAInfoKey[] = "has_migrated_to_gaia_info";
const char kGAIAPictureFileNameKey[] = "gaia_picture_file_name";
const char kIsManagedKey[] = "is_managed";
const char kSigninRequiredKey[] = "signin_required";
+const char kManagedUserId[] = "managed_user_id";
const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_";
const char kGAIAPictureFileName[] = "Google Profile Picture.png";
@@ -175,14 +176,22 @@ ProfileInfoCache::ProfileInfoCache(PrefService* prefs,
: prefs_(prefs),
user_data_dir_(user_data_dir) {
// Populate the cache
- const DictionaryValue* cache =
- prefs_->GetDictionary(prefs::kProfileInfoCache);
+ DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
+ DictionaryValue* cache = update.Get();
for (DictionaryValue::Iterator it(*cache); !it.IsAtEnd(); it.Advance()) {
- const DictionaryValue* info = NULL;
- it.value().GetAsDictionary(&info);
+ DictionaryValue* info = NULL;
+ cache->GetDictionaryWithoutPathExpansion(it.key(), &info);
string16 name;
info->GetString(kNameKey, &name);
sorted_keys_.insert(FindPositionForProfile(it.key(), name), it.key());
+ // TODO(ibraaaa): delete this when we fully migrate to
+ // |prefs::kManagedUserId|.
+ bool is_managed = false;
+ info->GetBoolean(kIsManagedKey, &is_managed);
+ if (is_managed) {
+ info->SetString(kManagedUserId, "DUMMY_ID");
+ info->Remove(kIsManagedKey, NULL);
+ }
}
}
@@ -195,7 +204,7 @@ void ProfileInfoCache::AddProfileToCache(const base::FilePath& profile_path,
const string16& name,
const string16& username,
size_t icon_index,
- bool is_managed) {
+ const std::string& managed_user_id) {
std::string key = CacheKeyFromProfilePath(profile_path);
DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
DictionaryValue* cache = update.Get();
@@ -206,7 +215,7 @@ void ProfileInfoCache::AddProfileToCache(const base::FilePath& profile_path,
info->SetString(kAvatarIconKey, GetDefaultAvatarIconUrl(icon_index));
// Default value for whether background apps are running is false.
info->SetBoolean(kBackgroundAppsKey, false);
- info->SetBoolean(kIsManagedKey, is_managed);
+ info->SetString(kManagedUserId, managed_user_id);
cache->Set(key, info.release());
sorted_keys_.insert(FindPositionForProfile(key, name), key);
@@ -369,9 +378,7 @@ const gfx::Image* ProfileInfoCache::GetGAIAPictureOfProfileAtIndex(
}
bool ProfileInfoCache::ProfileIsManagedAtIndex(size_t index) const {
- bool value = false;
- GetInfoForProfileAtIndex(index)->GetBoolean(kIsManagedKey, &value);
- return value;
+ return !GetManagedUserIdOfProfileAtIndex(index).empty();
}
bool ProfileInfoCache::ProfileIsSigninRequiredAtIndex(size_t index) const {
@@ -380,6 +387,13 @@ bool ProfileInfoCache::ProfileIsSigninRequiredAtIndex(size_t index) const {
return value;
}
+std::string ProfileInfoCache::GetManagedUserIdOfProfileAtIndex(
+ size_t index) const {
+ std::string managed_user_id;
+ GetInfoForProfileAtIndex(index)->GetString(kManagedUserId, &managed_user_id);
+ return managed_user_id;
+}
+
void ProfileInfoCache::OnGAIAPictureLoaded(const base::FilePath& path,
gfx::Image** image) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -492,6 +506,14 @@ void ProfileInfoCache::SetAvatarIconOfProfileAtIndex(size_t index,
OnProfileAvatarChanged(profile_path));
}
+void ProfileInfoCache::SetManagedUserIdOfProfileAtIndex(size_t index,
+ const std::string& id) {
+ scoped_ptr<DictionaryValue> info(GetInfoForProfileAtIndex(index)->DeepCopy());
+ info->SetString(kManagedUserId, id);
+ // This takes ownership of |info|.
+ SetInfoForProfileAtIndex(index, info.release());
+}
+
void ProfileInfoCache::SetBackgroundStatusOfProfileAtIndex(
size_t index,
bool running_background_apps) {
@@ -613,13 +635,6 @@ void ProfileInfoCache::SetIsUsingGAIAPictureOfProfileAtIndex(size_t index,
OnProfileAvatarChanged(profile_path));
}
-void ProfileInfoCache::SetProfileIsManagedAtIndex(size_t index, bool value) {
- scoped_ptr<DictionaryValue> info(GetInfoForProfileAtIndex(index)->DeepCopy());
- info->SetBoolean(kIsManagedKey, value);
- // This takes ownership of |info|.
- SetInfoForProfileAtIndex(index, info.release());
-}
-
void ProfileInfoCache::SetProfileSigninRequiredAtIndex(size_t index,
bool value) {
if (value == ProfileIsSigninRequiredAtIndex(index))
diff --git a/chrome/browser/profiles/profile_info_cache.h b/chrome/browser/profiles/profile_info_cache.h
index 93c8511..d1c8b62 100644
--- a/chrome/browser/profiles/profile_info_cache.h
+++ b/chrome/browser/profiles/profile_info_cache.h
@@ -44,7 +44,7 @@ class ProfileInfoCache : public ProfileInfoInterface,
const string16& name,
const string16& username,
size_t icon_index,
- bool is_managed);
+ const std::string& managed_user_id);
void DeleteProfileFromCache(const base::FilePath& profile_path);
// ProfileInfoInterface:
@@ -76,6 +76,8 @@ class ProfileInfoCache : public ProfileInfoInterface,
size_t index) const OVERRIDE;
virtual bool ProfileIsManagedAtIndex(size_t index) const OVERRIDE;
virtual bool ProfileIsSigninRequiredAtIndex(size_t index) const OVERRIDE;
+ virtual std::string GetManagedUserIdOfProfileAtIndex(size_t index) const
+ OVERRIDE;
size_t GetAvatarIconIndexOfProfileAtIndex(size_t index) const;
@@ -83,13 +85,13 @@ class ProfileInfoCache : public ProfileInfoInterface,
void SetShortcutNameOfProfileAtIndex(size_t index, const string16& name);
void SetUserNameOfProfileAtIndex(size_t index, const string16& user_name);
void SetAvatarIconOfProfileAtIndex(size_t index, size_t icon_index);
+ void SetManagedUserIdOfProfileAtIndex(size_t index, const std::string& id);
void SetBackgroundStatusOfProfileAtIndex(size_t index,
bool running_background_apps);
void SetGAIANameOfProfileAtIndex(size_t index, const string16& name);
void SetIsUsingGAIANameOfProfileAtIndex(size_t index, bool value);
void SetGAIAPictureOfProfileAtIndex(size_t index, const gfx::Image* image);
void SetIsUsingGAIAPictureOfProfileAtIndex(size_t index, bool value);
- void SetProfileIsManagedAtIndex(size_t index, bool value);
void SetProfileSigninRequiredAtIndex(size_t index, bool value);
// Returns unique name that can be assigned to a newly created profile.
diff --git a/chrome/browser/profiles/profile_info_cache_unittest.cc b/chrome/browser/profiles/profile_info_cache_unittest.cc
index ee0c592..51e1fd45 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.cc
+++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
@@ -123,10 +123,10 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) {
const SkBitmap* icon = rb.GetImageNamed(
ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(
i)).ToSkBitmap();
- bool is_managed = i == 3;
+ std::string managed_user_id = i == 3 ? "TEST_ID" : "";
GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i,
- is_managed);
+ managed_user_id);
GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true);
string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i));
GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name);
@@ -138,7 +138,8 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) {
GetCache()->GetAvatarIconOfProfileAtIndex(i).ToSkBitmap();
EXPECT_EQ(icon->width(), actual_icon->width());
EXPECT_EQ(icon->height(), actual_icon->height());
- EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i));
+ EXPECT_EQ(i == 3, GetCache()->ProfileIsManagedAtIndex(i));
+ EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i));
}
// Reset the cache and test the it reloads correctly.
@@ -163,12 +164,12 @@ TEST_F(ProfileInfoCacheTest, DeleteProfile) {
base::FilePath path_1 = GetProfilePath("path_1");
GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), string16(),
- 0, false);
+ 0, std::string());
EXPECT_EQ(1u, GetCache()->GetNumberOfProfiles());
base::FilePath path_2 = GetProfilePath("path_2");
string16 name_2 = ASCIIToUTF16("name_2");
- GetCache()->AddProfileToCache(path_2, name_2, string16(), 0, false);
+ GetCache()->AddProfileToCache(path_2, name_2, string16(), 0, std::string());
EXPECT_EQ(2u, GetCache()->GetNumberOfProfiles());
GetCache()->DeleteProfileFromCache(path_1);
@@ -181,9 +182,11 @@ TEST_F(ProfileInfoCacheTest, DeleteProfile) {
TEST_F(ProfileInfoCacheTest, MutateProfile) {
GetCache()->AddProfileToCache(
- GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0, false);
+ GetProfilePath("path_1"), ASCIIToUTF16("name_1"),
+ string16(), 0, std::string());
GetCache()->AddProfileToCache(
- GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0, false);
+ GetProfilePath("path_2"), ASCIIToUTF16("name_2"),
+ string16(), 0, std::string());
string16 new_name = ASCIIToUTF16("new_name");
GetCache()->SetNameOfProfileAtIndex(1, new_name);
@@ -204,11 +207,11 @@ TEST_F(ProfileInfoCacheTest, MutateProfile) {
TEST_F(ProfileInfoCacheTest, Sort) {
string16 name_a = ASCIIToUTF16("apple");
GetCache()->AddProfileToCache(
- GetProfilePath("path_a"), name_a, string16(), 0, false);
+ GetProfilePath("path_a"), name_a, string16(), 0, std::string());
string16 name_c = ASCIIToUTF16("cat");
GetCache()->AddProfileToCache(
- GetProfilePath("path_c"), name_c, string16(), 0, false);
+ GetProfilePath("path_c"), name_c, string16(), 0, std::string());
// Sanity check the initial order.
EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0));
@@ -217,7 +220,7 @@ TEST_F(ProfileInfoCacheTest, Sort) {
// Add a new profile (start with a capital to test case insensitive sorting.
string16 name_b = ASCIIToUTF16("Banana");
GetCache()->AddProfileToCache(
- GetProfilePath("path_b"), name_b, string16(), 0, false);
+ GetProfilePath("path_b"), name_b, string16(), 0, std::string());
// Verify the new order.
EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0));
@@ -243,9 +246,11 @@ TEST_F(ProfileInfoCacheTest, Sort) {
TEST_F(ProfileInfoCacheTest, BackgroundModeStatus) {
GetCache()->AddProfileToCache(
- GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0, false);
+ GetProfilePath("path_1"), ASCIIToUTF16("name_1"),
+ string16(), 0, std::string());
GetCache()->AddProfileToCache(
- GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0, false);
+ GetProfilePath("path_2"), ASCIIToUTF16("name_2"),
+ string16(), 0, std::string());
EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
@@ -268,9 +273,11 @@ TEST_F(ProfileInfoCacheTest, BackgroundModeStatus) {
TEST_F(ProfileInfoCacheTest, HasMigrated) {
GetCache()->AddProfileToCache(
- GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0, false);
+ GetProfilePath("path_1"), ASCIIToUTF16("name_1"),
+ string16(), 0, std::string());
GetCache()->AddProfileToCache(
- GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0, false);
+ GetProfilePath("path_2"), ASCIIToUTF16("name_2"),
+ string16(), 0, std::string());
// Sanity check.
EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
@@ -294,10 +301,11 @@ TEST_F(ProfileInfoCacheTest, HasMigrated) {
TEST_F(ProfileInfoCacheTest, GAIAName) {
GetCache()->AddProfileToCache(
- GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0, false);
+ GetProfilePath("path_1"), ASCIIToUTF16("name_1"),
+ string16(), 0, std::string());
string16 profile_name(ASCIIToUTF16("profile name 2"));
GetCache()->AddProfileToCache(
- GetProfilePath("path_2"), profile_name, string16(), 0, false);
+ GetProfilePath("path_2"), profile_name, string16(), 0, std::string());
// Sanity check.
EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty());
@@ -326,9 +334,11 @@ TEST_F(ProfileInfoCacheTest, GAIAName) {
TEST_F(ProfileInfoCacheTest, GAIAPicture) {
GetCache()->AddProfileToCache(
- GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0, false);
+ GetProfilePath("path_1"), ASCIIToUTF16("name_1"),
+ string16(), 0, std::string());
GetCache()->AddProfileToCache(
- GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0, false);
+ GetProfilePath("path_2"), ASCIIToUTF16("name_2"),
+ string16(), 0, std::string());
// Sanity check.
EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
@@ -369,7 +379,8 @@ TEST_F(ProfileInfoCacheTest, GAIAPicture) {
TEST_F(ProfileInfoCacheTest, PersistGAIAPicture) {
GetCache()->AddProfileToCache(
- GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0, false);
+ GetProfilePath("path_1"), ASCIIToUTF16("name_1"),
+ string16(), 0, std::string());
gfx::Image gaia_image(gfx::test::CreateImage());
content::WindowedNotificationObserver save_observer(
@@ -394,19 +405,22 @@ TEST_F(ProfileInfoCacheTest, PersistGAIAPicture) {
gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(0)));
}
-TEST_F(ProfileInfoCacheTest, SetProfileIsManaged) {
+TEST_F(ProfileInfoCacheTest, SetManagedUserId) {
GetCache()->AddProfileToCache(
- GetProfilePath("test"), ASCIIToUTF16("Test"), string16(), 0, false);
+ GetProfilePath("test"), ASCIIToUTF16("Test"),
+ string16(), 0, std::string());
EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0));
- GetCache()->SetProfileIsManagedAtIndex(0, true);
+ GetCache()->SetManagedUserIdOfProfileAtIndex(0, "TEST_ID");
EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0));
+ EXPECT_EQ("TEST_ID", GetCache()->GetManagedUserIdOfProfileAtIndex(0));
ResetCache();
EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0));
- GetCache()->SetProfileIsManagedAtIndex(0, false);
+ GetCache()->SetManagedUserIdOfProfileAtIndex(0, std::string());
EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0));
+ EXPECT_EQ("", GetCache()->GetManagedUserIdOfProfileAtIndex(0));
}
TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) {
@@ -416,7 +430,7 @@ TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) {
ResourceBundle::GetSharedInstance().GetImageNamed(id));
GetCache()->AddProfileToCache(
- GetProfilePath("path_1"), profile_name, string16(), 0, false);
+ GetProfilePath("path_1"), profile_name, string16(), 0, std::string());
// Set empty GAIA info.
GetCache()->SetGAIANameOfProfileAtIndex(0, string16());
@@ -434,11 +448,14 @@ TEST_F(ProfileInfoCacheTest, CreateManagedTestingProfile) {
testing_profile_manager_.CreateTestingProfile("default");
string16 managed_user_name = ASCIIToUTF16("Supervised User");
testing_profile_manager_.CreateTestingProfile(
- "test1", scoped_ptr<PrefServiceSyncable>(), managed_user_name, 0, true);
+ "test1", scoped_ptr<PrefServiceSyncable>(),
+ managed_user_name, 0, "TEST_ID");
for (size_t i = 0; i < GetCache()->GetNumberOfProfiles(); i++) {
bool is_managed =
GetCache()->GetNameOfProfileAtIndex(i) == managed_user_name;
EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i));
+ std::string managed_user_id = is_managed ? "TEST_ID" : "";
+ EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i));
}
}
diff --git a/chrome/browser/profiles/profile_info_interface.h b/chrome/browser/profiles/profile_info_interface.h
index 0ed63ba..56f9180 100644
--- a/chrome/browser/profiles/profile_info_interface.h
+++ b/chrome/browser/profiles/profile_info_interface.h
@@ -51,6 +51,8 @@ class ProfileInfoInterface {
virtual bool ProfileIsManagedAtIndex(size_t index) const = 0;
+ virtual std::string GetManagedUserIdOfProfileAtIndex(size_t index) const = 0;
+
// This profile is associated with an account but has been signed-out.
virtual bool ProfileIsSigninRequiredAtIndex(size_t index) const = 0;
diff --git a/chrome/browser/profiles/profile_loader.cc b/chrome/browser/profiles/profile_loader.cc
index f7ada5e..4d2a6e6c 100644
--- a/chrome/browser/profiles/profile_loader.cc
+++ b/chrome/browser/profiles/profile_loader.cc
@@ -46,7 +46,7 @@ void ProfileLoader::LoadProfileInvalidatingOtherLoads(
weak_factory_.GetWeakPtr(),
profile_load_sequence_id_,
callback),
- string16(), string16(), false);
+ string16(), string16(), std::string());
}
Profile* ProfileLoader::GetProfileByPath(const base::FilePath& path) {
@@ -58,9 +58,9 @@ void ProfileLoader::CreateProfileAsync(
const ProfileManager::CreateCallback& callback,
const string16& name,
const string16& icon_url,
- bool is_managed) {
+ const std::string& managed_user_id) {
profile_manager_->CreateProfileAsync(
- profile_path, callback, name, icon_url, is_managed);
+ profile_path, callback, name, icon_url, managed_user_id);
}
void ProfileLoader::OnProfileLoaded(int profile_load_sequence_id,
diff --git a/chrome/browser/profiles/profile_loader.h b/chrome/browser/profiles/profile_loader.h
index b9b9038..72d9f17 100644
--- a/chrome/browser/profiles/profile_loader.h
+++ b/chrome/browser/profiles/profile_loader.h
@@ -42,7 +42,7 @@ class ProfileLoader {
const ProfileManager::CreateCallback& callback,
const string16& name,
const string16& icon_url,
- bool is_managed);
+ const std::string& managed_user_id);
private:
void OnProfileLoaded(int profile_load_sequence_id,
diff --git a/chrome/browser/profiles/profile_loader_unittest.cc b/chrome/browser/profiles/profile_loader_unittest.cc
index 3c3598b..6637ab9 100644
--- a/chrome/browser/profiles/profile_loader_unittest.cc
+++ b/chrome/browser/profiles/profile_loader_unittest.cc
@@ -34,7 +34,7 @@ class TestProfileLoader : public ProfileLoader {
const ProfileManager::CreateCallback&,
const string16&,
const string16&,
- bool));
+ const std::string&));
void SetCreateCallback(const base::FilePath& path,
const ProfileManager::CreateCallback& callback) {
@@ -82,7 +82,8 @@ TEST(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
// path_1 never loads.
EXPECT_CALL(loader, GetProfileByPath(fake_profile_path_1))
.WillRepeatedly(Return(static_cast<Profile*>(NULL)));
- EXPECT_CALL(loader, CreateProfileAsync(fake_profile_path_1, _, _, _, false))
+ EXPECT_CALL(loader,
+ CreateProfileAsync(fake_profile_path_1, _, _, _, std::string()))
.WillRepeatedly(WithArgs<0, 1>(
Invoke(&loader, &TestProfileLoader::SetCreateCallback)));
@@ -90,7 +91,8 @@ TEST(ProfileLoaderTest, LoadProfileInvalidatingOtherLoads) {
EXPECT_CALL(loader, GetProfileByPath(fake_profile_path_2))
.WillOnce(Return(static_cast<Profile*>(NULL)))
.WillRepeatedly(Return(&profile));
- EXPECT_CALL(loader, CreateProfileAsync(fake_profile_path_2, _, _, _, false))
+ EXPECT_CALL(loader,
+ CreateProfileAsync(fake_profile_path_2, _, _, _, std::string()))
.WillRepeatedly(WithArgs<0, 1>(
Invoke(&loader, &TestProfileLoader::SetCreateCallback)));
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 8c37948..2282013 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -476,7 +476,7 @@ void ProfileManager::CreateProfileAsync(
const CreateCallback& callback,
const string16& name,
const string16& icon_url,
- bool is_managed) {
+ const std::string& managed_user_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Make sure that this profile is not pending deletion.
@@ -502,10 +502,10 @@ void ProfileManager::CreateProfileAsync(
if (cache.IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) {
// add profile to cache with user selected name and avatar
cache.AddProfileToCache(profile_path, name, string16(), icon_index,
- is_managed);
+ managed_user_id);
}
- if (is_managed) {
+ if (!managed_user_id.empty()) {
content::RecordAction(
UserMetricsAction("ManagedMode_LocallyManagedUserCreated"));
}
@@ -540,7 +540,7 @@ void ProfileManager::CreateDefaultProfileAsync(const CreateCallback& callback) {
// On Chrome OS |is_managed| preference will get initialized in
// Profile::CREATE_STATUS_CREATED callback.
profile_manager->CreateProfileAsync(
- default_profile_dir, callback, string16(), string16(), false);
+ default_profile_dir, callback, string16(), string16(), std::string());
}
bool ProfileManager::AddProfile(Profile* profile) {
@@ -844,7 +844,7 @@ base::FilePath ProfileManager::CreateMultiProfileAsync(
const string16& name,
const string16& icon_url,
const CreateCallback& callback,
- bool is_managed) {
+ const std::string& managed_user_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
ProfileManager* profile_manager = g_browser_process->profile_manager();
@@ -855,7 +855,7 @@ base::FilePath ProfileManager::CreateMultiProfileAsync(
callback,
name,
icon_url,
- is_managed);
+ managed_user_id);
return new_path;
}
@@ -919,13 +919,14 @@ void ProfileManager::AddProfileToCache(Profile* profile) {
size_t icon_index = profile->GetPrefs()->GetInteger(
prefs::kProfileAvatarIndex);
- bool is_managed = profile->GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
+ std::string managed_user_id =
+ profile->GetPrefs()->GetString(prefs::kManagedUserId);
cache.AddProfileToCache(profile->GetPath(),
profile_name,
username,
icon_index,
- is_managed);
+ managed_user_id);
}
void ProfileManager::InitProfileUserPrefs(Profile* profile) {
@@ -937,6 +938,7 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) {
bool is_managed = false;
size_t avatar_index;
std::string profile_name;
+ std::string managed_user_id;
if (profile->IsGuestSession()) {
profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME);
avatar_index = 0;
@@ -950,6 +952,8 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) {
profile_name =
UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index));
is_managed = cache.ProfileIsManagedAtIndex(profile_cache_index);
+ managed_user_id =
+ cache.GetManagedUserIdOfProfileAtIndex(profile_cache_index);
} else if (profile->GetPath() ==
profiles::GetDefaultProfileDir(cache.GetUserDataDir())) {
avatar_index = 0;
@@ -968,6 +972,9 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) {
if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileIsManaged))
profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, is_managed);
+
+ if (!profile->GetPrefs()->HasPrefPath(prefs::kManagedUserId))
+ profile->GetPrefs()->SetString(prefs::kManagedUserId, managed_user_id);
}
bool ProfileManager::ShouldGoOffTheRecord(Profile* profile) {
@@ -1019,7 +1026,7 @@ void ProfileManager::ScheduleProfileForDeletion(
callback,
string16(),
string16(),
- false);
+ std::string());
} else {
// On the Mac, the browser process is not killed when all browser windows
// are closed, so just in case we are deleting the active profile, and no
@@ -1033,7 +1040,7 @@ void ProfileManager::ScheduleProfileForDeletion(
callback),
string16(),
string16(),
- false);
+ std::string());
return;
#else
// For OS_MACOSX the pref is updated in the callback to make sure that
diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h
index 459dfdd..5c2f8bb 100644
--- a/chrome/browser/profiles/profile_manager.h
+++ b/chrome/browser/profiles/profile_manager.h
@@ -85,7 +85,7 @@ class ProfileManager : public base::NonThreadSafe,
const CreateCallback& callback,
const string16& name,
const string16& icon_url,
- bool is_managed);
+ const std::string& managed_user_id);
// Initiates profile creation identified by |active_profile_username_hash_|.
// If profile has already been created then the callback is called
@@ -168,7 +168,7 @@ class ProfileManager : public base::NonThreadSafe,
const string16& name,
const string16& icon_url,
const CreateCallback& callback,
- bool is_managed);
+ const std::string& managed_user_id);
// Returns the full path to be used for guest profiles.
static base::FilePath GetGuestProfilePath();
diff --git a/chrome/browser/profiles/profile_manager_browsertest.cc b/chrome/browser/profiles/profile_manager_browsertest.cc
index 84c7279..cd9d8e8 100644
--- a/chrome/browser/profiles/profile_manager_browsertest.cc
+++ b/chrome/browser/profiles/profile_manager_browsertest.cc
@@ -124,7 +124,7 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DISABLED_DeleteAllProfiles) {
base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath();
profile_manager->CreateProfileAsync(new_path,
base::Bind(&OnUnblockOnProfileCreation),
- string16(), string16(), false);
+ string16(), string16(), std::string());
// Spin to allow profile creation to take place, loop is terminated
// by OnUnblockOnProfileCreation when the profile is created.
@@ -171,7 +171,7 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
string16(), // name
string16(), // icon url
base::Bind(ProfileCreationComplete),
- false);
+ std::string());
// Wait for profile to finish loading.
content::RunMessageLoop();
EXPECT_EQ(profile_manager->GetNumberOfProfiles(), 2U);
@@ -209,7 +209,7 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
profile_manager->GenerateNextProfileDirectoryPath();
profile_manager->CreateProfileAsync(path_profile2,
base::Bind(&OnUnblockOnProfileCreation),
- string16(), string16(), false);
+ string16(), string16(), std::string());
// Spin to allow profile creation to take place, loop is terminated
// by OnUnblockOnProfileCreation when the profile is created.
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 3b49eac..dd2417b 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -125,7 +125,7 @@ class ProfileManagerTest : public testing::Test {
base::Unretained(mock_observer)),
UTF8ToUTF16(name),
string16(),
- false);
+ std::string());
}
#if defined(OS_CHROMEOS)
@@ -319,11 +319,11 @@ TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) {
EXPECT_EQ(0u, cache.GetNumberOfProfiles());
cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"),
- ASCIIToUTF16("name_1"), string16(), 0, false);
+ ASCIIToUTF16("name_1"), string16(), 0, std::string());
cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_2"),
- ASCIIToUTF16("name_2"), string16(), 0, false);
+ ASCIIToUTF16("name_2"), string16(), 0, std::string());
cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_3"),
- ASCIIToUTF16("name_3"), string16(), 0, false);
+ ASCIIToUTF16("name_3"), string16(), 0, std::string());
cache.SetBackgroundStatusOfProfileAtIndex(0, true);
cache.SetBackgroundStatusOfProfileAtIndex(2, true);
EXPECT_EQ(3u, cache.GetNumberOfProfiles());
@@ -341,9 +341,9 @@ TEST_F(ProfileManagerTest, DoNotAutoloadProfilesIfBackgroundModeOff) {
EXPECT_EQ(0u, cache.GetNumberOfProfiles());
cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"),
- ASCIIToUTF16("name_1"), string16(), 0, false);
+ ASCIIToUTF16("name_1"), string16(), 0, std::string());
cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_2"),
- ASCIIToUTF16("name_2"), string16(), 0, false);
+ ASCIIToUTF16("name_2"), string16(), 0, std::string());
cache.SetBackgroundStatusOfProfileAtIndex(0, false);
cache.SetBackgroundStatusOfProfileAtIndex(1, true);
EXPECT_EQ(2u, cache.GetNumberOfProfiles());
@@ -684,7 +684,7 @@ TEST_F(ProfileManagerTest, ActiveProfileDeletedNeedsToLoadNextProfile) {
// Track the profile, but don't load it.
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
cache.AddProfileToCache(dest_path2, ASCIIToUTF16(profile_name2),
- string16(), 0, false);
+ string16(), 0, std::string());
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1u, profile_manager->GetLoadedProfiles().size());
@@ -737,9 +737,9 @@ TEST_F(ProfileManagerTest, ActiveProfileDeletedNextProfileDeletedToo) {
// and not randomly by the avatar name.
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
cache.AddProfileToCache(dest_path2, ASCIIToUTF16(profile_name2),
- ASCIIToUTF16(profile_name2), 1, false);
+ ASCIIToUTF16(profile_name2), 1, std::string());
cache.AddProfileToCache(dest_path3, ASCIIToUTF16(profile_name3),
- ASCIIToUTF16(profile_name3), 2, false);
+ ASCIIToUTF16(profile_name3), 2, std::string());
base::RunLoop().RunUntilIdle();
diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
index 4afb347..7dea610 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -97,7 +97,7 @@ class ProfileShortcutManagerTest : public testing::Test {
ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_))
<< location.ToString();
profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_,
- string16(), 0, false);
+ string16(), 0, std::string());
// Also create a non-badged shortcut for Chrome, which is conveniently done
// by |CreateProfileShortcut()| since there is only one profile.
profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_);
@@ -185,7 +185,7 @@ class ProfileShortcutManagerTest : public testing::Test {
ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name))
<< location.ToString();
profile_info_cache_->AddProfileToCache(profile_path, profile_name,
- string16(), 0, false);
+ string16(), 0, std::string());
profile_shortcut_manager_->CreateProfileShortcut(profile_path);
RunPendingTasks();
ValidateProfileShortcut(location, profile_name, profile_path);
@@ -358,7 +358,7 @@ TEST_F(ProfileShortcutManagerTest, CreateSecondProfileBadgesFirstShortcut) {
// Create a second profile without a shortcut.
profile_info_cache_->AddProfileToCache(profile_2_path_, profile_2_name_,
- string16(), 0, false);
+ string16(), 0, std::string());
RunPendingTasks();
// Ensure that the second profile doesn't have a shortcut and that the first
@@ -678,7 +678,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
// Create the initial profile.
profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_,
- string16(), 0, false);
+ string16(), 0, std::string());
RunPendingTasks();
ASSERT_EQ(1U, profile_info_cache_->GetNumberOfProfiles());
@@ -696,7 +696,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
// Create a third profile without a shortcut and ensure it doesn't get one.
profile_info_cache_->AddProfileToCache(profile_3_path_, profile_3_name_,
- string16(), 0, false);
+ string16(), 0, std::string());
RunPendingTasks();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_));
diff --git a/chrome/browser/profiles/profile_window.cc b/chrome/browser/profiles/profile_window.cc
index 5523087..ca60706 100644
--- a/chrome/browser/profiles/profile_window.cc
+++ b/chrome/browser/profiles/profile_window.cc
@@ -83,7 +83,7 @@ void SwitchToProfile(
desktop_type),
string16(),
string16(),
- false);
+ std::string());
}
} // namespace profiles
diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
index c36e23f..cf455ce 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
@@ -856,7 +856,7 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceShutdownTest,
temp_profile_dir_.path(),
base::Bind(&SafeBrowsingServiceShutdownTest::OnUnblockOnProfileCreation,
this),
- string16(), string16(), false);
+ string16(), string16(), std::string());
// Spin to allow profile creation to take place, loop is terminated
// by OnUnblockOnProfileCreation when the profile is created.
diff --git a/chrome/browser/signin/signin_names_io_thread_unittest.cc b/chrome/browser/signin/signin_names_io_thread_unittest.cc
index b340dd3..bf450fd 100644
--- a/chrome/browser/signin/signin_names_io_thread_unittest.cc
+++ b/chrome/browser/signin/signin_names_io_thread_unittest.cc
@@ -76,7 +76,7 @@ void SigninNamesOnIOThreadTest::AddNewProfile(const string16& name,
#else
const base::FilePath profile_dir = user_data_dir.Append(name);
#endif
- cache->AddProfileToCache(profile_dir, name, email, 0, false);
+ cache->AddProfileToCache(profile_dir, name, email, 0, std::string());
}
} // namespace
diff --git a/chrome/browser/signin/signin_promo.cc b/chrome/browser/signin/signin_promo.cc
index 311e860..d381e0d 100644
--- a/chrome/browser/signin/signin_promo.cc
+++ b/chrome/browser/signin/signin_promo.cc
@@ -104,7 +104,7 @@ bool ShouldShowPromo(Profile* profile) {
return false;
// Don't show for managed profiles.
- if (profile->GetPrefs()->GetBoolean(prefs::kProfileIsManaged))
+ if (profile->IsManaged())
return false;
// Display the signin promo if the user is not signed in.
diff --git a/chrome/browser/ui/app_list/app_list_controller_browsertest.cc b/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
index 6a7464e..e773383 100644
--- a/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
+++ b/chrome/browser/ui/app_list/app_list_controller_browsertest.cc
@@ -55,7 +55,7 @@ IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, SwitchAppListProfiles) {
temp_profile_dir_.path(),
base::Bind(&AppListControllerBrowserTest::OnProfileCreated,
this),
- string16(), string16(), false);
+ string16(), string16(), std::string());
content::RunMessageLoop(); // Will stop in OnProfileCreated().
AppListService* service = AppListService::Get();
diff --git a/chrome/browser/ui/bookmarks/bookmark_browsertest.cc b/chrome/browser/ui/bookmarks/bookmark_browsertest.cc
index 1998fec..2075814 100644
--- a/chrome/browser/ui/bookmarks/bookmark_browsertest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_browsertest.cc
@@ -107,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkBrowsertest, DISABLED_MultiProfile) {
ui_test_utils::BrowserAddedObserver observer;
g_browser_process->profile_manager()->CreateMultiProfileAsync(
- string16(), string16(), ProfileManager::CreateCallback(), false);
+ string16(), string16(), ProfileManager::CreateCallback(), std::string());
Browser* browser2 = observer.WaitForSingleNewBrowser();
BookmarkModel* bookmark_model2 = WaitForBookmarkModel(browser2->profile());
diff --git a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm
index 6c2dbd7..e91fb3b 100644
--- a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm
@@ -30,9 +30,9 @@ class AvatarMenuBubbleControllerTest : public CocoaTest {
ASSERT_TRUE(manager_.SetUp());
manager_.CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(),
- ASCIIToUTF16("Test 1"), 1, false);
+ ASCIIToUTF16("Test 1"), 1, std::string());
manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(),
- ASCIIToUTF16("Test 2"), 0, false);
+ ASCIIToUTF16("Test 2"), 0, std::string());
model_ = new AvatarMenuModel(manager_.profile_info_cache(), NULL, NULL);
@@ -121,7 +121,7 @@ TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) {
// Now create a new profile and notify the delegate.
manager()->CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(),
- ASCIIToUTF16("Test 3"), 0, false);
+ ASCIIToUTF16("Test 3"), 0, std::string());
// Testing the bridge is not worth the effort...
[controller() performLayout];
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
index 8ec94d1..ca1940b 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
@@ -210,7 +210,7 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
create_callback,
ASCIIToUTF16("avatar_test"),
string16(),
- false);
+ std::string());
run_loop.Run();
diff --git a/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm b/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm
index 879b1de..c95fe4c 100644
--- a/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm
@@ -249,7 +249,7 @@ TEST_F(ProfileMenuControllerTest, ManagedProfile) {
scoped_ptr<PrefServiceSyncable>(),
ASCIIToUTF16("Supervised User"),
0,
- true);
+ "TEST_ID");
BrowserList::SetLastActive(browser());
NSMenu* menu = [controller() menu];
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc
index 9b079ab..f89eae3 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -728,7 +728,8 @@ void StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
if (!profile) {
profile_manager->CreateProfileAsync(profile_path,
base::Bind(&StartupBrowserCreator::ProcessCommandLineOnProfileCreated,
- command_line, cur_dir), string16(), string16(), false);
+ command_line, cur_dir), string16(), string16(),
+ std::string());
return;
}
diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
index ebdc2d8..aebcbfac 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
@@ -776,7 +776,7 @@ TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadEmailAlreadyUsed) {
const base::FilePath& user_data_dir = cache->GetUserDataDir();
cache->AddProfileToCache(user_data_dir.Append(FILE_PATH_LITERAL("user")),
UTF8ToUTF16("user"),
- UTF8ToUTF16("user@gmail.com"), 0, false);
+ UTF8ToUTF16("user@gmail.com"), 0, std::string());
scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false));
EXPECT_EQ(OneClickSigninHelper::DONT_OFFER,
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
index 03ccb51..d037dab 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
@@ -228,7 +228,7 @@ void OneClickSigninSyncStarter::CreateNewSignedInProfile() {
UTF8ToUTF16(ProfileInfoCache::GetDefaultAvatarIconUrl(icon_index)),
base::Bind(&OneClickSigninSyncStarter::CompleteInitForNewProfile,
weak_pointer_factory_.GetWeakPtr(), desktop_type_),
- false);
+ std::string());
}
void OneClickSigninSyncStarter::CompleteInitForNewProfile(
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index 9108c19..3abbfcd 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -1129,10 +1129,15 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
weak_ptr_factory_.GetWeakPtr(), GetDesktopType(),
managed_user);
+ std::string managed_user_id;
if (managed_user && ManagedUserService::AreManagedUsersEnabled()) {
+ managed_user_id =
+ ManagedUserRegistrationUtility::GenerateNewManagedUserId();
callbacks.push_back(
base::Bind(&BrowserOptionsHandler::RegisterNewManagedUser,
- weak_ptr_factory_.GetWeakPtr(), show_user_feedback));
+ weak_ptr_factory_.GetWeakPtr(),
+ show_user_feedback,
+ managed_user_id));
} else {
callbacks.push_back(show_user_feedback);
}
@@ -1141,11 +1146,12 @@ void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
profile_path_being_created_ = ProfileManager::CreateMultiProfileAsync(
name, icon, base::Bind(&RunProfileCreationCallbacks, callbacks),
- managed_user);
+ managed_user_id);
}
void BrowserOptionsHandler::RegisterNewManagedUser(
const ProfileManager::CreateCallback& callback,
+ const std::string& managed_user_id,
Profile* new_profile,
Profile::CreateStatus status) {
DCHECK(profile_path_being_created_ == new_profile->GetPath());
@@ -1161,6 +1167,7 @@ void BrowserOptionsHandler::RegisterNewManagedUser(
managed_user_service->RegisterAndInitSync(
managed_user_registration_utility_.get(),
Profile::FromWebUI(web_ui()),
+ managed_user_id,
callback);
}
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.h b/chrome/browser/ui/webui/options/browser_options_handler.h
index 8c81951..5cd2007 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.h
+++ b/chrome/browser/ui/webui/options/browser_options_handler.h
@@ -159,6 +159,7 @@ class BrowserOptionsHandler
// class) still exists after the new managed profile has been created
// asynchronously.
void RegisterNewManagedUser(const ProfileManager::CreateCallback& callback,
+ const std::string& managed_user_id,
Profile* new_profile,
Profile::CreateStatus status);
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index cd66dcd..84189e1 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1245,6 +1245,9 @@ const char kProfileName[] = "profile.name";
// Whether the profile is managed.
const char kProfileIsManaged[] = "profile.is_managed";
+// The managed user ID.
+const char kManagedUserId[] = "profile.managed_user_id";
+
// Indicates if we've already shown a notification that high contrast
// mode is on, recommending high-contrast extensions and themes.
const char kInvertNotificationShown[] = "invert_notification_version_2_shown";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index bbf895c..f4ced8e 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -425,6 +425,7 @@ extern const char kPasswordsUseLocalProfileId[];
extern const char kProfileAvatarIndex[];
extern const char kProfileName[];
extern const char kProfileIsManaged[];
+extern const char kManagedUserId[];
extern const char kInvertNotificationShown[];
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 3d9511d..8ef15da 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -547,7 +547,8 @@ Profile* TestingProfile::GetOriginalProfile() {
}
bool TestingProfile::IsManaged() {
- return GetPrefs()->GetBoolean(prefs::kProfileIsManaged);
+ return GetPrefs()->GetBoolean(prefs::kProfileIsManaged) ||
+ !GetPrefs()->GetString(prefs::kManagedUserId).empty();
}
ExtensionService* TestingProfile::GetExtensionService() {
diff --git a/chrome/test/base/testing_profile_manager.cc b/chrome/test/base/testing_profile_manager.cc
index b0c6604..e6f4748 100644
--- a/chrome/test/base/testing_profile_manager.cc
+++ b/chrome/test/base/testing_profile_manager.cc
@@ -49,7 +49,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
scoped_ptr<PrefServiceSyncable> prefs,
const string16& user_name,
int avatar_id,
- bool is_managed) {
+ const std::string& managed_user_id) {
DCHECK(called_set_up_);
// Create a path for the profile based on the name.
@@ -68,7 +68,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
size_t index = cache.GetIndexOfProfileWithPath(profile_path);
cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
- cache.SetProfileIsManagedAtIndex(index, is_managed);
+ cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id);
// SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it
// last.
cache.SetNameOfProfileAtIndex(index, user_name);
@@ -82,7 +82,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
const std::string& name) {
DCHECK(called_set_up_);
return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(),
- UTF8ToUTF16(name), 0, false);
+ UTF8ToUTF16(name), 0, std::string());
}
void TestingProfileManager::DeleteTestingProfile(const std::string& name) {
diff --git a/chrome/test/base/testing_profile_manager.h b/chrome/test/base/testing_profile_manager.h
index 0e27dce..01f3317 100644
--- a/chrome/test/base/testing_profile_manager.h
+++ b/chrome/test/base/testing_profile_manager.h
@@ -43,7 +43,7 @@ class TestingProfileManager {
// profile_name, which is a non-user-visible key for the test environment.
// |prefs| is the PrefService used by the profile. If it is NULL, the profile
// creates a PrefService on demand.
- // |user_name|, |avatar_id| and |is_managed| are passed along to the
+ // |user_name|, |avatar_id| and |managed_user_id| are passed along to the
// ProfileInfoCache and provide the user-visible profile metadata. This will
// register the TestingProfile with the profile subsystem as well. The
// subsystem owns the Profile and returns a weak pointer.
@@ -51,7 +51,7 @@ class TestingProfileManager {
scoped_ptr<PrefServiceSyncable> prefs,
const string16& user_name,
int avatar_id,
- bool is_managed);
+ const std::string& managed_user_id);
// Small helper for creating testing profiles. Just forwards to above.
TestingProfile* CreateTestingProfile(const std::string& name);