1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/supervised_user/supervised_user_sync_model_type_controller.h"
6
7 #include "base/bind.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "components/sync/model/model_type_store_service.h"
10
SupervisedUserSyncModelTypeController(syncer::ModelType type,const Profile * profile,const base::RepeatingClosure & dump_stack,syncer::OnceModelTypeStoreFactory store_factory,base::WeakPtr<syncer::SyncableService> syncable_service)11 SupervisedUserSyncModelTypeController::SupervisedUserSyncModelTypeController(
12 syncer::ModelType type,
13 const Profile* profile,
14 const base::RepeatingClosure& dump_stack,
15 syncer::OnceModelTypeStoreFactory store_factory,
16 base::WeakPtr<syncer::SyncableService> syncable_service)
17 : SyncableServiceBasedModelTypeController(
18 type,
19 std::move(store_factory),
20 syncable_service,
21 dump_stack,
22 DelegateMode::kTransportModeWithSingleModel),
23 profile_(profile) {
24 DCHECK(type == syncer::SUPERVISED_USER_SETTINGS ||
25 type == syncer::SUPERVISED_USER_ALLOWLISTS);
26 }
27
28 SupervisedUserSyncModelTypeController::
29 ~SupervisedUserSyncModelTypeController() = default;
30
31 syncer::DataTypeController::PreconditionState
GetPreconditionState() const32 SupervisedUserSyncModelTypeController::GetPreconditionState() const {
33 DCHECK(CalledOnValidThread());
34 return profile_->IsSupervised() ? PreconditionState::kPreconditionsMet
35 : PreconditionState::kMustStopAndClearData;
36 }
37