OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/network_connection_handler.h" | 5 #include "chromeos/network/network_connection_handler.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/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 if (!global_network_config) | 780 if (!global_network_config) |
781 return; | 781 return; |
782 | 782 |
783 applied_autoconnect_policy_ = true; | 783 applied_autoconnect_policy_ = true; |
784 | 784 |
785 bool only_policy_autoconnect = false; | 785 bool only_policy_autoconnect = false; |
786 global_network_config->GetBooleanWithoutPathExpansion( | 786 global_network_config->GetBooleanWithoutPathExpansion( |
787 ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, | 787 ::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect, |
788 &only_policy_autoconnect); | 788 &only_policy_autoconnect); |
789 | 789 |
790 if (!only_policy_autoconnect) | 790 if (only_policy_autoconnect) |
791 return; | 791 DisconnectFromUnmanagedSharedWiFiNetworks(); |
792 | 792 |
793 NET_LOG_DEBUG("DisconnectIfPolicyRequires", | 793 ConnectToBestNetworkAfterLogin(); |
794 "Disconnecting unmanaged and shared networks if any exist."); | 794 } |
795 | 795 |
796 // Get the list of unmanaged & shared networks that are connected or | 796 void NetworkConnectionHandler::DisconnectFromUnmanagedSharedWiFiNetworks() { |
797 // connecting. | 797 NET_LOG_DEBUG("DisconnectFromUnmanagedSharedWiFiNetworks", ""); |
| 798 |
798 NetworkStateHandler::NetworkStateList networks; | 799 NetworkStateHandler::NetworkStateList networks; |
799 network_state_handler_->GetVisibleNetworkListByType( | 800 network_state_handler_->GetVisibleNetworkListByType( |
800 NetworkTypePattern::Wireless(), &networks); | 801 NetworkTypePattern::Wireless(), &networks); |
801 for (NetworkStateHandler::NetworkStateList::const_iterator it = | 802 for (NetworkStateHandler::NetworkStateList::const_iterator it = |
802 networks.begin(); | 803 networks.begin(); |
803 it != networks.end(); | 804 it != networks.end(); |
804 ++it) { | 805 ++it) { |
805 const NetworkState* network = *it; | 806 const NetworkState* network = *it; |
806 if (!(network->IsConnectingState() || network->IsConnectedState())) | 807 if (!(network->IsConnectingState() || network->IsConnectedState())) |
807 break; // Connected and connecting networks are listed first. | 808 break; // Connected and connecting networks are listed first. |
808 | 809 |
809 if (network->IsPrivate()) | 810 if (network->IsPrivate()) |
810 continue; | 811 continue; |
811 | 812 |
812 const bool network_is_policy_managed = | 813 const bool network_is_policy_managed = |
813 !network->profile_path().empty() && !network->guid().empty() && | 814 !network->profile_path().empty() && !network->guid().empty() && |
814 managed_configuration_handler_->FindPolicyByGuidAndProfile( | 815 managed_configuration_handler_->FindPolicyByGuidAndProfile( |
815 network->guid(), network->profile_path()); | 816 network->guid(), network->profile_path()); |
816 if (network_is_policy_managed) | 817 if (network_is_policy_managed) |
817 continue; | 818 continue; |
818 | 819 |
819 NET_LOG_EVENT("Disconnect Forced by Policy", network->path()); | 820 NET_LOG_EVENT("Disconnect Forced by Policy", network->path()); |
820 CallShillDisconnect( | 821 CallShillDisconnect( |
821 network->path(), base::Closure(), network_handler::ErrorCallback()); | 822 network->path(), base::Closure(), network_handler::ErrorCallback()); |
822 } | 823 } |
823 | |
824 ConnectToBestNetworkAfterLogin(); | |
825 } | 824 } |
826 | 825 |
827 } // namespace chromeos | 826 } // namespace chromeos |
OLD | NEW |