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

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: Fixing the build again! Created 4 years, 6 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
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_profile.cc
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 0302f2571c42fe7ae9921366fadf8d949e0a0db1..78fbd5e84d2dc4efb6a8dd960c0585440878ff54 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/user_prefs/user_prefs.h"
@@ -93,6 +94,8 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_test_util.h"
+#include "sync/api/fake_sync_change_processor.h"
+#include "sync/api/sync_error_factory_mock.h"
#include "testing/gmock/include/gmock/gmock.h"
#if defined(ENABLE_EXTENSIONS)
@@ -116,6 +119,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 +334,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 +424,29 @@ 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);
+ settings_service->MergeDataAndStartSyncing(
+ syncer::SUPERVISED_USER_SETTINGS, syncer::SyncDataList(),
+ std::unique_ptr<syncer::SyncChangeProcessor>(
+ new syncer::FakeSyncChangeProcessor),
+ std::unique_ptr<syncer::SyncErrorFactory>(
+ new syncer::SyncErrorFactoryMock));
+
+ 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 +497,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 +762,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_);
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | extensions/common/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698