// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/policy/model/profile_policy_connector_factory.h"

#import "base/check.h"
#import "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#import "ios/chrome/browser/policy/model/profile_policy_connector.h"

std::unique_ptr<ProfilePolicyConnector> BuildProfilePolicyConnector(
    policy::SchemaRegistry* schema_registry,
    BrowserPolicyConnectorIOS* browser_policy_connector,
    policy::UserCloudPolicyManager* user_policy_manager,
    policy::CloudPolicyStore* policy_store) {
  auto connector = std::make_unique<ProfilePolicyConnector>();

  // Since extensions are not supported on iOS, the `schema_registry` here has
  // the same registered components as the registry owned by
  // `browser_policy_connector`, despite being a separate instance. The two
  // levels of registry (owned by ApplicationContext vs owned by BrowserState)
  // are maintained to keep a parallel structure with Desktop.
  connector->Init(schema_registry, browser_policy_connector,
                  user_policy_manager, policy_store);
  return connector;
}
