OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "components/onc/onc_constants.h" | 13 #include "components/onc/onc_constants.h" |
14 #include "components/policy/core/common/policy_service.h" | 14 #include "components/policy/core/common/policy_service.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class DictionaryValue; | 17 class DictionaryValue; |
18 class ListValue; | 18 class ListValue; |
19 class Value; | 19 class Value; |
20 } | 20 } |
21 | 21 |
22 namespace chromeos { | 22 namespace chromeos { |
23 class ManagedNetworkConfigurationHandler; | 23 class ManagedNetworkConfigurationHandler; |
24 | |
25 namespace onc { | |
26 class CertificateImporter; | |
27 } | |
28 } | 24 } |
29 | 25 |
30 namespace policy { | 26 namespace policy { |
31 | 27 |
32 class PolicyMap; | 28 class PolicyMap; |
33 | 29 |
34 // Implements the common part of tracking a OpenNetworkConfiguration device or | 30 // Implements the common part of tracking a OpenNetworkConfiguration device or |
35 // user policy. Pushes the network configs to the | 31 // user policy. Pushes the network configs to the |
36 // ManagedNetworkConfigurationHandler, which in turn writes configurations to | 32 // ManagedNetworkConfigurationHandler, which in turn writes configurations to |
37 // Shill. Certificates are imported with the chromeos::onc::CertificateImporter. | 33 // Shill. Certificates are imported with the chromeos::onc::CertificateImporter. |
38 // For user policies the subclass UserNetworkConfigurationUpdater must be used. | 34 // For user policies the subclass UserNetworkConfigurationUpdater must be used. |
39 // Does not handle proxy settings. | 35 // Does not handle proxy settings. |
40 class NetworkConfigurationUpdater : public PolicyService::Observer { | 36 class NetworkConfigurationUpdater : public PolicyService::Observer { |
41 public: | 37 public: |
42 virtual ~NetworkConfigurationUpdater(); | 38 virtual ~NetworkConfigurationUpdater(); |
43 | 39 |
44 // PolicyService::Observer overrides | 40 // PolicyService::Observer overrides |
45 virtual void OnPolicyUpdated(const PolicyNamespace& ns, | 41 virtual void OnPolicyUpdated(const PolicyNamespace& ns, |
46 const PolicyMap& previous, | 42 const PolicyMap& previous, |
47 const PolicyMap& current) OVERRIDE; | 43 const PolicyMap& current) OVERRIDE; |
48 virtual void OnPolicyServiceInitialized(PolicyDomain domain) OVERRIDE; | 44 virtual void OnPolicyServiceInitialized(PolicyDomain domain) OVERRIDE; |
49 | 45 |
50 protected: | 46 protected: |
51 NetworkConfigurationUpdater( | 47 NetworkConfigurationUpdater( |
52 onc::ONCSource onc_source, | 48 onc::ONCSource onc_source, |
53 std::string policy_key, | 49 std::string policy_key, |
54 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer, | |
55 PolicyService* policy_service, | 50 PolicyService* policy_service, |
56 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); | 51 chromeos::ManagedNetworkConfigurationHandler* network_config_handler); |
57 | 52 |
58 virtual void Init(); | 53 virtual void Init(); |
59 | 54 |
60 // Imports the certificates part of the policy. | 55 // Imports the certificates part of the policy. |
61 virtual void ImportCertificates(const base::ListValue& certificates_onc) = 0; | 56 virtual void ImportCertificates(const base::ListValue& certificates_onc) = 0; |
62 | 57 |
63 // Pushes the network part of the policy to the | 58 // Pushes the network part of the policy to the |
64 // ManagedNetworkConfigurationHandler. This can be overridden by subclasses to | 59 // ManagedNetworkConfigurationHandler. This can be overridden by subclasses to |
65 // modify |network_configs_onc| before the actual application. | 60 // modify |network_configs_onc| before the actual application. |
66 virtual void ApplyNetworkPolicy( | 61 virtual void ApplyNetworkPolicy( |
67 base::ListValue* network_configs_onc, | 62 base::ListValue* network_configs_onc, |
68 base::DictionaryValue* global_network_config) = 0; | 63 base::DictionaryValue* global_network_config) = 0; |
69 | 64 |
70 onc::ONCSource onc_source_; | 65 onc::ONCSource onc_source_; |
71 | 66 |
72 // Pointer to the global singleton or a test instance. | 67 // Pointer to the global singleton or a test instance. |
73 chromeos::ManagedNetworkConfigurationHandler* network_config_handler_; | 68 chromeos::ManagedNetworkConfigurationHandler* network_config_handler_; |
74 | 69 |
75 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer_; | |
76 | |
77 private: | 70 private: |
78 // Called if the ONC policy changed. | 71 // Called if the ONC policy changed. |
79 void OnPolicyChanged(const base::Value* previous, const base::Value* current); | 72 void OnPolicyChanged(const base::Value* previous, const base::Value* current); |
80 | 73 |
81 // Apply the observed policy, i.e. both networks and certificates. | 74 // Apply the observed policy, i.e. both networks and certificates. |
82 void ApplyPolicy(); | 75 void ApplyPolicy(); |
83 | 76 |
84 std::string LogHeader() const; | 77 std::string LogHeader() const; |
85 | 78 |
86 std::string policy_key_; | 79 std::string policy_key_; |
87 | 80 |
88 // Used to register for notifications from the |policy_service_|. | 81 // Used to register for notifications from the |policy_service_|. |
89 PolicyChangeRegistrar policy_change_registrar_; | 82 PolicyChangeRegistrar policy_change_registrar_; |
90 | 83 |
91 // Used to retrieve the policies. | 84 // Used to retrieve the policies. |
92 PolicyService* policy_service_; | 85 PolicyService* policy_service_; |
93 | 86 |
94 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater); | 87 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater); |
95 }; | 88 }; |
96 | 89 |
97 } // namespace policy | 90 } // namespace policy |
98 | 91 |
99 #endif // CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | 92 #endif // CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ |
OLD | NEW |