summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 15:08:54 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 15:08:54 +0000
commit0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5 (patch)
treedee6e164bd71ecd8251501b28f25b6bb415848bf
parent163713eb87570157b91a3259f8846b74ee1d18cb (diff)
downloadchromium_src-0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5.zip
chromium_src-0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5.tar.gz
chromium_src-0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5.tar.bz2
[Mac] Disable the "Add new user" menu item for managed users.
Also disable the menu items for switching to a different user. Switching via the avatar menu is still possible. TBR=bartfab@chromium.org BUG=248948 TEST=Verify that the menu item for a managed user is disabled. Review URL: https://chromiumcodereview.appspot.com/17074006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214743 0039d316-1c4b-4281-b951-d872f2087c98
-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/profiles/avatar_menu_model_unittest.cc28
-rw-r--r--chrome/browser/profiles/profile_info_cache.cc7
-rw-r--r--chrome/browser/profiles/profile_info_cache.h1
-rw-r--r--chrome/browser/profiles/profile_info_cache_unittest.cc43
-rw-r--r--chrome/browser/profiles/profile_info_cache_unittest.h7
-rw-r--r--chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm6
-rw-r--r--chrome/browser/ui/cocoa/profile_menu_controller.mm26
-rw-r--r--chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm46
-rw-r--r--chrome/test/base/testing_profile_manager.cc10
-rw-r--r--chrome/test/base/testing_profile_manager.h11
12 files changed, 145 insertions, 46 deletions
diff --git a/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc b/chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc
index 664681e..f0e9477 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);
+ UTF8ToUTF16(chrome::kInitialProfile), 0, false);
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);
+ "user", prefs_owner_.Pass(), UTF8ToUTF16("user"), 0, false);
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 7c3d9df..af01f3a 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
@@ -87,7 +87,7 @@ class UserCloudPolicyManagerChromeOSTest : public testing::Test {
ASSERT_TRUE(profile_manager_->SetUp());
profile_ = profile_manager_->CreateTestingProfile(
chrome::kInitialProfile, scoped_ptr<PrefServiceSyncable>(),
- UTF8ToUTF16("testing_profile"), 0);
+ UTF8ToUTF16("testing_profile"), 0, false);
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/profiles/avatar_menu_model_unittest.cc b/chrome/browser/profiles/avatar_menu_model_unittest.cc
index 0a48e4a..c999931 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);
+ name1, 0, false);
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0);
+ name2, 0, false);
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);
+ name1, 0, false);
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0);
+ name2, 0, false);
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);
+ name1, 0, false);
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0);
+ name2, 0, false);
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);
+ name1, 0, false);
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0);
+ name2, 0, false);
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);
+ name3, 0, false);
// 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);
+ name1, 0, false);
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);
+ name2, 0, false);
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);
+ name1, 0, false);
manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(),
- name2, 0);
+ name2, 0, false);
#if defined(OS_CHROMEOS)
EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu());
@@ -240,7 +240,7 @@ TEST_F(AvatarMenuModelTest, SyncState) {
return;
manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(),
- ASCIIToUTF16("Test 1"), 0);
+ ASCIIToUTF16("Test 1"), 0, false);
// Add a managed user profile.
ProfileInfoCache* cache = manager()->profile_info_cache();
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index dfbc6e1..cc37007 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -613,6 +613,13 @@ 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 cf3aabb..93c8511 100644
--- a/chrome/browser/profiles/profile_info_cache.h
+++ b/chrome/browser/profiles/profile_info_cache.h
@@ -89,6 +89,7 @@ class ProfileInfoCache : public ProfileInfoInterface,
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 2dc49ea..ee0c592 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.cc
+++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
@@ -9,6 +9,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/base/testing_browser_process.h"
@@ -77,10 +78,7 @@ ProfileInfoCache* ProfileNameVerifierObserver::GetCache() {
}
ProfileInfoCacheTest::ProfileInfoCacheTest()
- : testing_profile_manager_(
- TestingBrowserProcess::GetGlobal()),
- ui_thread_(BrowserThread::UI, &ui_loop_),
- file_thread_(BrowserThread::FILE, &ui_loop_),
+ : testing_profile_manager_(TestingBrowserProcess::GetGlobal()),
name_observer_(&testing_profile_manager_) {
}
@@ -95,7 +93,7 @@ void ProfileInfoCacheTest::SetUp() {
void ProfileInfoCacheTest::TearDown() {
// Drain the UI thread to make sure all tasks are completed. This prevents
// memory leaks.
- ui_loop_.RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
ProfileInfoCache* ProfileInfoCacheTest::GetCache() {
@@ -125,9 +123,10 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) {
const SkBitmap* icon = rb.GetImageNamed(
ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(
i)).ToSkBitmap();
+ bool is_managed = i == 3;
GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i,
- false);
+ is_managed);
GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true);
string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i));
GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name);
@@ -135,10 +134,11 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) {
EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles());
EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i));
- const SkBitmap* actual_icon = GetCache()->GetAvatarIconOfProfileAtIndex(
- i).ToSkBitmap();
+ const SkBitmap* actual_icon =
+ 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));
}
// Reset the cache and test the it reloads correctly.
@@ -394,6 +394,21 @@ TEST_F(ProfileInfoCacheTest, PersistGAIAPicture) {
gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(0)));
}
+TEST_F(ProfileInfoCacheTest, SetProfileIsManaged) {
+ GetCache()->AddProfileToCache(
+ GetProfilePath("test"), ASCIIToUTF16("Test"), string16(), 0, false);
+ EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0));
+
+ GetCache()->SetProfileIsManagedAtIndex(0, true);
+ EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0));
+
+ ResetCache();
+ EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0));
+
+ GetCache()->SetProfileIsManagedAtIndex(0, false);
+ EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0));
+}
+
TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) {
string16 profile_name = ASCIIToUTF16("name_1");
int id = ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(0);
@@ -415,4 +430,16 @@ TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) {
profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0)));
}
+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);
+ 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));
+ }
+}
+
} // namespace
diff --git a/chrome/browser/profiles/profile_info_cache_unittest.h b/chrome/browser/profiles/profile_info_cache_unittest.h
index 7bddb77..2a16395 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.h
+++ b/chrome/browser/profiles/profile_info_cache_unittest.h
@@ -7,10 +7,9 @@
#include <set>
-#include "base/message_loop/message_loop.h"
#include "chrome/browser/profiles/profile_info_cache_observer.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
class ProfileInfoCache;
@@ -62,9 +61,7 @@ class ProfileInfoCacheTest : public testing::Test {
TestingProfileManager testing_profile_manager_;
private:
- base::MessageLoopForUI ui_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_thread_;
+ content::TestBrowserThreadBundle thread_bundle_;
ProfileNameVerifierObserver name_observer_;
};
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 b80a2a8..6c2dbd7 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);
+ ASCIIToUTF16("Test 1"), 1, false);
manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(),
- ASCIIToUTF16("Test 2"), 0);
+ ASCIIToUTF16("Test 2"), 0, false);
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);
+ ASCIIToUTF16("Test 3"), 0, false);
// Testing the bridge is not worth the effort...
[controller() performLayout];
diff --git a/chrome/browser/ui/cocoa/profile_menu_controller.mm b/chrome/browser/ui/cocoa/profile_menu_controller.mm
index f1ee54e..cdccc9e 100644
--- a/chrome/browser/ui/cocoa/profile_menu_controller.mm
+++ b/chrome/browser/ui/cocoa/profile_menu_controller.mm
@@ -138,6 +138,25 @@ class Observer : public chrome::BrowserListObserver,
return YES;
}
+- (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
+ size_t activeProfileIndex = model_->GetActiveProfileIndex();
+ ProfileInfoCache* cache =
+ &g_browser_process->profile_manager()->GetProfileInfoCache();
+ BOOL profileIsManaged = cache->ProfileIsManagedAtIndex(activeProfileIndex);
+ if ([menuItem action] == @selector(switchToProfileFromDock:) ||
+ [menuItem action] == @selector(switchToProfileFromMenu:)) {
+ if (!profileIsManaged)
+ return YES;
+
+ return [menuItem tag] == static_cast<NSInteger>(activeProfileIndex);
+ }
+
+ if ([menuItem action] == @selector(newProfile:))
+ return !profileIsManaged;
+
+ return YES;
+}
+
// Private /////////////////////////////////////////////////////////////////////
- (NSMenu*)menu {
@@ -153,10 +172,9 @@ class Observer : public chrome::BrowserListObserver,
[[self menu] addItem:[NSMenuItem separatorItem]];
- NSMenuItem* item =
- [self createItemWithTitle:l10n_util::GetNSStringWithFixup(
- IDS_PROFILES_CUSTOMIZE_PROFILE)
- action:@selector(editProfile:)];
+ NSMenuItem* item = [self createItemWithTitle:
+ l10n_util::GetNSStringWithFixup(IDS_PROFILES_CUSTOMIZE_PROFILE)
+ action:@selector(editProfile:)];
[[self menu] addItem:item];
[[self menu] addItem:[NSMenuItem separatorItem]];
diff --git a/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm b/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm
index a0b001c..879b1de 100644
--- a/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm
@@ -5,8 +5,9 @@
#import "chrome/browser/ui/cocoa/profile_menu_controller.h"
#include "base/mac/scoped_nsobject.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
-#include "chrome/browser/profiles/avatar_menu_model.h"
+#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
@@ -241,3 +242,46 @@ TEST_F(ProfileMenuControllerTest, DeleteActiveProfile) {
base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
}
+TEST_F(ProfileMenuControllerTest, ManagedProfile) {
+ TestingProfileManager* manager = testing_profile_manager();
+ TestingProfile* managed_profile =
+ manager->CreateTestingProfile("test1",
+ scoped_ptr<PrefServiceSyncable>(),
+ ASCIIToUTF16("Supervised User"),
+ 0,
+ true);
+ BrowserList::SetLastActive(browser());
+
+ NSMenu* menu = [controller() menu];
+ ASSERT_EQ(6, [menu numberOfItems]);
+ NSMenuItem* item = [menu itemAtIndex:0];
+ ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]);
+ EXPECT_TRUE([controller() validateMenuItem:item]);
+
+ item = [menu itemAtIndex:1];
+ ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]);
+ EXPECT_TRUE([controller() validateMenuItem:item]);
+
+ item = [menu itemAtIndex:5];
+ ASSERT_EQ(@selector(newProfile:), [item action]);
+ EXPECT_TRUE([controller() validateMenuItem:item]);
+
+ // Open a new browser for the managed user and switch to it.
+ Browser::CreateParams managed_profile_params(
+ managed_profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
+ scoped_ptr<Browser> managed_browser(
+ chrome::CreateBrowserWithTestWindowForParams(&managed_profile_params));
+ BrowserList::SetLastActive(managed_browser.get());
+
+ item = [menu itemAtIndex:0];
+ ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]);
+ EXPECT_FALSE([controller() validateMenuItem:item]);
+
+ item = [menu itemAtIndex:1];
+ ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]);
+ EXPECT_TRUE([controller() validateMenuItem:item]);
+
+ item = [menu itemAtIndex:5];
+ ASSERT_EQ(@selector(newProfile:), [item action]);
+ EXPECT_FALSE([controller() validateMenuItem:item]);
+}
diff --git a/chrome/test/base/testing_profile_manager.cc b/chrome/test/base/testing_profile_manager.cc
index 44bb0b5..b0c6604 100644
--- a/chrome/test/base/testing_profile_manager.cc
+++ b/chrome/test/base/testing_profile_manager.cc
@@ -48,7 +48,8 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
const std::string& profile_name,
scoped_ptr<PrefServiceSyncable> prefs,
const string16& user_name,
- int avatar_id) {
+ int avatar_id,
+ bool is_managed) {
DCHECK(called_set_up_);
// Create a path for the profile based on the name.
@@ -66,8 +67,11 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
// Update the user metadata.
ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
size_t index = cache.GetIndexOfProfileWithPath(profile_path);
- cache.SetNameOfProfileAtIndex(index, user_name);
cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
+ cache.SetProfileIsManagedAtIndex(index, is_managed);
+ // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it
+ // last.
+ cache.SetNameOfProfileAtIndex(index, user_name);
testing_profiles_.insert(std::make_pair(profile_name, profile));
@@ -78,7 +82,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
const std::string& name) {
DCHECK(called_set_up_);
return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(),
- UTF8ToUTF16(name), 0);
+ UTF8ToUTF16(name), 0, false);
}
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 99d7458..0e27dce 100644
--- a/chrome/test/base/testing_profile_manager.h
+++ b/chrome/test/base/testing_profile_manager.h
@@ -43,14 +43,15 @@ 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| and |avatar_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.
+ // |user_name|, |avatar_id| and |is_managed| 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.
TestingProfile* CreateTestingProfile(const std::string& profile_name,
scoped_ptr<PrefServiceSyncable> prefs,
const string16& user_name,
- int avatar_id);
+ int avatar_id,
+ bool is_managed);
// Small helper for creating testing profiles. Just forwards to above.
TestingProfile* CreateTestingProfile(const std::string& name);