Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1793)

Unified Diff: chrome/test/base/testing_profile.cc

Issue 2004043002: Supervised Users Initiated Installs v2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kid_initiated_install
Patch Set: minor Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..540fbd5ebd1a05acb5d1310403cfc53fd38d057e 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)
Marc Treib 2016/05/24 09:54:58 Is it necessary to move this up here? It used to h
mamir 2016/06/03 09:45:55 Yes, it is. Because CreatePrefServiceForSupervised
Marc Treib 2016/06/03 13:24:13 And moving all the PrefService stuff down, after t
mamir 2016/06/06 15:01:36 I checked but couldn't be 100% sure whether it cau
Marc Treib 2016/06/07 10:27:03 Acknowledged.
+ 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_);

Powered by Google App Engine
This is Rietveld 408576698