| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/policy/network_configuration_updater_impl.h" | 5 #include "chrome/browser/chromeos/policy/network_configuration_updater_impl.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 "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/chromeos/net/onc_utils.h" | 13 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 14 #include "chrome/browser/policy/policy_map.h" | 14 #include "chrome/browser/policy/policy_map.h" |
| 15 #include "chromeos/network/certificate_handler.h" | |
| 16 #include "chromeos/network/managed_network_configuration_handler.h" | 15 #include "chromeos/network/managed_network_configuration_handler.h" |
| 16 #include "chromeos/network/onc/onc_certificate_importer.h" |
| 17 #include "chromeos/network/onc/onc_constants.h" | 17 #include "chromeos/network/onc/onc_constants.h" |
| 18 #include "chromeos/network/onc/onc_utils.h" | 18 #include "chromeos/network/onc/onc_utils.h" |
| 19 #include "policy/policy_constants.h" | 19 #include "policy/policy_constants.h" |
| 20 | 20 |
| 21 namespace policy { | 21 namespace policy { |
| 22 | 22 |
| 23 NetworkConfigurationUpdaterImpl::NetworkConfigurationUpdaterImpl( | 23 NetworkConfigurationUpdaterImpl::NetworkConfigurationUpdaterImpl( |
| 24 PolicyService* device_policy_service, | 24 PolicyService* device_policy_service, |
| 25 scoped_ptr<chromeos::CertificateHandler> certificate_handler) | 25 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer) |
| 26 : device_policy_change_registrar_(device_policy_service, | 26 : device_policy_change_registrar_(device_policy_service, |
| 27 PolicyNamespace(POLICY_DOMAIN_CHROME, | 27 PolicyNamespace(POLICY_DOMAIN_CHROME, |
| 28 std::string())), | 28 std::string())), |
| 29 user_policy_service_(NULL), | 29 user_policy_service_(NULL), |
| 30 device_policy_service_(device_policy_service), | 30 device_policy_service_(device_policy_service), |
| 31 certificate_handler_(certificate_handler.Pass()) { | 31 certificate_importer_(certificate_importer.Pass()) { |
| 32 device_policy_change_registrar_.Observe( | 32 device_policy_change_registrar_.Observe( |
| 33 key::kDeviceOpenNetworkConfiguration, | 33 key::kDeviceOpenNetworkConfiguration, |
| 34 base::Bind(&NetworkConfigurationUpdaterImpl::OnPolicyChanged, | 34 base::Bind(&NetworkConfigurationUpdaterImpl::OnPolicyChanged, |
| 35 base::Unretained(this), | 35 base::Unretained(this), |
| 36 chromeos::onc::ONC_SOURCE_DEVICE_POLICY)); | 36 chromeos::onc::ONC_SOURCE_DEVICE_POLICY)); |
| 37 | 37 |
| 38 if (device_policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME)) { | 38 if (device_policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME)) { |
| 39 // Apply the current device policies immediately. | 39 // Apply the current device policies immediately. |
| 40 VLOG(1) << "Device policy service is already initialized."; | 40 VLOG(1) << "Device policy service is already initialized."; |
| 41 ApplyNetworkConfiguration(chromeos::onc::ONC_SOURCE_DEVICE_POLICY); | 41 ApplyNetworkConfiguration(chromeos::onc::ONC_SOURCE_DEVICE_POLICY); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 VLOG(2) << "The policy is not set."; | 149 VLOG(2) << "The policy is not set."; |
| 150 } | 150 } |
| 151 VLOG(2) << "The policy contains this ONC: " << onc_blob; | 151 VLOG(2) << "The policy contains this ONC: " << onc_blob; |
| 152 | 152 |
| 153 base::ListValue network_configs; | 153 base::ListValue network_configs; |
| 154 base::ListValue certificates; | 154 base::ListValue certificates; |
| 155 chromeos::onc::ParseAndValidateOncForImport( | 155 chromeos::onc::ParseAndValidateOncForImport( |
| 156 onc_blob, onc_source, "", &network_configs, &certificates); | 156 onc_blob, onc_source, "", &network_configs, &certificates); |
| 157 | 157 |
| 158 scoped_ptr<net::CertificateList> web_trust_certs(new net::CertificateList); | 158 scoped_ptr<net::CertificateList> web_trust_certs(new net::CertificateList); |
| 159 certificate_handler_->ImportCertificates( | 159 certificate_importer_->ImportCertificates( |
| 160 certificates, onc_source, web_trust_certs.get()); | 160 certificates, onc_source, web_trust_certs.get()); |
| 161 | 161 |
| 162 std::string userhash; | 162 std::string userhash; |
| 163 if (onc_source == chromeos::onc::ONC_SOURCE_USER_POLICY) { | 163 if (onc_source == chromeos::onc::ONC_SOURCE_USER_POLICY) { |
| 164 userhash = hashed_username_; | 164 userhash = hashed_username_; |
| 165 chromeos::onc::ExpandStringPlaceholdersInNetworksForUser(hashed_username_, | 165 chromeos::onc::ExpandStringPlaceholdersInNetworksForUser(hashed_username_, |
| 166 &network_configs); | 166 &network_configs); |
| 167 } | 167 } |
| 168 | 168 |
| 169 chromeos::NetworkHandler::Get()->managed_network_configuration_handler()-> | 169 chromeos::NetworkHandler::Get()->managed_network_configuration_handler()-> |
| 170 SetPolicy(onc_source, userhash, network_configs); | 170 SetPolicy(onc_source, userhash, network_configs); |
| 171 | 171 |
| 172 if (onc_source == chromeos::onc::ONC_SOURCE_USER_POLICY) | 172 if (onc_source == chromeos::onc::ONC_SOURCE_USER_POLICY) |
| 173 SetTrustAnchors(web_trust_certs.Pass()); | 173 SetTrustAnchors(web_trust_certs.Pass()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace policy | 176 } // namespace policy |
| OLD | NEW |