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

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: 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 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 NetworkStateBase* ethernet) const {
stevenjb 2013/09/16 23:53:24 I don't especially like passing a NetworkState* ba
pneubeck (no reviews) 2013/09/17 12:48:36 Done.
369 // The same EAP service is shared for all ethernet services/devices.
370 // However EAP is used/enabled per device and only if the connection was
371 // successfully established.
372 DCHECK(ethernet);
373 DCHECK(ethernet->type() == flimflam::kTypeEthernet);
374 const NetworkState* ethernet_service = ethernet->AsNetworkState();
375 if (!ethernet_service || !ethernet_service->IsConnectedState())
376 return NULL;
377 const DeviceState* device = GetDeviceState(ethernet_service->device_path());
378 if (!device) {
379 NET_LOG_ERROR(
380 "GetEAPForEthernet",
381 base::StringPrintf("Unknown device %s of connected ethernet service %s",
382 ethernet_service->path().c_str(),
383 ethernet_service->device_path().c_str()));
384 return NULL;
385 }
386 if (!device->eap_authentication_completed())
387 return NULL;
388
389 FavoriteStateList list;
390 GetFavoriteListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap),
391 &list);
392 if (list.empty()) {
393 NET_LOG_ERROR("GetEAPForEthernet",
394 base::StringPrintf(
395 "Ethernet service %s connected using EAP, but no "
396 "EAP service found.",
397 ethernet_service->path().c_str()));
398 return NULL;
399 }
400 DCHECK(list.size() == 1);
401 return list.front();
402 }
403
365 void NetworkStateHandler::GetNetworkStatePropertiesForTest( 404 void NetworkStateHandler::GetNetworkStatePropertiesForTest(
366 base::DictionaryValue* dictionary) const { 405 base::DictionaryValue* dictionary) const {
367 for (ManagedStateList::const_iterator iter = network_list_.begin(); 406 for (ManagedStateList::const_iterator iter = network_list_.begin();
368 iter != network_list_.end(); ++iter) { 407 iter != network_list_.end(); ++iter) {
369 base::DictionaryValue* network_dict = new base::DictionaryValue; 408 base::DictionaryValue* network_dict = new base::DictionaryValue;
370 (*iter)->AsNetworkState()->GetProperties(network_dict); 409 (*iter)->AsNetworkState()->GetProperties(network_dict);
371 dictionary->SetWithoutPathExpansion((*iter)->path(), network_dict); 410 dictionary->SetWithoutPathExpansion((*iter)->path(), network_dict);
372 } 411 }
373 } 412 }
374 413
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 594
556 std::string detail = device->name() + "." + key; 595 std::string detail = device->name() + "." + key;
557 detail += " = " + network_event_log::ValueAsString(value); 596 detail += " = " + network_event_log::ValueAsString(value);
558 NET_LOG_EVENT("DevicePropertyUpdated", detail); 597 NET_LOG_EVENT("DevicePropertyUpdated", detail);
559 598
560 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, 599 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
561 DeviceListChanged()); 600 DeviceListChanged());
562 601
563 if (key == flimflam::kScanningProperty && device->scanning() == false) 602 if (key == flimflam::kScanningProperty && device->scanning() == false)
564 ScanCompleted(device->type()); 603 ScanCompleted(device->type());
604 if (key == shill::kEapAuthenticationCompletedProperty) {
605 // Notify a change for each Ethernet service using this device.
606 NetworkStateList ethernet_services;
607 GetNetworkListByType(NetworkTypePattern::Ethernet(), &ethernet_services);
608 for (NetworkStateList::const_iterator it = ethernet_services.begin();
609 it != ethernet_services.end(); ++it) {
610 const NetworkState* ethernet_service = *it;
611 if (ethernet_service->update_received() ||
stevenjb 2013/09/16 23:53:24 If this is false, then there should be an update i
pneubeck (no reviews) 2013/09/17 12:48:36 The intention here is: Sometime after you plugin
stevenjb 2013/09/17 16:22:59 In that case we should call RequestUpdateForNetwor
612 ethernet_service->device_path() != device->path()) {
613 continue;
614 }
615 if (ethernet_service->path() == default_network_path_)
616 OnDefaultNetworkChanged();
617 NetworkPropertiesUpdated(ethernet_service);
618 }
619 }
565 } 620 }
566 621
567 void NetworkStateHandler::CheckPortalListChanged( 622 void NetworkStateHandler::CheckPortalListChanged(
568 const std::string& check_portal_list) { 623 const std::string& check_portal_list) {
569 check_portal_list_ = check_portal_list; 624 check_portal_list_ = check_portal_list;
570 } 625 }
571 626
572 void NetworkStateHandler::NotifyManagerPropertyChanged() { 627 void NetworkStateHandler::NotifyManagerPropertyChanged() {
573 NET_LOG_DEBUG("NotifyManagerPropertyChanged", ""); 628 NET_LOG_DEBUG("NotifyManagerPropertyChanged", "");
574 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, 629 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 788 }
734 789
735 if (type.MatchesType(flimflam::kTypeCellular)) 790 if (type.MatchesType(flimflam::kTypeCellular))
736 return flimflam::kTypeCellular; 791 return flimflam::kTypeCellular;
737 792
738 NOTREACHED(); 793 NOTREACHED();
739 return std::string(); 794 return std::string();
740 } 795 }
741 796
742 } // namespace chromeos 797 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698