Commit ef56e36a authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Integrate supervised users sync datatypes in pseudo-USS

This is part of a patch series where we leverage the recently introduced
layer that allows integrating legacy SyncableService implementations
within the newest architecture, USS. This requires forking custom
controllers because a different class hierarchy is used.

Bug: 870624
Change-Id: I0931243109eef8f757692c5a932f03004f8ce039
Reviewed-on: https://chromium-review.googlesource.com/1254211
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595771}
parent fb08d63c
...@@ -4406,6 +4406,8 @@ jumbo_split_static_library("browser") { ...@@ -4406,6 +4406,8 @@ jumbo_split_static_library("browser") {
"supervised_user/supervised_user_site_list.h", "supervised_user/supervised_user_site_list.h",
"supervised_user/supervised_user_sync_data_type_controller.cc", "supervised_user/supervised_user_sync_data_type_controller.cc",
"supervised_user/supervised_user_sync_data_type_controller.h", "supervised_user/supervised_user_sync_data_type_controller.h",
"supervised_user/supervised_user_sync_model_type_controller.cc",
"supervised_user/supervised_user_sync_model_type_controller.h",
"supervised_user/supervised_user_url_filter.cc", "supervised_user/supervised_user_url_filter.cc",
"supervised_user/supervised_user_url_filter.h", "supervised_user/supervised_user_url_filter.h",
"supervised_user/supervised_user_whitelist_service.cc", "supervised_user/supervised_user_whitelist_service.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/supervised_user/supervised_user_sync_model_type_controller.h"
#include "base/bind.h"
#include "chrome/browser/profiles/profile.h"
#include "components/sync/driver/sync_client.h"
#include "components/sync/model/model_type_store_service.h"
SupervisedUserSyncModelTypeController::SupervisedUserSyncModelTypeController(
syncer::ModelType type,
const Profile* profile,
syncer::SyncClient* sync_client)
: SyncableServiceBasedModelTypeController(
type,
sync_client->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client),
type)),
profile_(profile) {
DCHECK(type == syncer::SUPERVISED_USER_SETTINGS ||
type == syncer::SUPERVISED_USER_WHITELISTS);
}
SupervisedUserSyncModelTypeController::
~SupervisedUserSyncModelTypeController() {}
bool SupervisedUserSyncModelTypeController::ReadyForStart() const {
DCHECK(CalledOnValidThread());
return profile_->IsSupervised();
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_MODEL_TYPE_CONTROLLER_H_
#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_MODEL_TYPE_CONTROLLER_H_
#include "base/macros.h"
#include "components/sync/driver/syncable_service_based_model_type_controller.h"
class Profile;
namespace syncer {
class SyncClient;
}
// A DataTypeController for supervised user sync datatypes, which enables or
// disables these types based on the profile's IsSupervised state.
class SupervisedUserSyncModelTypeController
: public syncer::SyncableServiceBasedModelTypeController {
public:
// |sync_client| and |profile| must not be null and must outlive this object.
SupervisedUserSyncModelTypeController(syncer::ModelType type,
const Profile* profile,
syncer::SyncClient* sync_client);
~SupervisedUserSyncModelTypeController() override;
// DataTypeController override.
bool ReadyForStart() const override;
private:
const Profile* const profile_;
DISALLOW_COPY_AND_ASSIGN(SupervisedUserSyncModelTypeController);
};
#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_SYNC_MODEL_TYPE_CONTROLLER_H_
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
#include "chrome/browser/supervised_user/supervised_user_settings_service.h" #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h" #include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#include "chrome/browser/supervised_user/supervised_user_sync_data_type_controller.h" #include "chrome/browser/supervised_user/supervised_user_sync_data_type_controller.h"
#include "chrome/browser/supervised_user/supervised_user_sync_model_type_controller.h"
#include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h"
#endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS)
...@@ -290,10 +291,22 @@ ChromeSyncClient::CreateDataTypeControllers( ...@@ -290,10 +291,22 @@ ChromeSyncClient::CreateDataTypeControllers(
&syncer::ReportUnrecoverableError, chrome::GetChannel()); &syncer::ReportUnrecoverableError, chrome::GetChannel());
#if BUILDFLAG(ENABLE_SUPERVISED_USERS) #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
controllers.push_back(std::make_unique<SupervisedUserSyncDataTypeController>( if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSSupervisedUsers)) {
syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_)); controllers.push_back(
controllers.push_back(std::make_unique<SupervisedUserSyncDataTypeController>( std::make_unique<SupervisedUserSyncModelTypeController>(
syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); syncer::SUPERVISED_USER_SETTINGS, profile_, this));
controllers.push_back(
std::make_unique<SupervisedUserSyncModelTypeController>(
syncer::SUPERVISED_USER_WHITELISTS, profile_, this));
} else {
controllers.push_back(
std::make_unique<SupervisedUserSyncDataTypeController>(
syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_));
controllers.push_back(
std::make_unique<SupervisedUserSyncDataTypeController>(
syncer::SUPERVISED_USER_WHITELISTS, error_callback, this,
profile_));
}
#endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS)
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
......
...@@ -64,6 +64,8 @@ const base::Feature kSyncPseudoUSSPreferences{ ...@@ -64,6 +64,8 @@ const base::Feature kSyncPseudoUSSPreferences{
"SyncPseudoUSSPreferences", base::FEATURE_DISABLED_BY_DEFAULT}; "SyncPseudoUSSPreferences", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSPriorityPreferences{ const base::Feature kSyncPseudoUSSPriorityPreferences{
"SyncPseudoUSSPriorityPreferences", base::FEATURE_DISABLED_BY_DEFAULT}; "SyncPseudoUSSPriorityPreferences", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSSupervisedUsers{
"SyncPseudoUSSSupervisedUsers", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSThemes{"SyncPseudoUSSThemes", const base::Feature kSyncPseudoUSSThemes{"SyncPseudoUSSThemes",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -31,6 +31,7 @@ extern const base::Feature kSyncPseudoUSSFavicons; ...@@ -31,6 +31,7 @@ extern const base::Feature kSyncPseudoUSSFavicons;
extern const base::Feature kSyncPseudoUSSHistoryDeleteDirectives; extern const base::Feature kSyncPseudoUSSHistoryDeleteDirectives;
extern const base::Feature kSyncPseudoUSSPreferences; extern const base::Feature kSyncPseudoUSSPreferences;
extern const base::Feature kSyncPseudoUSSPriorityPreferences; extern const base::Feature kSyncPseudoUSSPriorityPreferences;
extern const base::Feature kSyncPseudoUSSSupervisedUsers;
extern const base::Feature kSyncPseudoUSSThemes; extern const base::Feature kSyncPseudoUSSThemes;
extern const base::Feature kSyncStandaloneTransport; extern const base::Feature kSyncStandaloneTransport;
extern const base::Feature kSyncSupportSecondaryAccount; extern const base::Feature kSyncSupportSecondaryAccount;
......
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