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_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ |
6 #define CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | 6 #define CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/chromeos/cros/network_ui_data.h" | 11 #include "chrome/browser/chromeos/cros/network_ui_data.h" |
12 #include "chrome/browser/policy/policy_service.h" | 12 #include "chrome/browser/policy/configuration_policy_provider.h" |
13 | |
14 namespace base { | |
15 class Value; | |
16 } | |
17 | 13 |
18 namespace chromeos { | 14 namespace chromeos { |
19 class NetworkLibrary; | 15 class NetworkLibrary; |
20 } | 16 } |
21 | 17 |
22 namespace policy { | 18 namespace policy { |
23 | 19 |
24 class PolicyMap; | 20 class PolicyMap; |
25 | 21 |
26 // Keeps track of the network configuration policy settings and updates the | 22 // Keeps track of the network configuration policy settings and updates the |
27 // network definitions whenever the configuration changes. | 23 // network definitions whenever the configuration changes. |
28 class NetworkConfigurationUpdater { | 24 class NetworkConfigurationUpdater |
| 25 : public ConfigurationPolicyProvider::Observer { |
29 public: | 26 public: |
30 NetworkConfigurationUpdater(PolicyService* policy_service, | 27 NetworkConfigurationUpdater(ConfigurationPolicyProvider* provider, |
31 chromeos::NetworkLibrary* network_library); | 28 chromeos::NetworkLibrary* network_library); |
32 virtual ~NetworkConfigurationUpdater(); | 29 virtual ~NetworkConfigurationUpdater(); |
33 | 30 |
| 31 // ConfigurationPolicyProvider::Observer: |
| 32 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE; |
| 33 |
34 // Empty network configuration blob. | 34 // Empty network configuration blob. |
35 static const char kEmptyConfiguration[]; | 35 static const char kEmptyConfiguration[]; |
36 | 36 |
37 private: | 37 private: |
| 38 // Grabs network configuration from policy and applies it. |
| 39 void Update(); |
| 40 |
38 // Extracts ONC string from |policy_map| and pushes the configuration to | 41 // Extracts ONC string from |policy_map| and pushes the configuration to |
39 // |network_library_| if it's different from |*cached_value| (which is | 42 // |network_library_| if it's different from |*cached_value| (which is |
40 // updated). | 43 // updated). |
41 void ApplyNetworkConfiguration(chromeos::NetworkUIData::ONCSource onc_source, | 44 void ApplyNetworkConfiguration(const PolicyMap& policy_map, |
42 std::string* cached_value, | 45 const char* policy_name, |
43 const base::Value* previous, | 46 chromeos::NetworkUIData::ONCSource onc_source, |
44 const base::Value* current); | 47 std::string* cached_value); |
45 | 48 |
46 // Wraps the policy service we read network configuration from. | 49 // Wraps the provider we read network configuration from. |
47 PolicyChangeRegistrar policy_change_registrar_; | 50 ConfigurationPolicyObserverRegistrar provider_registrar_; |
48 | 51 |
49 // Network library to write network configuration to. | 52 // Network library to write network configuration to. |
50 chromeos::NetworkLibrary* network_library_; | 53 chromeos::NetworkLibrary* network_library_; |
51 | 54 |
52 // Current settings. | 55 // Current settings. |
53 std::string device_network_config_; | 56 std::string device_network_config_; |
54 std::string user_network_config_; | 57 std::string user_network_config_; |
55 | 58 |
56 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater); | 59 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater); |
57 }; | 60 }; |
58 | 61 |
59 } // namespace policy | 62 } // namespace policy |
60 | 63 |
61 #endif // CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ | 64 #endif // CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_ |
OLD | NEW |