| Index: chrome/test/base/testing_profile.cc
|
| diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
|
| index 8eb70633218dcbcb8c79b44dd88e4df0bb2a89f6..461036bb4b7de664918720d87b0065e598cc731d 100644
|
| --- a/chrome/test/base/testing_profile.cc
|
| +++ b/chrome/test/base/testing_profile.cc
|
| @@ -75,6 +75,7 @@
|
| #include "components/policy/core/common/schema.h"
|
| #include "components/prefs/testing_pref_store.h"
|
| #include "components/proxy_config/pref_proxy_config_tracker.h"
|
| +#include "components/syncable_prefs/pref_service_mock_factory.h"
|
| #include "components/syncable_prefs/pref_service_syncable.h"
|
| #include "components/syncable_prefs/testing_pref_service_syncable.h"
|
| #include "components/ui/zoom/zoom_event_manager.h"
|
| @@ -116,6 +117,7 @@
|
|
|
| #if defined(ENABLE_SUPERVISED_USERS)
|
| #include "chrome/browser/supervised_user/supervised_user_constants.h"
|
| +#include "chrome/browser/supervised_user/supervised_user_pref_store.h"
|
| #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
|
| #include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
|
| #endif
|
| @@ -330,6 +332,7 @@ TestingProfile::TestingProfile(
|
| force_incognito_(false),
|
| original_profile_(parent),
|
| guest_session_(guest_session),
|
| + supervised_user_id_(supervised_user_id),
|
| last_session_exited_cleanly_(true),
|
| #if defined(ENABLE_EXTENSIONS)
|
| extension_special_storage_policy_(extension_policy),
|
| @@ -419,10 +422,22 @@ void TestingProfile::Init() {
|
| ChromeBrowserMainExtraPartsProfiles::
|
| EnsureBrowserContextKeyedServiceFactoriesBuilt();
|
|
|
| +#if defined(ENABLE_SUPERVISED_USERS)
|
| + if (!IsOffTheRecord()) {
|
| + SupervisedUserSettingsService* settings_service =
|
| + SupervisedUserSettingsServiceFactory::GetForProfile(this);
|
| + TestingPrefStore* store = new TestingPrefStore();
|
| + settings_service->Init(store);
|
| + store->SetInitializationCompleted();
|
| + }
|
| +#endif
|
| +
|
| if (prefs_.get())
|
| user_prefs::UserPrefs::Set(this, prefs_.get());
|
| else if (IsOffTheRecord())
|
| CreateIncognitoPrefService();
|
| + else if (!supervised_user_id_.empty())
|
| + CreatePrefServiceForSupervisedUser();
|
| else
|
| CreateTestingPrefService();
|
|
|
| @@ -473,16 +488,6 @@ void TestingProfile::Init() {
|
|
|
| browser_context_dependency_manager_->CreateBrowserContextServicesForTest(
|
| this);
|
| -
|
| -#if defined(ENABLE_SUPERVISED_USERS)
|
| - if (!IsOffTheRecord()) {
|
| - SupervisedUserSettingsService* settings_service =
|
| - SupervisedUserSettingsServiceFactory::GetForProfile(this);
|
| - TestingPrefStore* store = new TestingPrefStore();
|
| - settings_service->Init(store);
|
| - store->SetInitializationCompleted();
|
| - }
|
| -#endif
|
| }
|
|
|
| void TestingProfile::FinishInit() {
|
| @@ -748,6 +753,25 @@ void TestingProfile::CreateTestingPrefService() {
|
| chrome::RegisterUserProfilePrefs(testing_prefs_->registry());
|
| }
|
|
|
| +void TestingProfile::CreatePrefServiceForSupervisedUser() {
|
| + DCHECK(!prefs_.get());
|
| + DCHECK(!supervised_user_id_.empty());
|
| + syncable_prefs::PrefServiceMockFactory factory;
|
| + SupervisedUserSettingsService* supervised_user_settings =
|
| + SupervisedUserSettingsServiceFactory::GetForProfile(this);
|
| + scoped_refptr<PrefStore> supervised_user_prefs =
|
| + make_scoped_refptr(new SupervisedUserPrefStore(supervised_user_settings));
|
| +
|
| + factory.set_supervised_user_prefs(supervised_user_prefs);
|
| +
|
| + scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
|
| + new user_prefs::PrefRegistrySyncable);
|
| +
|
| + prefs_ = factory.CreateSyncable(registry.get());
|
| + chrome::RegisterUserProfilePrefs(registry.get());
|
| + user_prefs::UserPrefs::Set(this, prefs_.get());
|
| +}
|
| +
|
| void TestingProfile::CreateIncognitoPrefService() {
|
| DCHECK(original_profile_);
|
| DCHECK(!testing_prefs_);
|
|
|