| Index: chromeos/network/network_state_handler.cc
|
| diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
|
| index 125cefd93d29c47ffb580d08ef54e67d11e31c4e..44c7230b17a4280394b8e58368d9173d27b42c07 100644
|
| --- a/chromeos/network/network_state_handler.cc
|
| +++ b/chromeos/network/network_state_handler.cc
|
| @@ -298,22 +298,38 @@ void NetworkStateHandler::GetDeviceListByType(const NetworkTypePattern& type,
|
| }
|
|
|
| void NetworkStateHandler::GetFavoriteList(FavoriteStateList* list) const {
|
| - GetFavoriteListByType(NetworkTypePattern::Default(), list);
|
| + GetFavoriteListByType(NetworkTypePattern::Default(),
|
| + true /* configured_only */,
|
| + false /* visible_only */,
|
| + list);
|
| }
|
|
|
| void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type,
|
| + bool configured_only,
|
| + bool visible_only,
|
| FavoriteStateList* list) const {
|
| DCHECK(list);
|
| + std::set<std::string> visible_networks;
|
| + if (visible_only) {
|
| + // Prepare a set of visible network service paths for fast lookup.
|
| + for (ManagedStateList::const_iterator iter = network_list_.begin();
|
| + iter != network_list_.end(); ++iter) {
|
| + visible_networks.insert((*iter)->path());
|
| + }
|
| + }
|
| FavoriteStateList result;
|
| list->clear();
|
| for (ManagedStateList::const_iterator iter = favorite_list_.begin();
|
| iter != favorite_list_.end(); ++iter) {
|
| const FavoriteState* favorite = (*iter)->AsFavoriteState();
|
| DCHECK(favorite);
|
| - if (favorite->update_received() && favorite->IsInProfile() &&
|
| - favorite->Matches(type)) {
|
| - list->push_back(favorite);
|
| - }
|
| + if (!favorite->update_received() || !favorite->Matches(type))
|
| + continue;
|
| + if (configured_only && !favorite->IsInProfile())
|
| + continue;
|
| + if (visible_only && !ContainsKey(visible_networks, favorite->path()))
|
| + continue;
|
| + list->push_back(favorite);
|
| }
|
| }
|
|
|
| @@ -414,6 +430,8 @@ const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
|
|
|
| FavoriteStateList list;
|
| GetFavoriteListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap),
|
| + true /* configured_only */,
|
| + false /* visible_only */,
|
| &list);
|
| if (list.empty()) {
|
| NET_LOG_ERROR("GetEAPForEthernet",
|
|
|