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 "chromeos/network/policy_util.h" | 5 #include "chromeos/network/policy_util.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/values.h" | 10 #include "base/values.h" |
9 #include "chromeos/network/network_profile.h" | 11 #include "chromeos/network/network_profile.h" |
10 #include "chromeos/network/network_ui_data.h" | 12 #include "chromeos/network/network_ui_data.h" |
11 #include "chromeos/network/onc/onc_merger.h" | 13 #include "chromeos/network/onc/onc_merger.h" |
12 #include "chromeos/network/onc/onc_normalizer.h" | 14 #include "chromeos/network/onc/onc_normalizer.h" |
13 #include "chromeos/network/onc/onc_signature.h" | 15 #include "chromeos/network/onc/onc_signature.h" |
14 #include "chromeos/network/onc/onc_translator.h" | 16 #include "chromeos/network/onc/onc_translator.h" |
15 #include "chromeos/network/onc/onc_utils.h" | 17 #include "chromeos/network/onc/onc_utils.h" |
16 #include "chromeos/network/shill_property_util.h" | 18 #include "chromeos/network/shill_property_util.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 bool allow_only_policy_autoconnect = false; | 259 bool allow_only_policy_autoconnect = false; |
258 global_policy->GetBooleanWithoutPathExpansion( | 260 global_policy->GetBooleanWithoutPathExpansion( |
259 ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, | 261 ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, |
260 &allow_only_policy_autoconnect); | 262 &allow_only_policy_autoconnect); |
261 if (allow_only_policy_autoconnect) { | 263 if (allow_only_policy_autoconnect) { |
262 ApplyGlobalAutoconnectPolicy(profile->type(), | 264 ApplyGlobalAutoconnectPolicy(profile->type(), |
263 augmented_onc_network.get()); | 265 augmented_onc_network.get()); |
264 } | 266 } |
265 } | 267 } |
266 | 268 |
267 return augmented_onc_network.Pass(); | 269 return augmented_onc_network; |
268 } | 270 } |
269 | 271 |
270 void SetShillPropertiesForGlobalPolicy( | 272 void SetShillPropertiesForGlobalPolicy( |
271 const base::DictionaryValue& shill_dictionary, | 273 const base::DictionaryValue& shill_dictionary, |
272 const base::DictionaryValue& global_network_policy, | 274 const base::DictionaryValue& global_network_policy, |
273 base::DictionaryValue* shill_properties_to_update) { | 275 base::DictionaryValue* shill_properties_to_update) { |
274 // kAllowOnlyPolicyNetworksToAutoconnect is currently the only global config. | 276 // kAllowOnlyPolicyNetworksToAutoconnect is currently the only global config. |
275 | 277 |
276 std::string type; | 278 std::string type; |
277 shill_dictionary.GetStringWithoutPathExpansion(shill::kTypeProperty, &type); | 279 shill_dictionary.GetStringWithoutPathExpansion(shill::kTypeProperty, &type); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // property and might write it into logs or other insecure places. Thus, we | 382 // property and might write it into logs or other insecure places. Thus, we |
381 // have to remove or mask credentials. | 383 // have to remove or mask credentials. |
382 // | 384 // |
383 // Shill's GetProperties doesn't return credentials. Masking credentials | 385 // Shill's GetProperties doesn't return credentials. Masking credentials |
384 // instead of just removing them, allows remembering if a credential is set | 386 // instead of just removing them, allows remembering if a credential is set |
385 // or not. | 387 // or not. |
386 scoped_ptr<base::DictionaryValue> sanitized_user_settings( | 388 scoped_ptr<base::DictionaryValue> sanitized_user_settings( |
387 onc::MaskCredentialsInOncObject(onc::kNetworkConfigurationSignature, | 389 onc::MaskCredentialsInOncObject(onc::kNetworkConfigurationSignature, |
388 *user_settings, | 390 *user_settings, |
389 kFakeCredential)); | 391 kFakeCredential)); |
390 ui_data->set_user_settings(sanitized_user_settings.Pass()); | 392 ui_data->set_user_settings(std::move(sanitized_user_settings)); |
391 } | 393 } |
392 | 394 |
393 shill_property_util::SetUIData(*ui_data, shill_dictionary.get()); | 395 shill_property_util::SetUIData(*ui_data, shill_dictionary.get()); |
394 | 396 |
395 VLOG(2) << "Created Shill properties: " << *shill_dictionary; | 397 VLOG(2) << "Created Shill properties: " << *shill_dictionary; |
396 | 398 |
397 return shill_dictionary.Pass(); | 399 return shill_dictionary; |
398 } | 400 } |
399 | 401 |
400 const base::DictionaryValue* FindMatchingPolicy( | 402 const base::DictionaryValue* FindMatchingPolicy( |
401 const GuidToPolicyMap& policies, | 403 const GuidToPolicyMap& policies, |
402 const base::DictionaryValue& actual_network) { | 404 const base::DictionaryValue& actual_network) { |
403 for (GuidToPolicyMap::const_iterator it = policies.begin(); | 405 for (GuidToPolicyMap::const_iterator it = policies.begin(); |
404 it != policies.end(); ++it) { | 406 it != policies.end(); ++it) { |
405 if (IsPolicyMatching(*it->second, actual_network)) | 407 if (IsPolicyMatching(*it->second, actual_network)) |
406 return it->second; | 408 return it->second; |
407 } | 409 } |
408 return NULL; | 410 return NULL; |
409 } | 411 } |
410 | 412 |
411 } // namespace policy_util | 413 } // namespace policy_util |
412 | 414 |
413 } // namespace chromeos | 415 } // namespace chromeos |
OLD | NEW |