Commit ce01914d authored by bauerb@chromium.org's avatar bauerb@chromium.org

Initialize ManagedUserService after ExtensionSystem to register as extension...

Initialize ManagedUserService after ExtensionSystem to register as extension management policy provider.


BUG=169819


Review URL: https://chromiumcodereview.appspot.com/12225051

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181949 0039d316-1c4b-4281-b951-d872f2087c98
parent 10cf237d
...@@ -88,7 +88,6 @@ void ManagedUserService::URLFilterContext::SetManualURLs( ...@@ -88,7 +88,6 @@ void ManagedUserService::URLFilterContext::SetManualURLs(
ManagedUserService::ManagedUserService(Profile* profile) ManagedUserService::ManagedUserService(Profile* profile)
: profile_(profile), : profile_(profile),
is_elevated_(false) { is_elevated_(false) {
Init();
} }
ManagedUserService::~ManagedUserService() { ManagedUserService::~ManagedUserService() {
......
...@@ -79,12 +79,10 @@ class ManagedUserService : public ProfileKeyedService, ...@@ -79,12 +79,10 @@ class ManagedUserService : public ProfileKeyedService,
void SetElevatedForTesting(bool is_elevated); void SetElevatedForTesting(bool is_elevated);
// Initializes this object. This method does nothing if the profile is not // Initializes this object. This method does nothing if the profile is not
// managed. This method only needs to be called if the profile is set to be // managed.
// managed after the ManagedUserService has been created (which happens when
// creating a new profile).
void Init(); void Init();
// ExtensionManagementPolicy::Provider implementation: // extensions::ManagementPolicy::Provider implementation:
virtual std::string GetDebugPolicyProviderName() const OVERRIDE; virtual std::string GetDebugPolicyProviderName() const OVERRIDE;
virtual bool UserMayLoad(const extensions::Extension* extension, virtual bool UserMayLoad(const extensions::Extension* extension,
string16* error) const OVERRIDE; string16* error) const OVERRIDE;
......
...@@ -75,6 +75,7 @@ TEST(ManagedUserServiceTest, ExtensionManagementPolicyProvider) { ...@@ -75,6 +75,7 @@ TEST(ManagedUserServiceTest, ExtensionManagementPolicyProvider) {
ManagedModeURLFilterObserver observer( ManagedModeURLFilterObserver observer(
managed_user_service.GetURLFilterForUIThread()); managed_user_service.GetURLFilterForUIThread());
EXPECT_TRUE(managed_user_service.ProfileIsManaged()); EXPECT_TRUE(managed_user_service.ProfileIsManaged());
managed_user_service.Init();
string16 error_1; string16 error_1;
EXPECT_FALSE(managed_user_service.UserMayLoad(NULL, &error_1)); EXPECT_FALSE(managed_user_service.UserMayLoad(NULL, &error_1));
...@@ -111,6 +112,7 @@ class ManagedUserServiceExtensionTest : public ExtensionServiceTestBase { ...@@ -111,6 +112,7 @@ class ManagedUserServiceExtensionTest : public ExtensionServiceTestBase {
TEST_F(ManagedUserServiceExtensionTest, NoContentPacks) { TEST_F(ManagedUserServiceExtensionTest, NoContentPacks) {
ManagedUserService managed_user_service(profile_.get()); ManagedUserService managed_user_service(profile_.get());
managed_user_service.Init();
ManagedModeURLFilter* url_filter = ManagedModeURLFilter* url_filter =
managed_user_service.GetURLFilterForUIThread(); managed_user_service.GetURLFilterForUIThread();
...@@ -125,6 +127,7 @@ TEST_F(ManagedUserServiceExtensionTest, NoContentPacks) { ...@@ -125,6 +127,7 @@ TEST_F(ManagedUserServiceExtensionTest, NoContentPacks) {
TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) { TEST_F(ManagedUserServiceExtensionTest, InstallContentPacks) {
profile_->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); profile_->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true);
ManagedUserService managed_user_service(profile_.get()); ManagedUserService managed_user_service(profile_.get());
managed_user_service.Init();
managed_user_service.SetElevatedForTesting(true); managed_user_service.SetElevatedForTesting(true);
ManagedModeURLFilter* url_filter = ManagedModeURLFilter* url_filter =
managed_user_service.GetURLFilterForUIThread(); managed_user_service.GetURLFilterForUIThread();
......
...@@ -728,8 +728,8 @@ void ProfileManager::BrowserListObserver::OnBrowserSetLastActive( ...@@ -728,8 +728,8 @@ void ProfileManager::BrowserListObserver::OnBrowserSetLastActive(
#endif // !defined(OS_ANDROID) && !defined(OS_IOS) #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) { void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) {
DoFinalInitForServices(profile, go_off_the_record);
InitProfileUserPrefs(profile); InitProfileUserPrefs(profile);
DoFinalInitForServices(profile, go_off_the_record);
AddProfileToCache(profile); AddProfileToCache(profile);
DoFinalInitLogging(profile); DoFinalInitLogging(profile);
...@@ -756,6 +756,12 @@ void ProfileManager::DoFinalInitForServices(Profile* profile, ...@@ -756,6 +756,12 @@ void ProfileManager::DoFinalInitForServices(Profile* profile,
} }
} }
#endif #endif
#if defined(ENABLE_MANAGED_USERS)
// Initialization needs to happen after extension system initialization (for
// extension::ManagementPolicy) and InitProfileUserPrefs (for setting the
// initializing the managed flag if necessary).
ManagedUserServiceFactory::GetForProfile(profile)->Init();
#endif
} }
void ProfileManager::DoFinalInitLogging(Profile* profile) { void ProfileManager::DoFinalInitLogging(Profile* profile) {
...@@ -964,14 +970,8 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) { ...@@ -964,14 +970,8 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) {
if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName))
profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); profile->GetPrefs()->SetString(prefs::kProfileName, profile_name);
if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileIsManaged)) { if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileIsManaged))
profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, is_managed); profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, is_managed);
#if defined(ENABLE_MANAGED_USERS)
ManagedUserServiceFactory::GetForProfile(profile)->Init();
#else
DCHECK(!is_managed);
#endif
}
} }
bool ProfileManager::ShouldGoOffTheRecord() { bool ProfileManager::ShouldGoOffTheRecord() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment