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