| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/policy/network_configuration_updater.h" | 5 #include "chrome/browser/policy/network_configuration_updater.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/cros/network_library.h" | 7 #include "chrome/browser/chromeos/cros/network_library.h" |
| 8 #include "chrome/browser/policy/policy_map.h" | 8 #include "chrome/browser/policy/policy_map.h" |
| 9 #include "policy/policy_constants.h" | 9 #include "policy/policy_constants.h" |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 void NetworkConfigurationUpdater::Update() { | 29 void NetworkConfigurationUpdater::Update() { |
| 30 ConfigurationPolicyProvider* provider = provider_registrar_.provider(); | 30 ConfigurationPolicyProvider* provider = provider_registrar_.provider(); |
| 31 | 31 |
| 32 PolicyMap policy; | 32 PolicyMap policy; |
| 33 if (!provider->Provide(&policy)) { | 33 if (!provider->Provide(&policy)) { |
| 34 LOG(WARNING) << "Failed to read policy from policy provider."; | 34 LOG(WARNING) << "Failed to read policy from policy provider."; |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 | 37 |
| 38 ApplyNetworkConfiguration(policy, kPolicyDeviceOpenNetworkConfiguration, | 38 ApplyNetworkConfiguration(policy, kPolicyDeviceOpenNetworkConfiguration, |
| 39 chromeos::NetworkUIData::ONC_SOURCE_DEVICE_POLICY, |
| 39 &device_network_config_); | 40 &device_network_config_); |
| 40 ApplyNetworkConfiguration(policy, kPolicyOpenNetworkConfiguration, | 41 ApplyNetworkConfiguration(policy, kPolicyOpenNetworkConfiguration, |
| 42 chromeos::NetworkUIData::ONC_SOURCE_USER_POLICY, |
| 41 &user_network_config_); | 43 &user_network_config_); |
| 42 } | 44 } |
| 43 | 45 |
| 44 void NetworkConfigurationUpdater::ApplyNetworkConfiguration( | 46 void NetworkConfigurationUpdater::ApplyNetworkConfiguration( |
| 45 const PolicyMap& policy_map, | 47 const PolicyMap& policy_map, |
| 46 ConfigurationPolicyType policy_type, | 48 ConfigurationPolicyType policy_type, |
| 49 chromeos::NetworkUIData::ONCSource onc_source, |
| 47 std::string* cached_value) { | 50 std::string* cached_value) { |
| 48 std::string new_network_config; | 51 std::string new_network_config; |
| 49 const base::Value* value = policy_map.Get(policy_type); | 52 const base::Value* value = policy_map.Get(policy_type); |
| 50 if (value != NULL) { | 53 if (value != NULL) { |
| 51 // If the policy is not a string, we issue a warning, but still clear the | 54 // If the policy is not a string, we issue a warning, but still clear the |
| 52 // network configuration. | 55 // network configuration. |
| 53 if (!value->GetAsString(&new_network_config)) | 56 if (!value->GetAsString(&new_network_config)) |
| 54 LOG(WARNING) << "Invalid network configuration."; | 57 LOG(WARNING) << "Invalid network configuration."; |
| 55 } | 58 } |
| 56 | 59 |
| 57 if (*cached_value != new_network_config) { | 60 if (*cached_value != new_network_config) { |
| 58 *cached_value = new_network_config; | 61 *cached_value = new_network_config; |
| 59 std::string error; | 62 std::string error; |
| 60 if (!network_library_->LoadOncNetworks(new_network_config, "", &error)) { | 63 if (!network_library_->LoadOncNetworks(new_network_config, "", onc_source, |
| 64 &error)) { |
| 61 LOG(WARNING) << "Network library failed to load ONC configuration:" | 65 LOG(WARNING) << "Network library failed to load ONC configuration:" |
| 62 << error; | 66 << error; |
| 63 } | 67 } |
| 64 } | 68 } |
| 65 } | 69 } |
| 66 | 70 |
| 67 } // namespace policy | 71 } // namespace policy |
| OLD | NEW |