Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8018)

Unified Diff: chromeos/network/network_state_handler.cc

Issue 23451044: Add an Ethernet EAP policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on NetworkStateBase removal and addressed comments. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/network/network_state_handler.cc
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
index fbb75d5b9d0e9ce557c40c70cb3ca60eb73c4ae8..3c1df4e0f03410699699823d0a3932a4870c6f69 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -271,9 +271,7 @@ void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type,
iter != network_list_.end(); ++iter) {
const NetworkState* network = (*iter)->AsNetworkState();
DCHECK(network);
- if (!network->update_received())
- continue;
- if (network->Matches(type))
+ if (network->update_received() && network->Matches(type))
list->push_back(network);
}
}
@@ -285,13 +283,17 @@ void NetworkStateHandler::GetDeviceList(DeviceStateList* list) const {
iter != device_list_.end(); ++iter) {
const DeviceState* device = (*iter)->AsDeviceState();
DCHECK(device);
- if (!device->update_received())
- continue;
- list->push_back(device);
+ if (device->update_received())
+ list->push_back(device);
}
}
void NetworkStateHandler::GetFavoriteList(FavoriteStateList* list) const {
+ GetFavoriteListByType(NetworkTypePattern::Default(), list);
+}
+
+void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type,
+ FavoriteStateList* list) const {
DCHECK(list);
FavoriteStateList result;
list->clear();
@@ -299,10 +301,10 @@ void NetworkStateHandler::GetFavoriteList(FavoriteStateList* list) const {
iter != favorite_list_.end(); ++iter) {
const FavoriteState* favorite = (*iter)->AsFavoriteState();
DCHECK(favorite);
- if (!favorite->update_received())
- continue;
- if (favorite->is_favorite())
+ if (favorite->update_received() && favorite->is_favorite() &&
+ favorite->Matches(type)) {
list->push_back(favorite);
+ }
}
}
@@ -362,6 +364,50 @@ void NetworkStateHandler::SetCheckPortalList(
shill_property_handler_->SetCheckPortalList(check_portal_list);
}
+const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
+ const std::string& service_path) const {
+ const NetworkState* network = GetNetworkState(service_path);
+ if (!network) {
+ NET_LOG_ERROR(
+ "GetEAPForEthernet",
+ base::StringPrintf("Unknown service path %s", service_path.c_str()));
stevenjb 2013/09/17 16:22:59 nit: + instead of StringPrintf ("foo" + bar where
pneubeck (no reviews) 2013/09/30 20:08:31 Done.
+ return NULL;
+ }
+ if (network->type() != flimflam::kTypeEthernet ||
+ !network->IsConnectedState()) {
+ return NULL;
+ }
+
+ // The same EAP service is shared for all ethernet services/devices.
+ // However EAP is used/enabled per device and only if the connection was
+ // successfully established.
+ const DeviceState* device = GetDeviceState(network->device_path());
+ if (!device) {
+ NET_LOG_ERROR(
+ "GetEAPForEthernet",
+ base::StringPrintf("Unknown device %s of connected ethernet service %s",
+ service_path.c_str(),
+ network->device_path().c_str()));
+ return NULL;
+ }
+ if (!device->eap_authentication_completed())
+ return NULL;
+
+ FavoriteStateList list;
+ GetFavoriteListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap),
+ &list);
+ if (list.empty()) {
+ NET_LOG_ERROR("GetEAPForEthernet",
+ base::StringPrintf(
+ "Ethernet service %s connected using EAP, but no "
+ "EAP service found.",
+ service_path.c_str()));
+ return NULL;
+ }
+ DCHECK(list.size() == 1);
+ return list.front();
+}
+
void NetworkStateHandler::GetNetworkStatePropertiesForTest(
base::DictionaryValue* dictionary) const {
for (ManagedStateList::const_iterator iter = network_list_.begin();
@@ -562,6 +608,22 @@ void NetworkStateHandler::UpdateDeviceProperty(const std::string& device_path,
if (key == flimflam::kScanningProperty && device->scanning() == false)
ScanCompleted(device->type());
+ if (key == shill::kEapAuthenticationCompletedProperty) {
+ // Notify a change for each Ethernet service using this device.
+ NetworkStateList ethernet_services;
+ GetNetworkListByType(NetworkTypePattern::Ethernet(), &ethernet_services);
+ for (NetworkStateList::const_iterator it = ethernet_services.begin();
+ it != ethernet_services.end(); ++it) {
+ const NetworkState* ethernet_service = *it;
+ if (ethernet_service->update_received() ||
+ ethernet_service->device_path() != device->path()) {
+ continue;
+ }
+ if (ethernet_service->path() == default_network_path_)
+ OnDefaultNetworkChanged();
+ NetworkPropertiesUpdated(ethernet_service);
+ }
+ }
}
void NetworkStateHandler::CheckPortalListChanged(

Powered by Google App Engine
This is Rietveld 408576698