blob: 1730b4a3f78f252b38285e4a15888c2bafad484a [file] [log] [blame]
// Copyright 2014 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 <stdint.h>
#include <string>
#include "base/macros.h"
#include "components/policy/core/browser/browser_policy_connector_base.h"
#include "components/policy/policy_export.h"
class PrefRegistrySimple;
class PrefService;
namespace net {
class URLRequestContextGetter;
namespace policy {
class DeviceManagementService;
class PolicyStatisticsCollector;
// The BrowserPolicyConnector keeps some shared components of the policy system.
// This is a basic implementation that gets extended by platform-specific
// subclasses.
class POLICY_EXPORT BrowserPolicyConnector : public BrowserPolicyConnectorBase {
~BrowserPolicyConnector() override;
// Finalizes the initialization of the connector. This call can be skipped on
// tests that don't require the full policy system running.
virtual void Init(
PrefService* local_state,
scoped_refptr<net::URLRequestContextGetter> request_context) = 0;
// Cleans up the connector before it can be safely deleted.
void Shutdown() override;
// Schedules initialization of the cloud policy backend services, if the
// services are already constructed.
void ScheduleServiceInitialization(int64_t delay_milliseconds);
DeviceManagementService* device_management_service() {
return device_management_service_.get();
// Check whether a user is known to be non-enterprise. Domains such as
// and are known to not be managed. Also returns
// false if the username is empty.
static bool IsNonEnterpriseUser(const std::string& username);
// Returns the URL for the device management service endpoint.
static std::string GetDeviceManagementUrl();
// Registers refresh rate prefs.
static void RegisterPrefs(PrefRegistrySimple* registry);
// Builds an uninitialized BrowserPolicyConnector.
// Init() should be called to create and start the policy components.
explicit BrowserPolicyConnector(
const HandlerListFactory& handler_list_factory);
// Helper for the public Init() that must be called by subclasses.
void InitInternal(
PrefService* local_state,
std::unique_ptr<DeviceManagementService> device_management_service);
std::unique_ptr<PolicyStatisticsCollector> policy_statistics_collector_;
std::unique_ptr<DeviceManagementService> device_management_service_;
} // namespace policy