1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/onc/onc_constants.h"
14 #include "components/policy/core/common/policy_service.h"
17 class DictionaryValue
;
23 class ManagedNetworkConfigurationHandler
;
30 // Implements the common part of tracking a OpenNetworkConfiguration device or
31 // user policy. Pushes the network configs to the
32 // ManagedNetworkConfigurationHandler, which in turn writes configurations to
33 // Shill. Certificates are imported with the chromeos::onc::CertificateImporter.
34 // For user policies the subclass UserNetworkConfigurationUpdater must be used.
35 // Does not handle proxy settings.
36 class NetworkConfigurationUpdater
: public PolicyService::Observer
{
38 ~NetworkConfigurationUpdater() override
;
40 // PolicyService::Observer overrides
41 void OnPolicyUpdated(const PolicyNamespace
& ns
,
42 const PolicyMap
& previous
,
43 const PolicyMap
& current
) override
;
44 void OnPolicyServiceInitialized(PolicyDomain domain
) override
;
47 NetworkConfigurationUpdater(
48 onc::ONCSource onc_source
,
49 std::string policy_key
,
50 PolicyService
* policy_service
,
51 chromeos::ManagedNetworkConfigurationHandler
* network_config_handler
);
55 // Imports the certificates part of the policy.
56 virtual void ImportCertificates(const base::ListValue
& certificates_onc
) = 0;
58 // Pushes the network part of the policy to the
59 // ManagedNetworkConfigurationHandler. This can be overridden by subclasses to
60 // modify |network_configs_onc| before the actual application.
61 virtual void ApplyNetworkPolicy(
62 base::ListValue
* network_configs_onc
,
63 base::DictionaryValue
* global_network_config
) = 0;
65 onc::ONCSource onc_source_
;
67 // Pointer to the global singleton or a test instance.
68 chromeos::ManagedNetworkConfigurationHandler
* network_config_handler_
;
71 // Called if the ONC policy changed.
72 void OnPolicyChanged(const base::Value
* previous
, const base::Value
* current
);
74 // Apply the observed policy, i.e. both networks and certificates.
77 std::string
LogHeader() const;
79 std::string policy_key_
;
81 // Used to register for notifications from the |policy_service_|.
82 PolicyChangeRegistrar policy_change_registrar_
;
84 // Used to retrieve the policies.
85 PolicyService
* policy_service_
;
87 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater
);
92 #endif // CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_