OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/device_network_configuration_updater.h" | 5 #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "chrome/browser/chromeos/settings/cros_settings.h" | 9 #include "chrome/browser/chromeos/settings/cros_settings.h" |
10 #include "chromeos/network/managed_network_configuration_handler.h" | 10 #include "chromeos/network/managed_network_configuration_handler.h" |
11 #include "chromeos/network/network_device_handler.h" | 11 #include "chromeos/network/network_device_handler.h" |
12 #include "chromeos/network/onc/onc_certificate_importer.h" | |
13 #include "chromeos/settings/cros_settings_names.h" | 12 #include "chromeos/settings/cros_settings_names.h" |
14 #include "chromeos/settings/cros_settings_provider.h" | 13 #include "chromeos/settings/cros_settings_provider.h" |
15 #include "policy/policy_constants.h" | 14 #include "policy/policy_constants.h" |
16 | 15 |
17 namespace policy { | 16 namespace policy { |
18 | 17 |
19 DeviceNetworkConfigurationUpdater::~DeviceNetworkConfigurationUpdater() {} | 18 DeviceNetworkConfigurationUpdater::~DeviceNetworkConfigurationUpdater() {} |
20 | 19 |
21 // static | 20 // static |
22 scoped_ptr<DeviceNetworkConfigurationUpdater> | 21 scoped_ptr<DeviceNetworkConfigurationUpdater> |
23 DeviceNetworkConfigurationUpdater::CreateForDevicePolicy( | 22 DeviceNetworkConfigurationUpdater::CreateForDevicePolicy( |
24 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer, | |
25 PolicyService* policy_service, | 23 PolicyService* policy_service, |
26 chromeos::ManagedNetworkConfigurationHandler* network_config_handler, | 24 chromeos::ManagedNetworkConfigurationHandler* network_config_handler, |
27 chromeos::NetworkDeviceHandler* network_device_handler, | 25 chromeos::NetworkDeviceHandler* network_device_handler, |
28 chromeos::CrosSettings* cros_settings) { | 26 chromeos::CrosSettings* cros_settings) { |
29 scoped_ptr<DeviceNetworkConfigurationUpdater> updater( | 27 scoped_ptr<DeviceNetworkConfigurationUpdater> updater( |
30 new DeviceNetworkConfigurationUpdater(certificate_importer.Pass(), | 28 new DeviceNetworkConfigurationUpdater(policy_service, |
31 policy_service, | |
32 network_config_handler, | 29 network_config_handler, |
33 network_device_handler, | 30 network_device_handler, |
34 cros_settings)); | 31 cros_settings)); |
35 updater->Init(); | 32 updater->Init(); |
36 return updater.Pass(); | 33 return updater.Pass(); |
37 } | 34 } |
38 | 35 |
39 DeviceNetworkConfigurationUpdater::DeviceNetworkConfigurationUpdater( | 36 DeviceNetworkConfigurationUpdater::DeviceNetworkConfigurationUpdater( |
40 scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer, | |
41 PolicyService* policy_service, | 37 PolicyService* policy_service, |
42 chromeos::ManagedNetworkConfigurationHandler* network_config_handler, | 38 chromeos::ManagedNetworkConfigurationHandler* network_config_handler, |
43 chromeos::NetworkDeviceHandler* network_device_handler, | 39 chromeos::NetworkDeviceHandler* network_device_handler, |
44 chromeos::CrosSettings* cros_settings) | 40 chromeos::CrosSettings* cros_settings) |
45 : NetworkConfigurationUpdater(onc::ONC_SOURCE_DEVICE_POLICY, | 41 : NetworkConfigurationUpdater(onc::ONC_SOURCE_DEVICE_POLICY, |
46 key::kDeviceOpenNetworkConfiguration, | 42 key::kDeviceOpenNetworkConfiguration, |
47 certificate_importer.Pass(), | |
48 policy_service, | 43 policy_service, |
49 network_config_handler), | 44 network_config_handler), |
50 network_device_handler_(network_device_handler), | 45 network_device_handler_(network_device_handler), |
51 cros_settings_(cros_settings), | 46 cros_settings_(cros_settings), |
52 weak_factory_(this) { | 47 weak_factory_(this) { |
53 DCHECK(network_device_handler_); | 48 DCHECK(network_device_handler_); |
54 data_roaming_setting_subscription_ = cros_settings->AddSettingsObserver( | 49 data_roaming_setting_subscription_ = cros_settings->AddSettingsObserver( |
55 chromeos::kSignedDataRoamingEnabled, | 50 chromeos::kSignedDataRoamingEnabled, |
56 base::Bind( | 51 base::Bind( |
57 &DeviceNetworkConfigurationUpdater::OnDataRoamingSettingChanged, | 52 &DeviceNetworkConfigurationUpdater::OnDataRoamingSettingChanged, |
58 base::Unretained(this))); | 53 base::Unretained(this))); |
59 } | 54 } |
60 | 55 |
61 void DeviceNetworkConfigurationUpdater::Init() { | 56 void DeviceNetworkConfigurationUpdater::Init() { |
62 NetworkConfigurationUpdater::Init(); | 57 NetworkConfigurationUpdater::Init(); |
63 | 58 |
64 // Apply the roaming setting initially. | 59 // Apply the roaming setting initially. |
65 OnDataRoamingSettingChanged(); | 60 OnDataRoamingSettingChanged(); |
66 } | 61 } |
67 | 62 |
68 void DeviceNetworkConfigurationUpdater::ImportCertificates( | 63 void DeviceNetworkConfigurationUpdater::ImportCertificates( |
69 const base::ListValue& certificates_onc) { | 64 const base::ListValue& certificates_onc) { |
70 certificate_importer_->ImportCertificates( | 65 // Importing CA and server certs from device policy is not allowed, while |
71 certificates_onc, onc_source_, NULL); | 66 // importing client is not yet supported (as a system-wide PKCS#11 token to |
| 67 // which they should be imported does not exists at the time). |
72 } | 68 } |
73 | 69 |
74 void DeviceNetworkConfigurationUpdater::ApplyNetworkPolicy( | 70 void DeviceNetworkConfigurationUpdater::ApplyNetworkPolicy( |
75 base::ListValue* network_configs_onc, | 71 base::ListValue* network_configs_onc, |
76 base::DictionaryValue* global_network_config) { | 72 base::DictionaryValue* global_network_config) { |
77 network_config_handler_->SetPolicy(onc_source_, | 73 network_config_handler_->SetPolicy(onc_source_, |
78 std::string() /* no username hash */, | 74 std::string() /* no username hash */, |
79 *network_configs_onc, | 75 *network_configs_onc, |
80 *global_network_config); | 76 *global_network_config); |
81 } | 77 } |
(...skipping 21 matching lines...) Expand all Loading... |
103 } else { | 99 } else { |
104 DCHECK_EQ(trusted_status, | 100 DCHECK_EQ(trusted_status, |
105 chromeos::CrosSettingsProvider::PERMANENTLY_UNTRUSTED); | 101 chromeos::CrosSettingsProvider::PERMANENTLY_UNTRUSTED); |
106 // Roaming is disabled as we can't determine the correct setting. | 102 // Roaming is disabled as we can't determine the correct setting. |
107 } | 103 } |
108 | 104 |
109 network_device_handler_->SetCellularAllowRoaming(data_roaming_setting); | 105 network_device_handler_->SetCellularAllowRoaming(data_roaming_setting); |
110 } | 106 } |
111 | 107 |
112 } // namespace policy | 108 } // namespace policy |
OLD | NEW |