| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 base::DictionaryValue* new_entry = network->DeepCopy(); | 457 base::DictionaryValue* new_entry = network->DeepCopy(); |
| 458 policies->per_network_config[guid] = base::WrapUnique(new_entry); | 458 policies->per_network_config[guid] = base::WrapUnique(new_entry); |
| 459 | 459 |
| 460 base::DictionaryValue* old_entry = old_per_network_config[guid].get(); | 460 base::DictionaryValue* old_entry = old_per_network_config[guid].get(); |
| 461 if (!old_entry || !old_entry->Equals(new_entry)) | 461 if (!old_entry || !old_entry->Equals(new_entry)) |
| 462 modified_policies.insert(guid); | 462 modified_policies.insert(guid); |
| 463 } | 463 } |
| 464 | 464 |
| 465 old_per_network_config.clear(); | 465 old_per_network_config.clear(); |
| 466 ApplyOrQueuePolicies(userhash, &modified_policies); | 466 ApplyOrQueuePolicies(userhash, &modified_policies); |
| 467 FOR_EACH_OBSERVER(NetworkPolicyObserver, observers_, | 467 for (auto& observer : observers_) |
| 468 PoliciesChanged(userhash)); | 468 observer.PoliciesChanged(userhash); |
| 469 } | 469 } |
| 470 | 470 |
| 471 bool ManagedNetworkConfigurationHandlerImpl::IsAnyPolicyApplicationRunning() | 471 bool ManagedNetworkConfigurationHandlerImpl::IsAnyPolicyApplicationRunning() |
| 472 const { | 472 const { |
| 473 return !policy_applicators_.empty() || !queued_modified_policies_.empty(); | 473 return !policy_applicators_.empty() || !queued_modified_policies_.empty(); |
| 474 } | 474 } |
| 475 | 475 |
| 476 bool ManagedNetworkConfigurationHandlerImpl::ApplyOrQueuePolicies( | 476 bool ManagedNetworkConfigurationHandlerImpl::ApplyOrQueuePolicies( |
| 477 const std::string& userhash, | 477 const std::string& userhash, |
| 478 std::set<std::string>* modified_policies) { | 478 std::set<std::string>* modified_policies) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 FROM_HERE, policy_applicators_[userhash].release()); | 597 FROM_HERE, policy_applicators_[userhash].release()); |
| 598 policy_applicators_.erase(userhash); | 598 policy_applicators_.erase(userhash); |
| 599 | 599 |
| 600 if (base::ContainsKey(queued_modified_policies_, userhash)) { | 600 if (base::ContainsKey(queued_modified_policies_, userhash)) { |
| 601 std::set<std::string> modified_policies; | 601 std::set<std::string> modified_policies; |
| 602 queued_modified_policies_[userhash].swap(modified_policies); | 602 queued_modified_policies_[userhash].swap(modified_policies); |
| 603 // Remove |userhash| from the queue. | 603 // Remove |userhash| from the queue. |
| 604 queued_modified_policies_.erase(userhash); | 604 queued_modified_policies_.erase(userhash); |
| 605 ApplyOrQueuePolicies(userhash, &modified_policies); | 605 ApplyOrQueuePolicies(userhash, &modified_policies); |
| 606 } else { | 606 } else { |
| 607 FOR_EACH_OBSERVER( | 607 for (auto& observer : observers_) |
| 608 NetworkPolicyObserver, observers_, PoliciesApplied(userhash)); | 608 observer.PoliciesApplied(userhash); |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 const base::DictionaryValue* | 612 const base::DictionaryValue* |
| 613 ManagedNetworkConfigurationHandlerImpl::FindPolicyByGUID( | 613 ManagedNetworkConfigurationHandlerImpl::FindPolicyByGUID( |
| 614 const std::string userhash, | 614 const std::string userhash, |
| 615 const std::string& guid, | 615 const std::string& guid, |
| 616 ::onc::ONCSource* onc_source) const { | 616 ::onc::ONCSource* onc_source) const { |
| 617 *onc_source = ::onc::ONC_SOURCE_NONE; | 617 *onc_source = ::onc::ONC_SOURCE_NONE; |
| 618 | 618 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 network_device_handler_ = network_device_handler; | 723 network_device_handler_ = network_device_handler; |
| 724 network_profile_handler_->AddObserver(this); | 724 network_profile_handler_->AddObserver(this); |
| 725 prohibited_technologies_handler_ = prohibited_technologies_handler; | 725 prohibited_technologies_handler_ = prohibited_technologies_handler; |
| 726 } | 726 } |
| 727 | 727 |
| 728 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork( | 728 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork( |
| 729 const std::string& service_path, | 729 const std::string& service_path, |
| 730 const std::string& guid) { | 730 const std::string& guid) { |
| 731 if (service_path.empty()) | 731 if (service_path.empty()) |
| 732 return; | 732 return; |
| 733 FOR_EACH_OBSERVER( | 733 for (auto& observer : observers_) |
| 734 NetworkPolicyObserver, observers_, PolicyAppliedToNetwork(service_path)); | 734 observer.PolicyAppliedToNetwork(service_path); |
| 735 } | 735 } |
| 736 | 736 |
| 737 // Get{Managed}Properties helpers | 737 // Get{Managed}Properties helpers |
| 738 | 738 |
| 739 void ManagedNetworkConfigurationHandlerImpl::GetDeviceStateProperties( | 739 void ManagedNetworkConfigurationHandlerImpl::GetDeviceStateProperties( |
| 740 const std::string& service_path, | 740 const std::string& service_path, |
| 741 base::DictionaryValue* properties) { | 741 base::DictionaryValue* properties) { |
| 742 std::string connection_state; | 742 std::string connection_state; |
| 743 properties->GetStringWithoutPathExpansion( | 743 properties->GetStringWithoutPathExpansion( |
| 744 shill::kStateProperty, &connection_state); | 744 shill::kStateProperty, &connection_state); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 std::unique_ptr<base::DictionaryValue> network_properties, | 852 std::unique_ptr<base::DictionaryValue> network_properties, |
| 853 GetDevicePropertiesCallback send_callback, | 853 GetDevicePropertiesCallback send_callback, |
| 854 const std::string& error_name, | 854 const std::string& error_name, |
| 855 std::unique_ptr<base::DictionaryValue> error_data) { | 855 std::unique_ptr<base::DictionaryValue> error_data) { |
| 856 NET_LOG_ERROR("Error getting device properties", service_path); | 856 NET_LOG_ERROR("Error getting device properties", service_path); |
| 857 send_callback.Run(service_path, std::move(network_properties)); | 857 send_callback.Run(service_path, std::move(network_properties)); |
| 858 } | 858 } |
| 859 | 859 |
| 860 | 860 |
| 861 } // namespace chromeos | 861 } // namespace chromeos |
| OLD | NEW |