1 // Copyright 2014 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.
5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_
6 #define COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_
10 #include "components/policy/core/browser/browser_policy_connector_base.h"
11 #include "components/policy/policy_export.h"
13 class PrefRegistrySimple
;
17 class URLRequestContextGetter
;
22 class DeviceManagementService
;
23 class PolicyStatisticsCollector
;
25 // The BrowserPolicyConnector keeps some shared components of the policy system.
26 // This is a basic implementation that gets extended by platform-specific
28 class POLICY_EXPORT BrowserPolicyConnector
: public BrowserPolicyConnectorBase
{
30 ~BrowserPolicyConnector() override
;
32 // Finalizes the initialization of the connector. This call can be skipped on
33 // tests that don't require the full policy system running.
35 PrefService
* local_state
,
36 scoped_refptr
<net::URLRequestContextGetter
> request_context
) = 0;
38 // Cleans up the connector before it can be safely deleted.
39 void Shutdown() override
;
41 // Schedules initialization of the cloud policy backend services, if the
42 // services are already constructed.
43 void ScheduleServiceInitialization(int64 delay_milliseconds
);
45 DeviceManagementService
* device_management_service() {
46 return device_management_service_
.get();
49 // Check whether a user is known to be non-enterprise. Domains such as
50 // gmail.com and googlemail.com are known to not be managed. Also returns
51 // false if the username is empty.
52 static bool IsNonEnterpriseUser(const std::string
& username
);
54 // Returns the URL for the device management service endpoint.
55 static std::string
GetDeviceManagementUrl();
57 // Registers refresh rate prefs.
58 static void RegisterPrefs(PrefRegistrySimple
* registry
);
61 // Builds an uninitialized BrowserPolicyConnector.
62 // Init() should be called to create and start the policy components.
63 explicit BrowserPolicyConnector(
64 const HandlerListFactory
& handler_list_factory
);
66 // Helper for the public Init() that must be called by subclasses.
68 PrefService
* local_state
,
69 scoped_ptr
<DeviceManagementService
> device_management_service
);
72 scoped_ptr
<PolicyStatisticsCollector
> policy_statistics_collector_
;
74 scoped_ptr
<DeviceManagementService
> device_management_service_
;
76 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector
);
81 #endif // COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_