| Index: chromeos/network/network_state_handler.cc
|
| diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
|
| index 1f061974199c01bbe503089b8bc4d85385524d23..125cefd93d29c47ffb580d08ef54e67d11e31c4e 100644
|
| --- a/chromeos/network/network_state_handler.cc
|
| +++ b/chromeos/network/network_state_handler.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/format_macros.h"
|
| +#include "base/guid.h"
|
| #include "base/location.h"
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram.h"
|
| @@ -309,7 +310,7 @@ void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type,
|
| iter != favorite_list_.end(); ++iter) {
|
| const FavoriteState* favorite = (*iter)->AsFavoriteState();
|
| DCHECK(favorite);
|
| - if (favorite->update_received() && favorite->IsFavorite() &&
|
| + if (favorite->update_received() && favorite->IsInProfile() &&
|
| favorite->Matches(type)) {
|
| list->push_back(favorite);
|
| }
|
| @@ -324,11 +325,22 @@ const FavoriteState* NetworkStateHandler::GetFavoriteState(
|
| return NULL;
|
| const FavoriteState* favorite = managed->AsFavoriteState();
|
| DCHECK(favorite);
|
| - if (!favorite->update_received() || !favorite->IsFavorite())
|
| + if (!favorite->update_received() || !favorite->IsInProfile())
|
| return NULL;
|
| return favorite;
|
| }
|
|
|
| +const FavoriteState* NetworkStateHandler::GetFavoriteStateFromGuid(
|
| + const std::string& guid) const {
|
| + for (ManagedStateList::const_iterator iter = favorite_list_.begin();
|
| + iter != favorite_list_.end(); ++iter) {
|
| + const FavoriteState* favorite = (*iter)->AsFavoriteState();
|
| + if (favorite->guid() == guid)
|
| + return favorite;
|
| + }
|
| + return NULL;
|
| +}
|
| +
|
| void NetworkStateHandler::RequestScan() const {
|
| NET_LOG_USER("RequestScan", "");
|
| shill_property_handler_->RequestScan();
|
| @@ -489,7 +501,7 @@ void NetworkStateHandler::UpdateManagedStateProperties(
|
| // A Favorite may not have been created yet if it was added later (e.g.
|
| // through ConfigureService) since ServiceCompleteList updates are not
|
| // emitted. Add and update the state here.
|
| - managed = new FavoriteState(path);
|
| + managed = ManagedState::Create(type, path);
|
| managed_list->push_back(managed);
|
| }
|
| managed->set_update_received();
|
| @@ -507,6 +519,7 @@ void NetworkStateHandler::UpdateManagedStateProperties(
|
| }
|
| managed->InitialPropertiesReceived(properties);
|
| }
|
| + UpdateGuid(managed);
|
| managed->set_update_requested(false);
|
| }
|
|
|
| @@ -681,7 +694,7 @@ void NetworkStateHandler::ManagedStateListChanged(
|
| for (ManagedStateList::iterator iter = favorite_list_.begin();
|
| iter != favorite_list_.end(); ++iter) {
|
| FavoriteState* favorite = (*iter)->AsFavoriteState();
|
| - if (!favorite->IsFavorite())
|
| + if (!favorite->IsInProfile())
|
| continue;
|
| if (favorite->IsPrivate())
|
| ++unshared;
|
| @@ -728,6 +741,38 @@ void NetworkStateHandler::DefaultNetworkServiceChanged(
|
| //------------------------------------------------------------------------------
|
| // Private methods
|
|
|
| +void NetworkStateHandler::UpdateGuid(ManagedState* managed) {
|
| + if (managed->managed_type() == ManagedState::MANAGED_TYPE_FAVORITE) {
|
| + // Ensure that a FavoriteState has a valid GUID.
|
| + FavoriteState* favorite = managed->AsFavoriteState();
|
| + if (!favorite->guid().empty())
|
| + return;
|
| + std::string specifier = favorite->GetSpecifier();
|
| + std::string guid;
|
| + SpecifierGuidMap::iterator iter = specifier_guid_map_.find(specifier);
|
| + if (iter != specifier_guid_map_.end()) {
|
| + guid = iter->second;
|
| + } else {
|
| + guid = base::GenerateGUID();
|
| + specifier_guid_map_[specifier] = guid;
|
| + }
|
| + favorite->SetGuid(guid);
|
| + NetworkState* network = GetModifiableNetworkState(favorite->path());
|
| + if (network)
|
| + network->SetGuid(guid);
|
| + } else if (managed->managed_type() == ManagedState::MANAGED_TYPE_NETWORK) {
|
| + // If the GUID is not set and a corresponding FavoriteState exists, get the
|
| + // GUID from the FavoriteState. Otherwise it will get set when the Favorite
|
| + // is created.
|
| + NetworkState* network = managed->AsNetworkState();
|
| + if (!network->guid().empty())
|
| + return;
|
| + FavoriteState* favorite = GetModifiableFavoriteState(network->path());
|
| + if (favorite && !favorite->guid().empty())
|
| + network->SetGuid(favorite->guid());
|
| + }
|
| +}
|
| +
|
| void NetworkStateHandler::NotifyDeviceListChanged() {
|
| NET_LOG_DEBUG("NotifyDeviceListChanged",
|
| base::StringPrintf("Size:%" PRIuS, device_list_.size()));
|
| @@ -752,6 +797,15 @@ NetworkState* NetworkStateHandler::GetModifiableNetworkState(
|
| return managed->AsNetworkState();
|
| }
|
|
|
| +FavoriteState* NetworkStateHandler::GetModifiableFavoriteState(
|
| + const std::string& service_path) const {
|
| + ManagedState* managed =
|
| + GetModifiableManagedState(&favorite_list_, service_path);
|
| + if (!managed)
|
| + return NULL;
|
| + return managed->AsFavoriteState();
|
| +}
|
| +
|
| ManagedState* NetworkStateHandler::GetModifiableManagedState(
|
| const ManagedStateList* managed_list,
|
| const std::string& path) const {
|
|
|