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

Side by Side 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. Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_state_handler.h" 5 #include "chromeos/network/network_state_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 264 }
265 265
266 void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type, 266 void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type,
267 NetworkStateList* list) const { 267 NetworkStateList* list) const {
268 DCHECK(list); 268 DCHECK(list);
269 list->clear(); 269 list->clear();
270 for (ManagedStateList::const_iterator iter = network_list_.begin(); 270 for (ManagedStateList::const_iterator iter = network_list_.begin();
271 iter != network_list_.end(); ++iter) { 271 iter != network_list_.end(); ++iter) {
272 const NetworkState* network = (*iter)->AsNetworkState(); 272 const NetworkState* network = (*iter)->AsNetworkState();
273 DCHECK(network); 273 DCHECK(network);
274 if (!network->update_received()) 274 if (network->update_received() && network->Matches(type))
275 continue;
276 if (network->Matches(type))
277 list->push_back(network); 275 list->push_back(network);
278 } 276 }
279 } 277 }
280 278
281 void NetworkStateHandler::GetDeviceList(DeviceStateList* list) const { 279 void NetworkStateHandler::GetDeviceList(DeviceStateList* list) const {
282 DCHECK(list); 280 DCHECK(list);
283 list->clear(); 281 list->clear();
284 for (ManagedStateList::const_iterator iter = device_list_.begin(); 282 for (ManagedStateList::const_iterator iter = device_list_.begin();
285 iter != device_list_.end(); ++iter) { 283 iter != device_list_.end(); ++iter) {
286 const DeviceState* device = (*iter)->AsDeviceState(); 284 const DeviceState* device = (*iter)->AsDeviceState();
287 DCHECK(device); 285 DCHECK(device);
288 if (!device->update_received()) 286 if (device->update_received())
289 continue; 287 list->push_back(device);
290 list->push_back(device);
291 } 288 }
292 } 289 }
293 290
294 void NetworkStateHandler::GetFavoriteList(FavoriteStateList* list) const { 291 void NetworkStateHandler::GetFavoriteList(FavoriteStateList* list) const {
292 GetFavoriteListByType(NetworkTypePattern::Default(), list);
293 }
294
295 void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type,
296 FavoriteStateList* list) const {
295 DCHECK(list); 297 DCHECK(list);
296 FavoriteStateList result; 298 FavoriteStateList result;
297 list->clear(); 299 list->clear();
298 for (ManagedStateList::const_iterator iter = favorite_list_.begin(); 300 for (ManagedStateList::const_iterator iter = favorite_list_.begin();
299 iter != favorite_list_.end(); ++iter) { 301 iter != favorite_list_.end(); ++iter) {
300 const FavoriteState* favorite = (*iter)->AsFavoriteState(); 302 const FavoriteState* favorite = (*iter)->AsFavoriteState();
301 DCHECK(favorite); 303 DCHECK(favorite);
302 if (!favorite->update_received()) 304 if (favorite->update_received() && favorite->is_favorite() &&
303 continue; 305 favorite->Matches(type)) {
304 if (favorite->is_favorite())
305 list->push_back(favorite); 306 list->push_back(favorite);
307 }
306 } 308 }
307 } 309 }
308 310
309 const FavoriteState* NetworkStateHandler::GetFavoriteState( 311 const FavoriteState* NetworkStateHandler::GetFavoriteState(
310 const std::string& service_path) const { 312 const std::string& service_path) const {
311 ManagedState* managed = 313 ManagedState* managed =
312 GetModifiableManagedState(&favorite_list_, service_path); 314 GetModifiableManagedState(&favorite_list_, service_path);
313 if (!managed) 315 if (!managed)
314 return NULL; 316 return NULL;
315 DCHECK(managed->update_received()); 317 DCHECK(managed->update_received());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 ManagedState::MANAGED_TYPE_NETWORK, network->path()); 357 ManagedState::MANAGED_TYPE_NETWORK, network->path());
356 } 358 }
357 } 359 }
358 360
359 void NetworkStateHandler::SetCheckPortalList( 361 void NetworkStateHandler::SetCheckPortalList(
360 const std::string& check_portal_list) { 362 const std::string& check_portal_list) {
361 NET_LOG_EVENT("SetCheckPortalList", check_portal_list); 363 NET_LOG_EVENT("SetCheckPortalList", check_portal_list);
362 shill_property_handler_->SetCheckPortalList(check_portal_list); 364 shill_property_handler_->SetCheckPortalList(check_portal_list);
363 } 365 }
364 366
367 const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
368 const std::string& service_path) const {
369 const NetworkState* network = GetNetworkState(service_path);
370 if (!network) {
371 NET_LOG_ERROR("GetEAPForEthernet", "Unknown service path " + service_path);
372 return NULL;
373 }
374 if (network->type() != flimflam::kTypeEthernet ||
stevenjb 2013/09/28 00:37:45 Shouldn't this trigger an error?
pneubeck (no reviews) 2013/09/30 20:08:31 Done.
375 !network->IsConnectedState()) {
376 return NULL;
377 }
378
379 // The same EAP service is shared for all ethernet services/devices.
380 // However EAP is used/enabled per device and only if the connection was
381 // successfully established.
382 const DeviceState* device = GetDeviceState(network->device_path());
383 if (!device) {
384 NET_LOG_ERROR(
385 "GetEAPForEthernet",
386 base::StringPrintf("Unknown device %s of connected ethernet service %s",
387 service_path.c_str(),
388 network->device_path().c_str()));
389 return NULL;
390 }
391 if (!device->eap_authentication_completed())
392 return NULL;
393
394 FavoriteStateList list;
395 GetFavoriteListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap),
396 &list);
397 if (list.empty()) {
398 NET_LOG_ERROR("GetEAPForEthernet",
399 base::StringPrintf(
400 "Ethernet service %s connected using EAP, but no "
401 "EAP service found.",
402 service_path.c_str()));
403 return NULL;
404 }
405 DCHECK(list.size() == 1);
406 return list.front();
407 }
408
365 void NetworkStateHandler::GetNetworkStatePropertiesForTest( 409 void NetworkStateHandler::GetNetworkStatePropertiesForTest(
366 base::DictionaryValue* dictionary) const { 410 base::DictionaryValue* dictionary) const {
367 for (ManagedStateList::const_iterator iter = network_list_.begin(); 411 for (ManagedStateList::const_iterator iter = network_list_.begin();
368 iter != network_list_.end(); ++iter) { 412 iter != network_list_.end(); ++iter) {
369 base::DictionaryValue* network_dict = new base::DictionaryValue; 413 base::DictionaryValue* network_dict = new base::DictionaryValue;
370 (*iter)->AsNetworkState()->GetProperties(network_dict); 414 (*iter)->AsNetworkState()->GetProperties(network_dict);
371 dictionary->SetWithoutPathExpansion((*iter)->path(), network_dict); 415 dictionary->SetWithoutPathExpansion((*iter)->path(), network_dict);
372 } 416 }
373 } 417 }
374 418
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return; 597 return;
554 598
555 std::string detail = device->name() + "." + key; 599 std::string detail = device->name() + "." + key;
556 detail += " = " + network_event_log::ValueAsString(value); 600 detail += " = " + network_event_log::ValueAsString(value);
557 NET_LOG_EVENT("DevicePropertyUpdated", detail); 601 NET_LOG_EVENT("DevicePropertyUpdated", detail);
558 602
559 NotifyDeviceListChanged(); 603 NotifyDeviceListChanged();
560 604
561 if (key == shill::kScanningProperty && device->scanning() == false) 605 if (key == shill::kScanningProperty && device->scanning() == false)
562 ScanCompleted(device->type()); 606 ScanCompleted(device->type());
607 if (key == shill::kEapAuthenticationCompletedProperty) {
608 // Notify a change for each Ethernet service using this device.
609 NetworkStateList ethernet_services;
610 GetNetworkListByType(NetworkTypePattern::Ethernet(), &ethernet_services);
611 for (NetworkStateList::const_iterator it = ethernet_services.begin();
612 it != ethernet_services.end(); ++it) {
613 const NetworkState* ethernet_service = *it;
614 if (ethernet_service->update_received() ||
615 ethernet_service->device_path() != device->path()) {
616 continue;
617 }
618 if (ethernet_service->path() == default_network_path_)
619 OnDefaultNetworkChanged();
620 NetworkPropertiesUpdated(ethernet_service);
621 }
622 }
563 } 623 }
564 624
565 void NetworkStateHandler::CheckPortalListChanged( 625 void NetworkStateHandler::CheckPortalListChanged(
566 const std::string& check_portal_list) { 626 const std::string& check_portal_list) {
567 check_portal_list_ = check_portal_list; 627 check_portal_list_ = check_portal_list;
568 } 628 }
569 629
570 void NetworkStateHandler::TechnologyListChanged() { 630 void NetworkStateHandler::TechnologyListChanged() {
571 // Eventually we would like to replace Technology state with Device state. 631 // Eventually we would like to replace Technology state with Device state.
572 // For now, treat technology state changes as device list changes. 632 // For now, treat technology state changes as device list changes.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } 795 }
736 796
737 if (type.MatchesType(shill::kTypeCellular)) 797 if (type.MatchesType(shill::kTypeCellular))
738 return shill::kTypeCellular; 798 return shill::kTypeCellular;
739 799
740 NOTREACHED(); 800 NOTREACHED();
741 return std::string(); 801 return std::string();
742 } 802 }
743 803
744 } // namespace chromeos 804 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698