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/managed_network_configuration_handler_impl.h" | 5 #include "chromeos/network/managed_network_configuration_handler_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 const Policies* policies = GetPoliciesForUser(userhash); | 711 const Policies* policies = GetPoliciesForUser(userhash); |
712 if (!policies) | 712 if (!policies) |
713 return NULL; | 713 return NULL; |
714 | 714 |
715 return &policies->global_network_config; | 715 return &policies->global_network_config; |
716 } | 716 } |
717 | 717 |
718 const base::DictionaryValue* | 718 const base::DictionaryValue* |
719 ManagedNetworkConfigurationHandlerImpl::FindPolicyByGuidAndProfile( | 719 ManagedNetworkConfigurationHandlerImpl::FindPolicyByGuidAndProfile( |
720 const std::string& guid, | 720 const std::string& guid, |
721 const std::string& profile_path) const { | 721 const std::string& profile_path, |
| 722 ::onc::ONCSource* onc_source) const { |
722 const NetworkProfile* profile = | 723 const NetworkProfile* profile = |
723 network_profile_handler_->GetProfileForPath(profile_path); | 724 network_profile_handler_->GetProfileForPath(profile_path); |
724 if (!profile) { | 725 if (!profile) { |
725 NET_LOG_ERROR("Profile path unknown:" + profile_path, guid); | 726 NET_LOG_ERROR("Profile path unknown:" + profile_path, guid); |
726 return NULL; | 727 return NULL; |
727 } | 728 } |
728 | 729 |
729 const Policies* policies = GetPoliciesForProfile(*profile); | 730 const Policies* policies = GetPoliciesForProfile(*profile); |
730 if (!policies) | 731 if (!policies) |
731 return NULL; | 732 return NULL; |
732 | 733 |
733 return GetByGUID(policies->per_network_config, guid); | 734 const base::DictionaryValue* policy = |
| 735 GetByGUID(policies->per_network_config, guid); |
| 736 if (policy && onc_source) { |
| 737 *onc_source = (profile->userhash.empty() ? ::onc::ONC_SOURCE_DEVICE_POLICY |
| 738 : ::onc::ONC_SOURCE_USER_POLICY); |
| 739 } |
| 740 return policy; |
734 } | 741 } |
735 | 742 |
736 const ManagedNetworkConfigurationHandlerImpl::Policies* | 743 const ManagedNetworkConfigurationHandlerImpl::Policies* |
737 ManagedNetworkConfigurationHandlerImpl::GetPoliciesForUser( | 744 ManagedNetworkConfigurationHandlerImpl::GetPoliciesForUser( |
738 const std::string& userhash) const { | 745 const std::string& userhash) const { |
739 UserToPoliciesMap::const_iterator it = policies_by_user_.find(userhash); | 746 UserToPoliciesMap::const_iterator it = policies_by_user_.find(userhash); |
740 if (it == policies_by_user_.end()) | 747 if (it == policies_by_user_.end()) |
741 return NULL; | 748 return NULL; |
742 return it->second.get(); | 749 return it->second.get(); |
743 } | 750 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 std::unique_ptr<base::DictionaryValue> network_properties, | 913 std::unique_ptr<base::DictionaryValue> network_properties, |
907 GetDevicePropertiesCallback send_callback, | 914 GetDevicePropertiesCallback send_callback, |
908 const std::string& error_name, | 915 const std::string& error_name, |
909 std::unique_ptr<base::DictionaryValue> error_data) { | 916 std::unique_ptr<base::DictionaryValue> error_data) { |
910 NET_LOG_ERROR("Error getting device properties", service_path); | 917 NET_LOG_ERROR("Error getting device properties", service_path); |
911 send_callback.Run(service_path, std::move(network_properties)); | 918 send_callback.Run(service_path, std::move(network_properties)); |
912 } | 919 } |
913 | 920 |
914 | 921 |
915 } // namespace chromeos | 922 } // namespace chromeos |
OLD | NEW |