Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / policy / core / browser / browser_policy_connector.h
blob439eb42928f400c70d8d61e05f48054543ab301b
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_
8 #include <string>
10 #include "components/policy/core/browser/browser_policy_connector_base.h"
11 #include "components/policy/policy_export.h"
13 class PrefRegistrySimple;
14 class PrefService;
16 namespace net {
17 class URLRequestContextGetter;
20 namespace policy {
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
27 // subclasses.
28 class POLICY_EXPORT BrowserPolicyConnector : public BrowserPolicyConnectorBase {
29 public:
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.
34 virtual void Init(
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);
60 protected:
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.
67 void InitInternal(
68 PrefService* local_state,
69 scoped_ptr<DeviceManagementService> device_management_service);
71 private:
72 scoped_ptr<PolicyStatisticsCollector> policy_statistics_collector_;
74 scoped_ptr<DeviceManagementService> device_management_service_;
76 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector);
79 } // namespace policy
81 #endif // COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_