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 "base/basictypes.h" |
9 | |
10 #include "chrome/browser/chromeos/cros/network_constants.h" | |
11 #include "chrome/browser/chromeos/cros/network_library.h" | |
12 #include "chrome/browser/policy/policy_service.h" | |
13 #include "chromeos/network/network_ui_data.h" | |
14 #include "chromeos/network/onc/onc_constants.h" | |
15 | |
16 namespace base { | |
17 class Value; | |
18 } | |
19 | 9 |
20 namespace net { | 10 namespace net { |
21 class CertTrustAnchorProvider; | 11 class CertTrustAnchorProvider; |
22 } | 12 } |
23 | 13 |
24 namespace policy { | 14 namespace policy { |
25 | 15 |
26 class PolicyMap; | 16 // Keeps track of the network configuration policy settings and pushes changes |
27 | 17 // to the respective configuration backend, which in turn writes configurations |
28 // Keeps track of the network configuration policy settings and Shill's | 18 // to Shill. |
29 // profiles. Requests the NetworkLibrary to apply the ONC of the network | 19 class NetworkConfigurationUpdater { |
30 // policies every time one of the relevant policies or Shill's profiles changes | |
31 // or OnUserPolicyInitialized() is called. If the user policy is available, | |
32 // always both the device and the user policy are applied. Otherwise only the | |
33 // device policy is applied. | |
34 class NetworkConfigurationUpdater | |
35 : public chromeos::NetworkLibrary::NetworkProfileObserver { | |
36 public: | 20 public: |
37 NetworkConfigurationUpdater(PolicyService* policy_service, | 21 NetworkConfigurationUpdater() {} |
38 chromeos::NetworkLibrary* network_library); | 22 virtual ~NetworkConfigurationUpdater() {} |
39 virtual ~NetworkConfigurationUpdater(); | |
40 | |
41 // NetworkProfileObserver overrides. | |
42 virtual void OnProfileListChanged() OVERRIDE; | |
43 | 23 |
44 // Notifies this updater that the user policy is initialized. Before this | 24 // Notifies this updater that the user policy is initialized. Before this |
45 // function is called, the user policy is not applied. Afterwards, always both | 25 // function is called, the user policy is not applied. This function may |
46 // device and user policy are applied as described in the class comment. This | 26 // trigger immediate policy applications. |
47 // function also triggers an immediate policy application of both device and | 27 virtual void OnUserPolicyInitialized() = 0; |
48 // user policy. | 28 |
49 void OnUserPolicyInitialized(); | 29 // TODO(pneubeck): Extract the following two certificate related functions |
| 30 // into a separate CertificateUpdater. |
50 | 31 |
51 // Web trust isn't given to certificates imported from ONC by default. Setting | 32 // Web trust isn't given to certificates imported from ONC by default. Setting |
52 // |allow| to true allows giving Web trust to the certificates that | 33 // |allow| to true allows giving Web trust to the certificates that |
53 // request it. | 34 // request it. |
54 void set_allow_trusted_certificates_from_policy(bool allow) { | 35 virtual void set_allow_trusted_certificates_from_policy(bool allow) = 0; |
55 allow_trusted_certificates_from_policy_ = allow; | |
56 } | |
57 | 36 |
58 // Returns a CertTrustAnchorProvider that provides the list of server and | 37 // Returns a CertTrustAnchorProvider that provides the list of server and |
59 // CA certificates with the Web trust flag set that were retrieved from the | 38 // CA certificates with the Web trust flag set that were retrieved from the |
60 // last user ONC policy update. | 39 // last user ONC policy update. |
61 // This getter must be used on the UI thread, and the provider must be used | 40 // This getter must be used on the UI thread, and the provider must be used |
62 // on the IO thread. It is only valid as long as the | 41 // on the IO thread. It is only valid as long as the |
63 // NetworkConfigurationUpdater is valid; the NetworkConfigurationUpdater | 42 // NetworkConfigurationUpdater is valid; the NetworkConfigurationUpdater |
64 // outlives all the profiles, and deletes the provider on the IO thread. | 43 // outlives all the profiles, and deletes the provider on the IO thread. |
65 net::CertTrustAnchorProvider* GetCertTrustAnchorProvider(); | 44 virtual net::CertTrustAnchorProvider* GetCertTrustAnchorProvider() = 0; |
66 | 45 |
67 private: | 46 private: |
68 // Callback that's called by |policy_service_| if the respective ONC policy | |
69 // changed. | |
70 void OnPolicyChanged(chromeos::onc::ONCSource onc_source, | |
71 const base::Value* previous, | |
72 const base::Value* current); | |
73 | |
74 // Retrieves the ONC policies from |policy_service_| and pushes the | |
75 // configurations to |network_library_|. Ensures that a device policy is | |
76 // always overwritten by a user policy. | |
77 void ApplyNetworkConfigurations(); | |
78 | |
79 // Push the policy stored at |policy_key| for |onc_source| to | |
80 // |network_library_|. | |
81 void ApplyNetworkConfiguration(const std::string& policy_key, | |
82 chromeos::onc::ONCSource onc_source); | |
83 | |
84 // Wraps the policy service we read network configuration from. | |
85 PolicyChangeRegistrar policy_change_registrar_; | |
86 | |
87 // Network library to write network configuration to. | |
88 chromeos::NetworkLibrary* network_library_; | |
89 | |
90 // Whether the user policy is already available. | |
91 bool user_policy_initialized_; | |
92 | |
93 // Whether Web trust is allowed or not. | |
94 bool allow_trusted_certificates_from_policy_; | |
95 | |
96 // The policy service storing the ONC policies. | |
97 PolicyService* policy_service_; | |
98 | |
99 // An implementation of CertTrustAnchorProvider. Owned by the updater, but | |
100 // lives on the IO thread. | |
101 net::CertTrustAnchorProvider* cert_trust_provider_; | |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater); | 47 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater); |
104 }; | 48 }; |
105 | 49 |
106 } // namespace policy | 50 } // namespace policy |
107 | 51 |
108 #endif // CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | 52 #endif // CHROME_BROWSER_CHROMEOS_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ |
OLD | NEW |