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/chromeos/cros/network_library_impl_base.h" | 5 #include "chrome/browser/chromeos/cros/network_library_impl_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "chrome/browser/chromeos/cros/native_network_parser.h" | 11 #include "chrome/browser/chromeos/cros/native_network_parser.h" |
12 #include "chrome/browser/chromeos/cros/onc_constants.h" | |
13 #include "chrome/browser/chromeos/cros/onc_network_parser.h" | 12 #include "chrome/browser/chromeos/cros/onc_network_parser.h" |
14 #include "chrome/browser/chromeos/network_login_observer.h" | 13 #include "chrome/browser/chromeos/network_login_observer.h" |
15 #include "chrome/browser/chromeos/network_settings/onc_certificate_importer.h" | 14 #include "chromeos/network/onc/onc_certificate_importer.h" |
16 #include "chrome/browser/chromeos/network_settings/onc_signature.h" | 15 #include "chromeos/network/onc/onc_constants.h" |
17 #include "chrome/browser/chromeos/network_settings/onc_utils.h" | 16 #include "chromeos/network/onc/onc_signature.h" |
18 #include "chrome/browser/chromeos/network_settings/onc_validator.h" | 17 #include "chromeos/network/onc/onc_utils.h" |
18 #include "chromeos/network/onc/onc_validator.h" | |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. | 20 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. |
21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
22 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 | 26 |
27 namespace chromeos { | 27 namespace chromeos { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Only send network change notifications to observers once every 50ms. | 31 // Only send network change notifications to observers once every 50ms. |
32 const int kNetworkNotifyDelayMs = 50; | 32 const int kNetworkNotifyDelayMs = 50; |
33 | 33 |
34 // How long we should remember that cellular plan payment was received. | 34 // How long we should remember that cellular plan payment was received. |
35 const int kRecentPlanPaymentHours = 6; | 35 const int kRecentPlanPaymentHours = 6; |
36 | 36 |
37 NetworkProfileType GetProfileTypeForSource(NetworkUIData::ONCSource source) { | 37 NetworkProfileType GetProfileTypeForSource(onc::ONCSource source) { |
38 switch (source) { | 38 switch (source) { |
39 case NetworkUIData::ONC_SOURCE_DEVICE_POLICY: | 39 case onc::ONC_SOURCE_DEVICE_POLICY: |
40 return PROFILE_SHARED; | 40 return PROFILE_SHARED; |
41 case NetworkUIData::ONC_SOURCE_USER_POLICY: | 41 case onc::ONC_SOURCE_USER_POLICY: |
42 return PROFILE_USER; | 42 return PROFILE_USER; |
43 case NetworkUIData::ONC_SOURCE_NONE: | 43 case onc::ONC_SOURCE_NONE: |
44 case NetworkUIData::ONC_SOURCE_USER_IMPORT: | 44 case onc::ONC_SOURCE_USER_IMPORT: |
45 return PROFILE_NONE; | 45 return PROFILE_NONE; |
46 } | 46 } |
47 NOTREACHED() << "Unknown ONC source " << source; | 47 NOTREACHED() << "Unknown ONC source " << source; |
48 return PROFILE_NONE; | 48 return PROFILE_NONE; |
49 } | 49 } |
50 | 50 |
51 // For logging only: strings not user facing. | |
52 std::string GetSourceAsString(onc::ONCSource source) { | |
pneubeck (no reviews)
2012/12/10 09:33:10
move to onc_utils.*
Greg Spencer (Chromium)
2012/12/10 23:54:03
Done.
| |
53 switch (source) { | |
54 case onc::ONC_SOURCE_DEVICE_POLICY: | |
55 return "device policy"; | |
56 case onc::ONC_SOURCE_USER_POLICY: | |
57 return "user policy"; | |
58 case onc::ONC_SOURCE_NONE: | |
59 return "none"; | |
60 case onc::ONC_SOURCE_USER_IMPORT: | |
61 return "user import"; | |
62 } | |
63 NOTREACHED() << "unknown ONC source " << source; | |
64 return "unknown"; | |
65 } | |
66 | |
51 } // namespace | 67 } // namespace |
52 | 68 |
53 NetworkLibraryImplBase::NetworkLibraryImplBase() | 69 NetworkLibraryImplBase::NetworkLibraryImplBase() |
54 : ethernet_(NULL), | 70 : ethernet_(NULL), |
55 active_wifi_(NULL), | 71 active_wifi_(NULL), |
56 active_cellular_(NULL), | 72 active_cellular_(NULL), |
57 active_wimax_(NULL), | 73 active_wimax_(NULL), |
58 active_virtual_(NULL), | 74 active_virtual_(NULL), |
59 available_devices_(0), | 75 available_devices_(0), |
60 enabled_devices_(0), | 76 enabled_devices_(0), |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 result = ethernet_; | 373 result = ethernet_; |
358 if (active_wifi_ && active_wifi_->connected()) | 374 if (active_wifi_ && active_wifi_->connected()) |
359 result = highest_priority(result, active_wifi_); | 375 result = highest_priority(result, active_wifi_); |
360 if (active_cellular_ && active_cellular_->connected()) | 376 if (active_cellular_ && active_cellular_->connected()) |
361 result = highest_priority(result, active_cellular_); | 377 result = highest_priority(result, active_cellular_); |
362 if (active_wimax_ && active_wimax_->connected()) | 378 if (active_wimax_ && active_wimax_->connected()) |
363 result = highest_priority(result, active_wimax_); | 379 result = highest_priority(result, active_wimax_); |
364 return result; | 380 return result; |
365 } | 381 } |
366 | 382 |
367 // Connecting order in logical prefernce. | 383 // Connecting order in logical preference. |
368 const Network* NetworkLibraryImplBase::connecting_network() const { | 384 const Network* NetworkLibraryImplBase::connecting_network() const { |
369 if (ethernet_connecting()) | 385 if (ethernet_connecting()) |
370 return ethernet_network(); | 386 return ethernet_network(); |
371 else if (wifi_connecting()) | 387 else if (wifi_connecting()) |
372 return wifi_network(); | 388 return wifi_network(); |
373 else if (cellular_connecting()) | 389 else if (cellular_connecting()) |
374 return cellular_network(); | 390 return cellular_network(); |
375 else if (wimax_connecting()) | 391 else if (wimax_connecting()) |
376 return wimax_network(); | 392 return wimax_network(); |
377 return NULL; | 393 return NULL; |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 break; | 1032 break; |
1017 if (wifi->auto_connect()) { | 1033 if (wifi->auto_connect()) { |
1018 ConnectToWifiNetwork(wifi); | 1034 ConnectToWifiNetwork(wifi); |
1019 break; | 1035 break; |
1020 } | 1036 } |
1021 } | 1037 } |
1022 } | 1038 } |
1023 | 1039 |
1024 bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob, | 1040 bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob, |
1025 const std::string& passphrase, | 1041 const std::string& passphrase, |
1026 NetworkUIData::ONCSource source, | 1042 onc::ONCSource source, |
1027 bool allow_web_trust_from_policy, | 1043 bool allow_web_trust_from_policy) { |
1028 std::string* error) { | |
1029 NetworkProfile* profile = NULL; | 1044 NetworkProfile* profile = NULL; |
1030 bool from_policy = (source == NetworkUIData::ONC_SOURCE_USER_POLICY || | 1045 bool from_policy = (source == onc::ONC_SOURCE_USER_POLICY || |
1031 source == NetworkUIData::ONC_SOURCE_DEVICE_POLICY); | 1046 source == onc::ONC_SOURCE_DEVICE_POLICY); |
1032 | 1047 |
1033 // Policies are applied to a specific Shill profile. User ONC import however | 1048 // Policies are applied to a specific Shill profile. User ONC import however |
1034 // is applied to whatever profile Shill chooses. This should be the profile | 1049 // is applied to whatever profile Shill chooses. This should be the profile |
1035 // that is already associated with a network and if no profile is associated | 1050 // that is already associated with a network and if no profile is associated |
1036 // yet, it should be the user profile. | 1051 // yet, it should be the user profile. |
1037 if (from_policy) { | 1052 if (from_policy) { |
1038 profile = GetProfileForType(GetProfileTypeForSource(source)); | 1053 profile = GetProfileForType(GetProfileTypeForSource(source)); |
1039 if (profile == NULL) { | 1054 if (profile == NULL) { |
1040 DLOG(WARNING) << "Profile for ONC source " << source << " doesn't exist."; | 1055 DLOG(WARNING) << "Profile for ONC source " << GetSourceAsString(source) |
1056 << " doesn't exist."; | |
1041 return false; | 1057 return false; |
1042 } | 1058 } |
1043 } | 1059 } |
1044 | 1060 |
1045 VLOG(2) << __func__ << ": called on " << onc_blob; | 1061 VLOG(2) << __func__ << ": called on " << onc_blob; |
1046 std::string json_error; | |
1047 scoped_ptr<base::DictionaryValue> root_dict = | 1062 scoped_ptr<base::DictionaryValue> root_dict = |
1048 onc::ReadDictionaryFromJson(onc_blob, &json_error); | 1063 onc::ReadDictionaryFromJson(onc_blob); |
1049 if (root_dict.get() == NULL) { | 1064 if (root_dict.get() == NULL) { |
1050 if (error != NULL) | 1065 LOG(WARNING) << "ONC loaded from " << GetSourceAsString(source) |
1051 *error = json_error; | 1066 << " is not a valid JSON dictionary."; |
1052 LOG(WARNING) << "ONC loaded from ONC source " << source | |
1053 << " is not a valid json dictionary: " << json_error; | |
1054 return false; | 1067 return false; |
1055 } | 1068 } |
1056 | 1069 |
1057 // Check and see if this is an encrypted ONC file. If so, decrypt it. | 1070 // Check and see if this is an encrypted ONC file. If so, decrypt it. |
1058 std::string onc_type; | 1071 std::string onc_type; |
1059 root_dict->GetStringWithoutPathExpansion(onc::kType, &onc_type); | 1072 root_dict->GetStringWithoutPathExpansion(onc::kType, &onc_type); |
1060 if (onc_type == onc::kEncryptedConfiguration) { | 1073 if (onc_type == onc::kEncryptedConfiguration) { |
1061 std::string decrypt_error; | 1074 root_dict = onc::Decrypt(passphrase, *root_dict); |
1062 root_dict = onc::Decrypt(passphrase, *root_dict, &decrypt_error); | |
1063 if (root_dict.get() == NULL) { | 1075 if (root_dict.get() == NULL) { |
1064 if (error != NULL) | 1076 LOG(WARNING) << "Couldn't decrypt the ONC from " |
1065 *error = decrypt_error; | 1077 << GetSourceAsString(source); |
1066 LOG(WARNING) << "Couldn't decrypt the ONC from source " << source | |
1067 << " with error: " << decrypt_error; | |
1068 return false; | 1078 return false; |
1069 } | 1079 } |
1070 } | 1080 } |
1071 | 1081 |
1072 // Validate the ONC dictionary. We are liberal and ignore unknown field | 1082 // Validate the ONC dictionary. We are liberal and ignore unknown field |
1073 // names and ignore invalid field names in kRecommended arrays. | 1083 // names and ignore invalid field names in kRecommended arrays. |
1074 onc::Validator validator(false, // Ignore unknown fields. | 1084 onc::Validator validator(false, // Ignore unknown fields. |
1075 false, // Ignore invalid recommended field names. | 1085 false, // Ignore invalid recommended field names. |
1076 true, // Fail on missing fields. | 1086 true, // Fail on missing fields. |
1077 from_policy); | 1087 from_policy); |
(...skipping 20 matching lines...) Expand all Loading... | |
1098 | 1108 |
1099 // At least one of NetworkConfigurations or Certificates is required. | 1109 // At least one of NetworkConfigurations or Certificates is required. |
1100 LOG_IF(WARNING, (!has_network_configurations && !has_certificates)) | 1110 LOG_IF(WARNING, (!has_network_configurations && !has_certificates)) |
1101 << "ONC from source " << source | 1111 << "ONC from source " << source |
1102 << " has neither NetworkConfigurations nor Certificates."; | 1112 << " has neither NetworkConfigurations nor Certificates."; |
1103 | 1113 |
1104 if (has_certificates) { | 1114 if (has_certificates) { |
1105 VLOG(2) << "ONC file has " << certificates->GetSize() << " certificates"; | 1115 VLOG(2) << "ONC file has " << certificates->GetSize() << " certificates"; |
1106 | 1116 |
1107 onc::CertificateImporter cert_importer(source, allow_web_trust_from_policy); | 1117 onc::CertificateImporter cert_importer(source, allow_web_trust_from_policy); |
1108 std::string cert_error; | 1118 if (cert_importer.ParseAndStoreCertificates(*certificates) != |
1109 if (!cert_importer.ParseAndStoreCertificates(*certificates, &cert_error)) { | 1119 onc::CertificateImporter::IMPORT_OK) { |
1110 if (error != NULL) | |
1111 *error = cert_error; | |
1112 LOG(WARNING) << "Cannot parse some of the certificates in the ONC from " | 1120 LOG(WARNING) << "Cannot parse some of the certificates in the ONC from " |
1113 << "source " << source << " with error: " << cert_error; | 1121 << GetSourceAsString(source); |
1114 return false; | 1122 return false; |
1115 } | 1123 } |
1116 } | 1124 } |
1117 | 1125 |
1118 std::set<std::string> removal_ids; | 1126 std::set<std::string> removal_ids; |
1119 std::set<std::string>& network_ids(network_source_map_[source]); | 1127 std::set<std::string>& network_ids(network_source_map_[source]); |
1120 network_ids.clear(); | 1128 network_ids.clear(); |
1121 if (has_network_configurations) { | 1129 if (has_network_configurations) { |
1122 VLOG(2) << "ONC file has " << network_configs->GetSize() << " networks"; | 1130 VLOG(2) << "ONC file has " << network_configs->GetSize() << " networks"; |
1123 OncNetworkParser parser(*network_configs, source); | 1131 OncNetworkParser parser(*network_configs, source); |
1124 | 1132 |
1125 // Parse all networks. Bail out if that fails. | 1133 // Parse all networks. Bail out if that fails. |
1126 NetworkOncMap added_onc_map; | 1134 NetworkOncMap added_onc_map; |
1127 ScopedVector<Network> networks; | 1135 ScopedVector<Network> networks; |
1128 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) { | 1136 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) { |
1129 // Parse Open Network Configuration blob into a temporary Network object. | 1137 // Parse Open Network Configuration blob into a temporary Network object. |
1130 bool marked_for_removal = false; | 1138 bool marked_for_removal = false; |
1131 Network* network = parser.ParseNetwork(i, &marked_for_removal); | 1139 Network* network = parser.ParseNetwork(i, &marked_for_removal); |
1132 if (!network) { | 1140 if (!network) { |
1133 if (error != NULL) | |
1134 *error = parser.parse_error(); | |
1135 LOG(WARNING) << "Error during parsing network at index " << i | 1141 LOG(WARNING) << "Error during parsing network at index " << i |
1136 << " from ONC source " << source | 1142 << " from ONC source " << GetSourceAsString(source); |
1137 << ": " << parser.parse_error(); | |
1138 return false; | 1143 return false; |
1139 } | 1144 } |
1140 | 1145 |
1141 // Disallow anything but WiFi and Ethernet for device-level policy (which | 1146 // Disallow anything but WiFi and Ethernet for device-level policy (which |
1142 // corresponds to shared networks). See also http://crosbug.com/28741. | 1147 // corresponds to shared networks). See also http://crosbug.com/28741. |
1143 if (source == NetworkUIData::ONC_SOURCE_DEVICE_POLICY && | 1148 if (source == onc::ONC_SOURCE_DEVICE_POLICY && |
1144 network->type() != TYPE_WIFI && | 1149 network->type() != TYPE_WIFI && |
1145 network->type() != TYPE_ETHERNET) { | 1150 network->type() != TYPE_ETHERNET) { |
1146 LOG(WARNING) << "Ignoring device-level policy-pushed network of type " | 1151 LOG(WARNING) << "Ignoring device-level policy-pushed network of type " |
1147 << network->type(); | 1152 << network->type(); |
1148 delete network; | 1153 delete network; |
1149 continue; | 1154 continue; |
1150 } | 1155 } |
1151 | 1156 |
1152 networks.push_back(network); | 1157 networks.push_back(network); |
1153 if (!(source == NetworkUIData::ONC_SOURCE_USER_IMPORT && | 1158 if (!(source == onc::ONC_SOURCE_USER_IMPORT && |
1154 marked_for_removal)) { | 1159 marked_for_removal)) { |
1155 added_onc_map[network->unique_id()] = parser.GetNetworkConfig(i); | 1160 added_onc_map[network->unique_id()] = parser.GetNetworkConfig(i); |
1156 } | 1161 } |
1157 | 1162 |
1158 if (marked_for_removal) | 1163 if (marked_for_removal) |
1159 removal_ids.insert(network->unique_id()); | 1164 removal_ids.insert(network->unique_id()); |
1160 } | 1165 } |
1161 | 1166 |
1162 // Update the ONC map. | 1167 // Update the ONC map. |
1163 for (NetworkOncMap::iterator iter(added_onc_map.begin()); | 1168 for (NetworkOncMap::iterator iter(added_onc_map.begin()); |
1164 iter != added_onc_map.end(); ++iter) { | 1169 iter != added_onc_map.end(); ++iter) { |
1165 const base::DictionaryValue*& entry = network_onc_map_[iter->first]; | 1170 const base::DictionaryValue*& entry = network_onc_map_[iter->first]; |
1166 delete entry; | 1171 delete entry; |
1167 entry = iter->second->DeepCopy(); | 1172 entry = iter->second->DeepCopy(); |
1168 } | 1173 } |
1169 | 1174 |
1170 // Configure the networks. While doing so, collect unique identifiers of the | 1175 // Configure the networks. While doing so, collect unique identifiers of the |
1171 // networks that are defined in the ONC blob in |network_ids|. They're later | 1176 // networks that are defined in the ONC blob in |network_ids|. They're later |
1172 // used to clean out any previously-existing networks that had been | 1177 // used to clean out any previously-existing networks that had been |
1173 // configured through policy but are no longer specified in the updated ONC | 1178 // configured through policy but are no longer specified in the updated ONC |
1174 // blob. | 1179 // blob. |
1175 for (std::vector<Network*>::iterator iter(networks.begin()); | 1180 for (std::vector<Network*>::iterator iter(networks.begin()); |
1176 iter != networks.end(); ++iter) { | 1181 iter != networks.end(); ++iter) { |
1177 Network* network = *iter; | 1182 Network* network = *iter; |
1178 | 1183 |
1179 // Don't configure a network that is supposed to be removed. For | 1184 // Don't configure a network that is supposed to be removed. For |
1180 // policy-managed networks, the "remove" functionality of ONC is ignored. | 1185 // policy-managed networks, the "remove" functionality of ONC is ignored. |
1181 if (source == NetworkUIData::ONC_SOURCE_USER_IMPORT && | 1186 if (source == onc::ONC_SOURCE_USER_IMPORT && |
1182 removal_ids.find(network->unique_id()) != removal_ids.end()) { | 1187 removal_ids.find(network->unique_id()) != removal_ids.end()) { |
1183 continue; | 1188 continue; |
1184 } | 1189 } |
1185 | 1190 |
1186 DictionaryValue dict; | 1191 DictionaryValue dict; |
1187 for (Network::PropertyMap::const_iterator props = | 1192 for (Network::PropertyMap::const_iterator props = |
1188 network->property_map_.begin(); | 1193 network->property_map_.begin(); |
1189 props != network->property_map_.end(); ++props) { | 1194 props != network->property_map_.end(); ++props) { |
1190 std::string key = | 1195 std::string key = |
1191 NativeNetworkParser::property_mapper()->GetKey(props->first); | 1196 NativeNetworkParser::property_mapper()->GetKey(props->first); |
(...skipping 23 matching lines...) Expand all Loading... | |
1215 network_ids.insert(network->unique_id()); | 1220 network_ids.insert(network->unique_id()); |
1216 } | 1221 } |
1217 } | 1222 } |
1218 | 1223 |
1219 if (from_policy) { | 1224 if (from_policy) { |
1220 // For policy-managed networks, go through the list of existing remembered | 1225 // For policy-managed networks, go through the list of existing remembered |
1221 // networks and clean out the ones that no longer have a definition in the | 1226 // networks and clean out the ones that no longer have a definition in the |
1222 // ONC blob. We first collect the networks and do the actual deletion later | 1227 // ONC blob. We first collect the networks and do the actual deletion later |
1223 // because ForgetNetwork() changes the remembered network vectors. | 1228 // because ForgetNetwork() changes the remembered network vectors. |
1224 ForgetNetworksById(source, network_ids, false); | 1229 ForgetNetworksById(source, network_ids, false); |
1225 } else if (source == NetworkUIData::ONC_SOURCE_USER_IMPORT) { | 1230 } else if (source == onc::ONC_SOURCE_USER_IMPORT) { |
1226 if (removal_ids.empty()) | 1231 if (removal_ids.empty()) |
1227 return true; | 1232 return true; |
1228 | 1233 |
1229 ForgetNetworksById(source, removal_ids, true); | 1234 ForgetNetworksById(source, removal_ids, true); |
1230 } | 1235 } |
1231 | 1236 |
1232 return true; | 1237 return true; |
1233 } | 1238 } |
1234 | 1239 |
1235 //////////////////////////////////////////////////////////////////////////// | 1240 //////////////////////////////////////////////////////////////////////////// |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1361 // Do not set the active network here. Wait until we parse the network. | 1366 // Do not set the active network here. Wait until we parse the network. |
1362 } | 1367 } |
1363 | 1368 |
1364 // Deletes a network. It must already be removed from any lists. | 1369 // Deletes a network. It must already be removed from any lists. |
1365 void NetworkLibraryImplBase::DeleteNetwork(Network* network) { | 1370 void NetworkLibraryImplBase::DeleteNetwork(Network* network) { |
1366 CHECK(network_map_.find(network->service_path()) == network_map_.end()); | 1371 CHECK(network_map_.find(network->service_path()) == network_map_.end()); |
1367 delete network; | 1372 delete network; |
1368 } | 1373 } |
1369 | 1374 |
1370 void NetworkLibraryImplBase::ForgetNetworksById( | 1375 void NetworkLibraryImplBase::ForgetNetworksById( |
1371 NetworkUIData::ONCSource source, | 1376 onc::ONCSource source, |
1372 std::set<std::string> ids, | 1377 std::set<std::string> ids, |
1373 bool if_found) { | 1378 bool if_found) { |
1374 std::vector<std::string> to_be_forgotten; | 1379 std::vector<std::string> to_be_forgotten; |
1375 for (WifiNetworkVector::iterator i = remembered_wifi_networks_.begin(); | 1380 for (WifiNetworkVector::iterator i = remembered_wifi_networks_.begin(); |
1376 i != remembered_wifi_networks_.end(); ++i) { | 1381 i != remembered_wifi_networks_.end(); ++i) { |
1377 WifiNetwork* wifi_network = *i; | 1382 WifiNetwork* wifi_network = *i; |
1378 if (wifi_network->ui_data().onc_source() == source && | 1383 if (wifi_network->ui_data().onc_source() == source && |
1379 if_found == (ids.find(wifi_network->unique_id()) != ids.end())) | 1384 if_found == (ids.find(wifi_network->unique_id()) != ids.end())) |
1380 to_be_forgotten.push_back(wifi_network->service_path()); | 1385 to_be_forgotten.push_back(wifi_network->service_path()); |
1381 } | 1386 } |
(...skipping 16 matching lines...) Expand all Loading... | |
1398 std::pair<NetworkMap::iterator, bool> result = | 1403 std::pair<NetworkMap::iterator, bool> result = |
1399 remembered_network_map_.insert( | 1404 remembered_network_map_.insert( |
1400 std::make_pair(network->service_path(), network)); | 1405 std::make_pair(network->service_path(), network)); |
1401 DCHECK(result.second); // Should only get called with new network. | 1406 DCHECK(result.second); // Should only get called with new network. |
1402 | 1407 |
1403 // See if this is a policy-configured network that has meanwhile been removed. | 1408 // See if this is a policy-configured network that has meanwhile been removed. |
1404 // This situation may arise when the full list of remembered networks is not | 1409 // This situation may arise when the full list of remembered networks is not |
1405 // available to LoadOncNetworks(), which can happen due to the asynchronous | 1410 // available to LoadOncNetworks(), which can happen due to the asynchronous |
1406 // communication between shill and NetworkLibrary. Just tell shill to | 1411 // communication between shill and NetworkLibrary. Just tell shill to |
1407 // delete the network now. | 1412 // delete the network now. |
1408 const NetworkUIData::ONCSource source = network->ui_data().onc_source(); | 1413 const onc::ONCSource source = network->ui_data().onc_source(); |
1409 if (source == NetworkUIData::ONC_SOURCE_USER_POLICY || | 1414 if (source == onc::ONC_SOURCE_USER_POLICY || |
1410 source == NetworkUIData::ONC_SOURCE_DEVICE_POLICY) { | 1415 source == onc::ONC_SOURCE_DEVICE_POLICY) { |
1411 NetworkSourceMap::const_iterator network_id_set( | 1416 NetworkSourceMap::const_iterator network_id_set( |
1412 network_source_map_.find(source)); | 1417 network_source_map_.find(source)); |
1413 if (network_id_set != network_source_map_.end() && | 1418 if (network_id_set != network_source_map_.end() && |
1414 network_id_set->second.find(network->unique_id()) == | 1419 network_id_set->second.find(network->unique_id()) == |
1415 network_id_set->second.end()) { | 1420 network_id_set->second.end()) { |
1416 DeleteRememberedNetwork(network->service_path()); | 1421 DeleteRememberedNetwork(network->service_path()); |
1417 return false; | 1422 return false; |
1418 } | 1423 } |
1419 } | 1424 } |
1420 | 1425 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1746 GetTpmInfo(); | 1751 GetTpmInfo(); |
1747 return tpm_slot_; | 1752 return tpm_slot_; |
1748 } | 1753 } |
1749 | 1754 |
1750 const std::string& NetworkLibraryImplBase::GetTpmPin() { | 1755 const std::string& NetworkLibraryImplBase::GetTpmPin() { |
1751 GetTpmInfo(); | 1756 GetTpmInfo(); |
1752 return tpm_pin_; | 1757 return tpm_pin_; |
1753 } | 1758 } |
1754 | 1759 |
1755 } // namespace chromeos | 1760 } // namespace chromeos |
OLD | NEW |