| 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 #include "chrome/browser/policy/network_configuration_updater.h" | 5 #include "chrome/browser/policy/network_configuration_updater.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "chrome/browser/chromeos/cros/network_library.h" | 11 #include "chrome/browser/chromeos/cros/network_library.h" |
| 12 #include "chrome/browser/policy/policy_map.h" | 12 #include "chrome/browser/policy/policy_map.h" |
| 13 #include "policy/policy_constants.h" | 13 #include "policy/policy_constants.h" |
| 14 | 14 |
| 15 namespace policy { | 15 namespace policy { |
| 16 | 16 |
| 17 const char NetworkConfigurationUpdater::kEmptyConfiguration[] = | 17 const char NetworkConfigurationUpdater::kEmptyConfiguration[] = |
| 18 "{\"NetworkConfigurations\":[],\"Certificates\":[]}"; | 18 "{\"NetworkConfigurations\":[],\"Certificates\":[]}"; |
| 19 | 19 |
| 20 NetworkConfigurationUpdater::NetworkConfigurationUpdater( | 20 NetworkConfigurationUpdater::NetworkConfigurationUpdater( |
| 21 PolicyService* policy_service, | 21 PolicyService* policy_service, |
| 22 chromeos::NetworkLibrary* network_library) | 22 chromeos::NetworkLibrary* network_library, |
| 23 bool allow_web_trust) |
| 23 : policy_change_registrar_( | 24 : policy_change_registrar_( |
| 24 policy_service, POLICY_DOMAIN_CHROME, std::string()), | 25 policy_service, POLICY_DOMAIN_CHROME, std::string()), |
| 25 network_library_(network_library) { | 26 network_library_(network_library), |
| 27 allow_web_trust_(allow_web_trust) { |
| 26 DCHECK(network_library_); | 28 DCHECK(network_library_); |
| 27 policy_change_registrar_.Observe( | 29 policy_change_registrar_.Observe( |
| 28 key::kDeviceOpenNetworkConfiguration, | 30 key::kDeviceOpenNetworkConfiguration, |
| 29 base::Bind(&NetworkConfigurationUpdater::ApplyNetworkConfiguration, | 31 base::Bind(&NetworkConfigurationUpdater::ApplyNetworkConfiguration, |
| 30 base::Unretained(this), | 32 base::Unretained(this), |
| 31 chromeos::NetworkUIData::ONC_SOURCE_DEVICE_POLICY, | 33 chromeos::NetworkUIData::ONC_SOURCE_DEVICE_POLICY, |
| 32 &device_network_config_)); | 34 &device_network_config_)); |
| 33 policy_change_registrar_.Observe( | 35 policy_change_registrar_.Observe( |
| 34 key::kOpenNetworkConfiguration, | 36 key::kOpenNetworkConfiguration, |
| 35 base::Bind(&NetworkConfigurationUpdater::ApplyNetworkConfiguration, | 37 base::Bind(&NetworkConfigurationUpdater::ApplyNetworkConfiguration, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // We need to load an empty configuration to get rid of any configuration | 72 // We need to load an empty configuration to get rid of any configuration |
| 71 // that has been installed previously. An empty string also works, but | 73 // that has been installed previously. An empty string also works, but |
| 72 // generates warnings and errors, which we'd like to avoid. | 74 // generates warnings and errors, which we'd like to avoid. |
| 73 if (new_network_config.empty()) | 75 if (new_network_config.empty()) |
| 74 new_network_config = kEmptyConfiguration; | 76 new_network_config = kEmptyConfiguration; |
| 75 | 77 |
| 76 if (*cached_value != new_network_config) { | 78 if (*cached_value != new_network_config) { |
| 77 *cached_value = new_network_config; | 79 *cached_value = new_network_config; |
| 78 std::string error; | 80 std::string error; |
| 79 if (!network_library_->LoadOncNetworks(new_network_config, "", onc_source, | 81 if (!network_library_->LoadOncNetworks(new_network_config, "", onc_source, |
| 80 &error)) { | 82 allow_web_trust_, &error)) { |
| 81 LOG(WARNING) << "Network library failed to load ONC configuration:" | 83 LOG(WARNING) << "Network library failed to load ONC configuration:" |
| 82 << error; | 84 << error; |
| 83 } | 85 } |
| 84 } | 86 } |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // namespace policy | 89 } // namespace policy |
| OLD | NEW |