summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-12 22:08:38 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-12 22:08:38 +0000
commitfa0336fa8a8909d614c9e500d76a0ebaa4844614 (patch)
treed9d549ac71541a75740a9c4319758d723477baeb
parent1208940857f29eff012e834c971adcf0471ca9c1 (diff)
downloadchromium_src-fa0336fa8a8909d614c9e500d76a0ebaa4844614.zip
chromium_src-fa0336fa8a8909d614c9e500d76a0ebaa4844614.tar.gz
chromium_src-fa0336fa8a8909d614c9e500d76a0ebaa4844614.tar.bz2
Merge FavoriteState into NetworkState
BUG=375955 For trivial renaming: R=armansito@chromium.org, pneubeck@chromium.org TBR=derat@chromium.org, xiyuan@chromium.org Review URL: https://codereview.chromium.org/289383004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276822 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--apps/shell/browser/shell_network_controller_chromeos.cc2
-rw-r--r--ash/system/chromeos/network/network_icon.cc33
-rw-r--r--ash/system/chromeos/network/network_icon.h6
-rw-r--r--ash/system/chromeos/network/network_state_list_detailed_view.cc2
-rw-r--r--chrome/browser/chromeos/mobile/mobile_activator_unittest.cc1
-rw-r--r--chrome/browser/chromeos/net/onc_utils.cc39
-rw-r--r--chrome/browser/chromeos/net/onc_utils.h13
-rw-r--r--chrome/browser/chromeos/net/proxy_config_handler.cc12
-rw-r--r--chrome/browser/chromeos/net/proxy_config_handler.h10
-rw-r--r--chrome/browser/chromeos/options/wifi_config_view.cc1
-rw-r--r--chrome/browser/chromeos/proxy_config_service_impl.cc7
-rw-r--r--chrome/browser/chromeos/status/network_menu.cc2
-rw-r--r--chrome/browser/chromeos/ui_proxy_config_service.cc26
-rw-r--r--chrome/browser/chromeos/ui_proxy_config_service.h4
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc16
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_apitest.cc12
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc3
-rw-r--r--chrome/browser/resources/chromeos/network_ui/network_ui.html3
-rw-r--r--chrome/browser/resources/chromeos/network_ui/network_ui.js3
-rw-r--r--chrome/browser/ui/webui/chromeos/login/network_state_informer.cc10
-rw-r--r--chrome/browser/ui/webui/chromeos/network_config_message_handler.cc5
-rw-r--r--chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc89
-rw-r--r--chrome/browser/ui/webui/options/preferences_browsertest.cc14
-rw-r--r--chromeos/chromeos.gyp2
-rw-r--r--chromeos/dbus/fake_shill_manager_client.cc176
-rw-r--r--chromeos/dbus/fake_shill_manager_client.h9
-rw-r--r--chromeos/dbus/fake_shill_profile_client.cc13
-rw-r--r--chromeos/dbus/fake_shill_service_client.cc24
-rw-r--r--chromeos/dbus/shill_manager_client.h15
-rw-r--r--chromeos/network/client_cert_resolver.cc44
-rw-r--r--chromeos/network/client_cert_resolver.h8
-rw-r--r--chromeos/network/client_cert_resolver_unittest.cc2
-rw-r--r--chromeos/network/favorite_state.cc116
-rw-r--r--chromeos/network/favorite_state.h74
-rw-r--r--chromeos/network/managed_network_configuration_handler_impl.cc8
-rw-r--r--chromeos/network/managed_network_configuration_handler_unittest.cc2
-rw-r--r--chromeos/network/managed_state.cc11
-rw-r--r--chromeos/network/managed_state.h3
-rw-r--r--chromeos/network/network_cert_migrator.cc2
-rw-r--r--chromeos/network/network_change_notifier_chromeos_unittest.cc1
-rw-r--r--chromeos/network/network_configuration_handler.cc2
-rw-r--r--chromeos/network/network_connection_handler.cc4
-rw-r--r--chromeos/network/network_connection_handler_unittest.cc2
-rw-r--r--chromeos/network/network_handler.cc2
-rw-r--r--chromeos/network/network_profile_handler.cc13
-rw-r--r--chromeos/network/network_profile_handler.h4
-rw-r--r--chromeos/network/network_sms_handler_unittest.cc10
-rw-r--r--chromeos/network/network_state.cc80
-rw-r--r--chromeos/network/network_state.h29
-rw-r--r--chromeos/network/network_state_handler.cc373
-rw-r--r--chromeos/network/network_state_handler.h115
-rw-r--r--chromeos/network/network_state_handler_unittest.cc174
-rw-r--r--chromeos/network/network_util.cc34
-rw-r--r--chromeos/network/network_util.h8
-rw-r--r--chromeos/network/shill_property_handler.cc74
-rw-r--r--chromeos/network/shill_property_handler.h11
-rw-r--r--chromeos/network/shill_property_handler_unittest.cc106
57 files changed, 782 insertions, 1082 deletions
diff --git a/apps/shell/browser/shell_network_controller_chromeos.cc b/apps/shell/browser/shell_network_controller_chromeos.cc
index 4280765..e1bf209 100644
--- a/apps/shell/browser/shell_network_controller_chromeos.cc
+++ b/apps/shell/browser/shell_network_controller_chromeos.cc
@@ -125,7 +125,7 @@ void ShellNetworkController::ConnectIfUnconnected() {
return;
chromeos::NetworkStateHandler::NetworkStateList state_list;
- handler->network_state_handler()->GetNetworkListByType(
+ handler->network_state_handler()->GetVisibleNetworkListByType(
chromeos::NetworkTypePattern::WiFi(), &state_list);
for (chromeos::NetworkStateHandler::NetworkStateList::const_iterator it =
state_list.begin(); it != state_list.end(); ++it) {
diff --git a/ash/system/chromeos/network/network_icon.cc b/ash/system/chromeos/network/network_icon.cc
index a732385..e14f15d 100644
--- a/ash/system/chromeos/network/network_icon.cc
+++ b/ash/system/chromeos/network/network_icon.cc
@@ -364,26 +364,6 @@ const gfx::ImageSkia GetDisconnectedImage(IconType icon_type,
return GetImageForIndex(image_type, icon_type, disconnected_index);
}
-const std::string& GetDisconnectedImageUrl(IconType icon_type,
- const std::string& network_type,
- float scale_factor) {
- static ImageIdUrlMap* s_image_url_map = NULL;
- if (s_image_url_map == NULL)
- s_image_url_map = new ImageIdUrlMap;
-
- ImageIdForNetworkType key(icon_type, network_type, scale_factor);
- ImageIdUrlMap::iterator iter = s_image_url_map->find(key);
- if (iter != s_image_url_map->end())
- return iter->second;
-
- VLOG(2) << "Generating disconnected bitmap URL for: " << network_type;
- gfx::ImageSkia image = GetDisconnectedImage(icon_type, network_type);
- gfx::ImageSkiaRep image_rep = image.GetRepresentation(scale_factor);
- iter = s_image_url_map->insert(std::make_pair(
- key, webui::GetBitmapDataUrl(image_rep.sk_bitmap()))).first;
- return iter->second;
-}
-
gfx::ImageSkia* ConnectingWirelessImage(ImageType image_type,
IconType icon_type,
double animation) {
@@ -783,7 +763,9 @@ NetworkIconImpl* FindAndUpdateImageImpl(const NetworkState* network,
gfx::ImageSkia GetImageForNetwork(const NetworkState* network,
IconType icon_type) {
DCHECK(network);
- // Handle connecting icons.
+ if (!network->visible())
+ return GetDisconnectedImage(icon_type, network->type());
+
if (network->IsConnectingState())
return GetConnectingImage(icon_type, network->type());
@@ -818,12 +800,6 @@ gfx::ImageSkia GetImageForDisconnectedNetwork(IconType icon_type,
return GetDisconnectedImage(icon_type, network_type);
}
-std::string GetImageUrlForDisconnectedNetwork(IconType icon_type,
- const std::string& network_type,
- float scale_factor) {
- return GetDisconnectedImageUrl(icon_type, network_type, scale_factor);
-}
-
base::string16 GetLabelForNetwork(const chromeos::NetworkState* network,
IconType icon_type) {
DCHECK(network);
@@ -970,7 +946,8 @@ void GetDefaultNetworkImageAndLabel(IconType icon_type,
void PurgeNetworkIconCache() {
NetworkStateHandler::NetworkStateList networks;
- NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks);
+ NetworkHandler::Get()->network_state_handler()->GetVisibleNetworkList(
+ &networks);
std::set<std::string> network_paths;
for (NetworkStateHandler::NetworkStateList::iterator iter = networks.begin();
iter != networks.end(); ++iter) {
diff --git a/ash/system/chromeos/network/network_icon.h b/ash/system/chromeos/network/network_icon.h
index 4974de7..7497930 100644
--- a/ash/system/chromeos/network/network_icon.h
+++ b/ash/system/chromeos/network/network_icon.h
@@ -56,12 +56,6 @@ ASH_EXPORT gfx::ImageSkia GetImageForDisconnectedNetwork(
IconType icon_type,
const std::string& network_type);
-// Gets a url representing the image for a disconnected network type.
-ASH_EXPORT std::string GetImageUrlForDisconnectedNetwork(
- IconType icon_type,
- const std::string& network_type,
- float scale_factor);
-
// Returns the label for |network| based on |icon_type|. |network| can be NULL.
ASH_EXPORT base::string16 GetLabelForNetwork(
const chromeos::NetworkState* network,
diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc
index de571bd..616dc27 100644
--- a/ash/system/chromeos/network/network_state_list_detailed_view.cc
+++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc
@@ -182,7 +182,7 @@ void NetworkStateListDetailedView::ManagerChanged() {
void NetworkStateListDetailedView::NetworkListChanged() {
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
NetworkStateHandler::NetworkStateList network_list;
- handler->GetNetworkList(&network_list);
+ handler->GetVisibleNetworkList(&network_list);
UpdateNetworks(network_list);
UpdateNetworkList();
UpdateHeaderButtons();
diff --git a/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc b/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc
index 13ec029..8f634d9 100644
--- a/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc
+++ b/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc
@@ -101,6 +101,7 @@ class MobileActivatorTest : public testing::Test {
cellular_network_.activation_state_ = activation_state;
}
void set_connection_state(const std::string& state) {
+ cellular_network_.visible_ = true;
cellular_network_.connection_state_ = state;
}
diff --git a/chrome/browser/chromeos/net/onc_utils.cc b/chrome/browser/chromeos/net/onc_utils.cc
index f7f27ca..e8e8cb0 100644
--- a/chrome/browser/chromeos/net/onc_utils.cc
+++ b/chrome/browser/chromeos/net/onc_utils.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/chromeos/ui_proxy_config.h"
#include "chrome/browser/prefs/proxy_config_dictionary.h"
#include "chrome/common/pref_names.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_handler.h"
@@ -348,10 +347,10 @@ const base::DictionaryValue* GetNetworkConfigForEthernetWithoutEAP(
const base::DictionaryValue* GetNetworkConfigForNetworkFromOnc(
const base::ListValue& network_configs,
- const FavoriteState& favorite) {
+ const NetworkState& network) {
// In all cases except Ethernet, we use the GUID of |network|.
- if (!favorite.Matches(NetworkTypePattern::Ethernet()))
- return GetNetworkConfigByGUID(network_configs, favorite.guid());
+ if (!network.Matches(NetworkTypePattern::Ethernet()))
+ return GetNetworkConfigByGUID(network_configs, network.guid());
// Ethernet is always shared and thus cannot store a GUID per user. Thus we
// search for any Ethernet policy intead of a matching GUID.
@@ -359,11 +358,11 @@ const base::DictionaryValue* GetNetworkConfigForNetworkFromOnc(
// the respective ONC policy. The EthernetEAP service itself is however never
// in state "connected". An EthernetEAP policy must be applied, if an Ethernet
// service is connected using the EAP parameters.
- const FavoriteState* ethernet_eap = NULL;
+ const NetworkState* ethernet_eap = NULL;
if (NetworkHandler::IsInitialized()) {
ethernet_eap =
NetworkHandler::Get()->network_state_handler()->GetEAPForEthernet(
- favorite.path());
+ network.path());
}
// The GUID associated with the EthernetEAP service refers to the ONC policy
@@ -379,7 +378,7 @@ const base::DictionaryValue* GetNetworkConfigForNetworkFromOnc(
const base::DictionaryValue* GetPolicyForNetworkFromPref(
const PrefService* pref_service,
const char* pref_name,
- const FavoriteState& favorite) {
+ const NetworkState& network) {
if (!pref_service) {
VLOG(2) << "No pref service";
return NULL;
@@ -413,42 +412,42 @@ const base::DictionaryValue* GetPolicyForNetworkFromPref(
onc_policy_value->GetAsList(&onc_policy);
DCHECK(onc_policy);
- return GetNetworkConfigForNetworkFromOnc(*onc_policy, favorite);
+ return GetNetworkConfigForNetworkFromOnc(*onc_policy, network);
}
} // namespace
-const base::DictionaryValue* GetPolicyForFavoriteNetwork(
+const base::DictionaryValue* GetPolicyForNetwork(
const PrefService* profile_prefs,
const PrefService* local_state_prefs,
- const FavoriteState& favorite,
+ const NetworkState& network,
::onc::ONCSource* onc_source) {
- VLOG(2) << "GetPolicyForFavoriteNetwork: " << favorite.path();
+ VLOG(2) << "GetPolicyForNetwork: " << network.path();
*onc_source = ::onc::ONC_SOURCE_NONE;
const base::DictionaryValue* network_policy = GetPolicyForNetworkFromPref(
- profile_prefs, prefs::kOpenNetworkConfiguration, favorite);
+ profile_prefs, prefs::kOpenNetworkConfiguration, network);
if (network_policy) {
- VLOG(1) << "Network " << favorite.path() << " is managed by user policy.";
+ VLOG(1) << "Network " << network.path() << " is managed by user policy.";
*onc_source = ::onc::ONC_SOURCE_USER_POLICY;
return network_policy;
}
network_policy = GetPolicyForNetworkFromPref(
- local_state_prefs, prefs::kDeviceOpenNetworkConfiguration, favorite);
+ local_state_prefs, prefs::kDeviceOpenNetworkConfiguration, network);
if (network_policy) {
- VLOG(1) << "Network " << favorite.path() << " is managed by device policy.";
+ VLOG(1) << "Network " << network.path() << " is managed by device policy.";
*onc_source = ::onc::ONC_SOURCE_DEVICE_POLICY;
return network_policy;
}
- VLOG(2) << "Network " << favorite.path() << " is unmanaged.";
+ VLOG(2) << "Network " << network.path() << " is unmanaged.";
return NULL;
}
-bool HasPolicyForFavoriteNetwork(const PrefService* profile_prefs,
- const PrefService* local_state_prefs,
- const FavoriteState& network) {
+bool HasPolicyForNetwork(const PrefService* profile_prefs,
+ const PrefService* local_state_prefs,
+ const NetworkState& network) {
::onc::ONCSource ignored_onc_source;
- const base::DictionaryValue* policy = onc::GetPolicyForFavoriteNetwork(
+ const base::DictionaryValue* policy = onc::GetPolicyForNetwork(
profile_prefs, local_state_prefs, network, &ignored_onc_source);
return policy != NULL;
}
diff --git a/chrome/browser/chromeos/net/onc_utils.h b/chrome/browser/chromeos/net/onc_utils.h
index 4fa8784..e6a30f3 100644
--- a/chrome/browser/chromeos/net/onc_utils.h
+++ b/chrome/browser/chromeos/net/onc_utils.h
@@ -19,7 +19,6 @@ class ListValue;
namespace chromeos {
-class FavoriteState;
class NetworkState;
class User;
@@ -63,19 +62,19 @@ const base::DictionaryValue* GetGlobalConfigFromPolicy(bool for_active_user);
// GetGlobalConfigFromPolicy).
bool PolicyAllowsOnlyPolicyNetworksToAutoconnect(bool for_active_user);
-// Returns the effective (user or device) policy for network |favorite|. Both
+// Returns the effective (user or device) policy for network |network|. Both
// |profile_prefs| and |local_state_prefs| might be NULL. Returns NULL if no
// applicable policy is found. Sets |onc_source| accordingly.
-const base::DictionaryValue* GetPolicyForFavoriteNetwork(
+const base::DictionaryValue* GetPolicyForNetwork(
const PrefService* profile_prefs,
const PrefService* local_state_prefs,
- const FavoriteState& favorite,
+ const NetworkState& network,
::onc::ONCSource* onc_source);
// Convenience function to check only whether a policy for a network exists.
-bool HasPolicyForFavoriteNetwork(const PrefService* profile_prefs,
- const PrefService* local_state_prefs,
- const FavoriteState& network);
+bool HasPolicyForNetwork(const PrefService* profile_prefs,
+ const PrefService* local_state_prefs,
+ const NetworkState& network);
} // namespace onc
} // namespace chromeos
diff --git a/chrome/browser/chromeos/net/proxy_config_handler.cc b/chrome/browser/chromeos/net/proxy_config_handler.cc
index 66b6d58..782b035 100644
--- a/chrome/browser/chromeos/net/proxy_config_handler.cc
+++ b/chrome/browser/chromeos/net/proxy_config_handler.cc
@@ -14,10 +14,10 @@
#include "chrome/common/pref_names.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_service_client.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_handler_callbacks.h"
#include "chromeos/network/network_profile.h"
#include "chromeos/network/network_profile_handler.h"
+#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "dbus/object_path.h"
@@ -38,13 +38,13 @@ void NotifyNetworkStateHandler(const std::string& service_path) {
namespace proxy_config {
-scoped_ptr<ProxyConfigDictionary> GetProxyConfigForFavoriteNetwork(
+scoped_ptr<ProxyConfigDictionary> GetProxyConfigForNetwork(
const PrefService* profile_prefs,
const PrefService* local_state_prefs,
- const FavoriteState& network,
+ const NetworkState& network,
::onc::ONCSource* onc_source) {
const base::DictionaryValue* network_policy =
- onc::GetPolicyForFavoriteNetwork(
+ onc::GetPolicyForNetwork(
profile_prefs, local_state_prefs, network, onc_source);
if (network_policy) {
@@ -91,8 +91,8 @@ scoped_ptr<ProxyConfigDictionary> GetProxyConfigForFavoriteNetwork(
return make_scoped_ptr(new ProxyConfigDictionary(&value));
}
-void SetProxyConfigForFavoriteNetwork(const ProxyConfigDictionary& proxy_config,
- const FavoriteState& network) {
+void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config,
+ const NetworkState& network) {
chromeos::ShillServiceClient* shill_service_client =
DBusThreadManager::Get()->GetShillServiceClient();
diff --git a/chrome/browser/chromeos/net/proxy_config_handler.h b/chrome/browser/chromeos/net/proxy_config_handler.h
index 5aae4d6..e44dfbd 100644
--- a/chrome/browser/chromeos/net/proxy_config_handler.h
+++ b/chrome/browser/chromeos/net/proxy_config_handler.h
@@ -18,7 +18,7 @@ class PrefRegistrySyncable;
namespace chromeos {
-class FavoriteState;
+class NetworkState;
namespace proxy_config {
@@ -26,14 +26,14 @@ namespace proxy_config {
// |network|. If |profile_prefs| is NULL, then only shared settings (and device
// policy) are respected. This is e.g. the case for the signin screen and the
// system request context.
-scoped_ptr<ProxyConfigDictionary> GetProxyConfigForFavoriteNetwork(
+scoped_ptr<ProxyConfigDictionary> GetProxyConfigForNetwork(
const PrefService* profile_prefs,
const PrefService* local_state_prefs,
- const FavoriteState& network,
+ const NetworkState& network,
onc::ONCSource* onc_source);
-void SetProxyConfigForFavoriteNetwork(const ProxyConfigDictionary& proxy_config,
- const FavoriteState& network);
+void SetProxyConfigForNetwork(const ProxyConfigDictionary& proxy_config,
+ const NetworkState& network);
void RegisterPrefs(PrefRegistrySimple* registry);
diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc
index c0a59b4..096ec02 100644
--- a/chrome/browser/chromeos/options/wifi_config_view.cc
+++ b/chrome/browser/chromeos/options/wifi_config_view.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/chromeos/options/passphrase_textfield.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/login/login_state.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_handler.h"
diff --git a/chrome/browser/chromeos/proxy_config_service_impl.cc b/chrome/browser/chromeos/proxy_config_service_impl.cc
index 2773a54..d66ccc2 100644
--- a/chrome/browser/chromeos/proxy_config_service_impl.cc
+++ b/chrome/browser/chromeos/proxy_config_service_impl.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/prefs/proxy_config_dictionary.h"
#include "chrome/browser/prefs/proxy_prefs.h"
#include "chrome/common/pref_names.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_profile.h"
#include "chromeos/network/network_profile_handler.h"
#include "chromeos/network/network_state.h"
@@ -35,11 +34,11 @@ namespace {
// proxy was configured for this network.
bool GetProxyConfig(const PrefService* profile_prefs,
const PrefService* local_state_prefs,
- const FavoriteState& network,
+ const NetworkState& network,
net::ProxyConfig* proxy_config,
::onc::ONCSource* onc_source) {
scoped_ptr<ProxyConfigDictionary> proxy_dict =
- proxy_config::GetProxyConfigForFavoriteNetwork(
+ proxy_config::GetProxyConfigForNetwork(
profile_prefs, local_state_prefs, network, onc_source);
if (!proxy_dict)
return false;
@@ -161,7 +160,7 @@ bool ProxyConfigServiceImpl::IgnoreProxy(const PrefService* profile_prefs,
void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() {
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
- const FavoriteState* network = handler->DefaultFavoriteNetwork();
+ const NetworkState* network = handler->DefaultNetwork();
// Get prefs proxy config if available.
net::ProxyConfig pref_config;
diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc
index cdaea87..63b48d7 100644
--- a/chrome/browser/chromeos/status/network_menu.cc
+++ b/chrome/browser/chromeos/status/network_menu.cc
@@ -411,7 +411,7 @@ void MainMenuModel::InitMenuItems(bool should_open_button_options) {
// Get the list of all networks.
NetworkStateHandler::NetworkStateList network_list;
- handler->GetNetworkList(&network_list);
+ handler->GetVisibleNetworkList(&network_list);
// Cellular Networks
if (handler->IsTechnologyEnabled(NetworkTypePattern::Cellular())) {
diff --git a/chrome/browser/chromeos/ui_proxy_config_service.cc b/chrome/browser/chromeos/ui_proxy_config_service.cc
index 945f4e4..8f694dd 100644
--- a/chrome/browser/chromeos/ui_proxy_config_service.cc
+++ b/chrome/browser/chromeos/ui_proxy_config_service.cc
@@ -9,7 +9,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/net/proxy_config_handler.h"
#include "chrome/browser/chromeos/proxy_config_service_impl.h"
-#include "chromeos/network/favorite_state.h"
+#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "grit/generated_resources.h"
#include "net/proxy/proxy_config.h"
@@ -40,11 +40,11 @@ const char* ModeToString(UIProxyConfig::Mode mode) {
// for this network.
bool GetProxyConfig(const PrefService* profile_prefs,
const PrefService* local_state_prefs,
- const FavoriteState& network,
+ const NetworkState& network,
net::ProxyConfig* proxy_config,
onc::ONCSource* onc_source) {
scoped_ptr<ProxyConfigDictionary> proxy_dict =
- proxy_config::GetProxyConfigForFavoriteNetwork(
+ proxy_config::GetProxyConfigForNetwork(
profile_prefs, local_state_prefs, network, onc_source);
if (!proxy_dict)
return false;
@@ -79,13 +79,13 @@ void UIProxyConfigService::SetCurrentNetwork(
}
void UIProxyConfigService::UpdateFromPrefs() {
- const FavoriteState* network = NULL;
+ const NetworkState* network = NULL;
if (!current_ui_network_.empty()) {
network = NetworkHandler::Get()
->network_state_handler()
- ->GetFavoriteStateFromServicePath(current_ui_network_,
- true /* configured_only */);
- LOG_IF(ERROR, !network) << "Couldn't find FavoriteState for network "
+ ->GetNetworkStateFromServicePath(current_ui_network_,
+ true /* configured_only */);
+ LOG_IF(ERROR, !network) << "Couldn't find NetworkState for network "
<< current_ui_network_;
}
if (!network) {
@@ -110,13 +110,13 @@ void UIProxyConfigService::SetProxyConfig(const UIProxyConfig& config) {
if (current_ui_network_.empty())
return;
- const FavoriteState* network =
+ const NetworkState* network =
NetworkHandler::Get()
->network_state_handler()
- ->GetFavoriteStateFromServicePath(current_ui_network_,
- true /* configured_only */);
+ ->GetNetworkStateFromServicePath(current_ui_network_,
+ true /* configured_only */);
if (!network) {
- LOG(ERROR) << "Couldn't find FavoriteState for network "
+ LOG(ERROR) << "Couldn't find NetworkState for network "
<< current_ui_network_;
return;
}
@@ -129,12 +129,12 @@ void UIProxyConfigService::SetProxyConfig(const UIProxyConfig& config) {
VLOG(1) << "Set proxy for " << current_ui_network_
<< " to " << *proxy_config_value;
- proxy_config::SetProxyConfigForFavoriteNetwork(proxy_config_dict, *network);
+ proxy_config::SetProxyConfigForNetwork(proxy_config_dict, *network);
current_ui_config_.state = ProxyPrefs::CONFIG_SYSTEM;
}
void UIProxyConfigService::DetermineEffectiveConfig(
- const FavoriteState& network) {
+ const NetworkState& network) {
DCHECK(local_state_prefs_);
// The pref service to read proxy settings that apply to all networks.
diff --git a/chrome/browser/chromeos/ui_proxy_config_service.h b/chrome/browser/chromeos/ui_proxy_config_service.h
index 44c1da8..c6e28bb 100644
--- a/chrome/browser/chromeos/ui_proxy_config_service.h
+++ b/chrome/browser/chromeos/ui_proxy_config_service.h
@@ -14,7 +14,7 @@ class PrefService;
namespace chromeos {
-class FavoriteState;
+class NetworkState;
// This class is only accessed from the UI via Profile::GetProxyConfigTracker to
// allow the user to read and modify the proxy configuration via
@@ -55,7 +55,7 @@ class UIProxyConfigService {
// |network| and if user is using shared proxies. The effective config is
// stored in |current_ui_config_| but not activated on network stack, and
// hence, not picked up by observers.
- void DetermineEffectiveConfig(const FavoriteState& network);
+ void DetermineEffectiveConfig(const NetworkState& network);
// Service path of network whose proxy configuration is being displayed or
// edited via UI.
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc b/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc
index a77d194..81bda9e 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_api_chromeos.cc
@@ -15,7 +15,6 @@
#include "chrome/common/extensions/api/networking_private.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_manager_client.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_connection_handler.h"
#include "chromeos/network/network_device_handler.h"
@@ -31,7 +30,6 @@
namespace api = extensions::api::networking_private;
using chromeos::DBusThreadManager;
-using chromeos::FavoriteState;
using chromeos::ManagedNetworkConfigurationHandler;
using chromeos::NetworkHandler;
using chromeos::NetworkPortalDetector;
@@ -72,8 +70,8 @@ std::string GetUserIdHash(Profile* profile) {
bool GetServicePathFromGuid(const std::string& guid,
std::string* service_path,
std::string* error) {
- const FavoriteState* network =
- NetworkHandler::Get()->network_state_handler()->GetFavoriteStateFromGuid(
+ const NetworkState* network =
+ NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid(
guid);
if (!network) {
*error = "Error.InvalidNetworkGuid";
@@ -180,18 +178,18 @@ bool NetworkingPrivateGetStateFunction::RunAsync() {
if (!GetServicePathFromGuid(params->network_guid, &service_path, &error_))
return false;
- const FavoriteState* favorite_state =
+ const NetworkState* network_state =
NetworkHandler::Get()
->network_state_handler()
- ->GetFavoriteStateFromServicePath(service_path,
- false /* configured_only */);
- if (!favorite_state) {
+ ->GetNetworkStateFromServicePath(service_path,
+ false /* configured_only */);
+ if (!network_state) {
error_ = "Error.NetworkUnavailable";
return false;
}
scoped_ptr<base::DictionaryValue> network_properties =
- chromeos::network_util::TranslateFavoriteStateToONC(favorite_state);
+ chromeos::network_util::TranslateNetworkStateToONC(network_state);
SetResult(network_properties.release());
SendResponse(true);
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
index 2a0530f4..eda0f53 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
@@ -225,8 +225,6 @@ class ExtensionNetworkingPrivateApiTest
"stub_cellular1",
shill::kRoamingStateProperty,
base::StringValue(shill::kRoamingStateHome));
- DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- SortManagerServices();
content::RunAllPendingInMessageLoop();
}
@@ -263,7 +261,6 @@ class ExtensionNetworkingPrivateApiTest
device_test_->ClearDevices();
service_test_->ClearServices();
- profile_test->ClearProfiles();
// Sends a notification about the added profile.
profile_test->AddProfile(kUser1ProfilePath, userhash_);
@@ -354,8 +351,6 @@ class ExtensionNetworkingPrivateApiTest
AddService("stub_vpn1", "vpn1", shill::kTypeVPN, shill::kStateOnline);
- manager_test_->SortManagerServices();
-
content::RunAllPendingInMessageLoop();
}
#else // !defined(OS_CHROMEOS)
@@ -427,11 +422,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
#if defined(OS_CHROMEOS)
// TODO(stevenjb/mef): Fix these on non-Chrome OS, crbug.com/371442.
IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, GetNetworks) {
- // Remove "stub_wifi2" from the visible list.
- manager_test_->RemoveManagerService("stub_wifi2", false);
+ // Hide stub_wifi2.
+ service_test_->SetServiceProperty("stub_wifi2",
+ shill::kVisibleProperty,
+ base::FundamentalValue(false));
// Add a couple of additional networks that are not configured (saved).
AddService("stub_wifi3", "wifi3", shill::kTypeWifi, shill::kStateIdle);
AddService("stub_wifi4", "wifi4", shill::kTypeWifi, shill::kStateIdle);
+ content::RunAllPendingInMessageLoop();
EXPECT_TRUE(RunNetworkingSubtest("getNetworks")) << message_;
}
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc b/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc
index 786690a..bdd86d33 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_event_router_chromeos.cc
@@ -143,7 +143,8 @@ void NetworkingPrivateEventRouterImpl::StartOrStopListeningForNetworkChanges() {
void NetworkingPrivateEventRouterImpl::NetworkListChanged() {
EventRouter* event_router = EventRouter::Get(profile_);
NetworkStateHandler::NetworkStateList networks;
- NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks);
+ NetworkHandler::Get()->network_state_handler()->GetVisibleNetworkList(
+ &networks);
if (!event_router->HasEventListener(
api::networking_private::OnNetworkListChanged::kEventName)) {
// TODO(stevenjb): Remove logging once crbug.com/256881 is fixed
diff --git a/chrome/browser/resources/chromeos/network_ui/network_ui.html b/chrome/browser/resources/chromeos/network_ui/network_ui.html
index d18941b..ffb87e07 100644
--- a/chrome/browser/resources/chromeos/network_ui/network_ui.html
+++ b/chrome/browser/resources/chromeos/network_ui/network_ui.html
@@ -31,7 +31,7 @@
</div>
<div id="network-log-container">
</div>
- <h3>Networks: </h3>
+ <h3>Visible Networks: </h3>
<table id="network-state-table" class="state-table">
<tr class="state-table-header">
<td></td>
@@ -56,6 +56,7 @@
<td>Name</td>
<td>Type</td>
<td>Profile</td>
+ <td>Visible</td>
<td>ONC Source</td>
</tr>
</table>
diff --git a/chrome/browser/resources/chromeos/network_ui/network_ui.js b/chrome/browser/resources/chromeos/network_ui/network_ui.js
index 333687a..844d47a 100644
--- a/chrome/browser/resources/chromeos/network_ui/network_ui.js
+++ b/chrome/browser/resources/chromeos/network_ui/network_ui.js
@@ -27,7 +27,8 @@ var NetworkUI = (function() {
'GUID',
'Name',
'Type',
- 'Profile',
+ 'profile_path',
+ 'visible',
'onc_source'
];
diff --git a/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc b/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
index 1c20bd1..a1bc27e 100644
--- a/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
+++ b/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
@@ -28,14 +28,14 @@ const char kNetworkStateConnecting[] = "connecting";
const char kNetworkStateProxyAuthRequired[] = "proxy auth required";
bool HasDefaultNetworkProxyConfigured() {
- const FavoriteState* favorite =
- NetworkHandler::Get()->network_state_handler()->DefaultFavoriteNetwork();
- if (!favorite)
+ const NetworkState* network =
+ NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
+ if (!network)
return false;
onc::ONCSource onc_source = onc::ONC_SOURCE_NONE;
scoped_ptr<ProxyConfigDictionary> proxy_dict =
- proxy_config::GetProxyConfigForFavoriteNetwork(
- NULL, g_browser_process->local_state(), *favorite, &onc_source);
+ proxy_config::GetProxyConfigForNetwork(
+ NULL, g_browser_process->local_state(), *network, &onc_source);
ProxyPrefs::ProxyMode mode;
return (proxy_dict && proxy_dict->GetMode(&mode) &&
mode == ProxyPrefs::MODE_FIXED_SERVERS);
diff --git a/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc b/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc
index cbc8d8d..c70779ab 100644
--- a/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/network_config_message_handler.cc
@@ -10,7 +10,6 @@
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/values.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
@@ -28,8 +27,8 @@ namespace {
bool GetServicePathFromGuid(const std::string& guid,
std::string* service_path) {
- const FavoriteState* network =
- NetworkHandler::Get()->network_state_handler()->GetFavoriteStateFromGuid(
+ const NetworkState* network =
+ NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid(
guid);
if (!network)
return false;
diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
index 82ffaa5..fd8488e 100644
--- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
@@ -36,7 +36,6 @@
#include "chrome/browser/ui/webui/options/chromeos/internet_options_handler_strings.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/network/device_state.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_connection_handler.h"
@@ -293,25 +292,7 @@ std::string LoggedInUserTypeToJSString(LoginState::LoggedInUserType type) {
return std::string();
}
-bool HasPolicyForFavorite(const FavoriteState* favorite,
- const PrefService* profile_prefs) {
- return onc::HasPolicyForFavoriteNetwork(
- profile_prefs, g_browser_process->local_state(), *favorite);
-}
-
-bool HasPolicyForNetwork(const NetworkState* network,
- const PrefService* profile_prefs) {
- const FavoriteState* favorite =
- NetworkHandler::Get()
- ->network_state_handler()
- ->GetFavoriteStateFromServicePath(network->path(),
- true /* configured_only */);
- if (!favorite)
- return false;
- return HasPolicyForFavorite(favorite, profile_prefs);
-}
-
-void SetCommonNetworkInfo(const ManagedState* state,
+void SetCommonNetworkInfo(const NetworkState* state,
const std::string& icon_url,
base::DictionaryValue* network_info) {
network_info->SetString(kNetworkInfoKeyIconURL, icon_url);
@@ -334,13 +315,21 @@ base::DictionaryValue* BuildNetworkDictionary(
float icon_scale_factor,
const PrefService* profile_prefs) {
scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue());
- network_info->SetBoolean(kNetworkInfoKeyConnectable, network->connectable());
- network_info->SetBoolean(kNetworkInfoKeyConnected,
- network->IsConnectedState());
- network_info->SetBoolean(kNetworkInfoKeyConnecting,
- network->IsConnectingState());
- network_info->SetBoolean(kNetworkInfoKeyPolicyManaged,
- HasPolicyForNetwork(network, profile_prefs));
+ if (network->visible()) {
+ network_info->SetBoolean(kNetworkInfoKeyConnectable,
+ network->connectable());
+ network_info->SetBoolean(kNetworkInfoKeyConnected,
+ network->IsConnectedState());
+ network_info->SetBoolean(kNetworkInfoKeyConnecting,
+ network->IsConnectingState());
+ } else {
+ network_info->SetBoolean(kNetworkInfoKeyConnectable, false);
+ network_info->SetBoolean(kNetworkInfoKeyConnected, false);
+ network_info->SetBoolean(kNetworkInfoKeyConnecting, false);
+ }
+ bool has_policy = onc::HasPolicyForNetwork(
+ profile_prefs, g_browser_process->local_state(), *network);
+ network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy);
std::string icon_url = ash::network_icon::GetImageUrlForNetwork(
network, ash::network_icon::ICON_TYPE_LIST, icon_scale_factor);
@@ -348,23 +337,6 @@ base::DictionaryValue* BuildNetworkDictionary(
return network_info.release();
}
-base::DictionaryValue* BuildFavoriteDictionary(
- const FavoriteState* favorite,
- float icon_scale_factor,
- const PrefService* profile_prefs) {
- scoped_ptr<base::DictionaryValue> network_info(new base::DictionaryValue());
- network_info->SetBoolean(kNetworkInfoKeyConnectable, false);
- network_info->SetBoolean(kNetworkInfoKeyConnected, false);
- network_info->SetBoolean(kNetworkInfoKeyConnecting, false);
- network_info->SetBoolean(kNetworkInfoKeyPolicyManaged,
- HasPolicyForFavorite(favorite, profile_prefs));
-
- std::string icon_url = ash::network_icon::GetImageUrlForDisconnectedNetwork(
- ash::network_icon::ICON_TYPE_LIST, favorite->type(), icon_scale_factor);
- SetCommonNetworkInfo(favorite, icon_url, network_info.get());
- return network_info.release();
-}
-
// Pulls IP information out of a shill service properties dictionary. If
// |static_ip| is true, then it fetches "StaticIP.*" properties. If not, then it
// fetches "SavedIP.*" properties. Caller must take ownership of returned
@@ -1738,7 +1710,7 @@ base::ListValue* InternetOptionsHandler::GetWirelessList() {
base::ListValue* list = new base::ListValue();
NetworkStateHandler::NetworkStateList networks;
- NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
+ NetworkHandler::Get()->network_state_handler()->GetVisibleNetworkListByType(
NetworkTypePattern::Wireless(), &networks);
for (NetworkStateHandler::NetworkStateList::const_iterator iter =
networks.begin(); iter != networks.end(); ++iter) {
@@ -1755,7 +1727,7 @@ base::ListValue* InternetOptionsHandler::GetVPNList() {
base::ListValue* list = new base::ListValue();
NetworkStateHandler::NetworkStateList networks;
- NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
+ NetworkHandler::Get()->network_state_handler()->GetVisibleNetworkListByType(
NetworkTypePattern::VPN(), &networks);
for (NetworkStateHandler::NetworkStateList::const_iterator iter =
networks.begin(); iter != networks.end(); ++iter) {
@@ -1771,18 +1743,23 @@ base::ListValue* InternetOptionsHandler::GetVPNList() {
base::ListValue* InternetOptionsHandler::GetRememberedList() {
base::ListValue* list = new base::ListValue();
- NetworkStateHandler::FavoriteStateList favorites;
- NetworkHandler::Get()->network_state_handler()->GetFavoriteList(&favorites);
- for (NetworkStateHandler::FavoriteStateList::const_iterator iter =
- favorites.begin(); iter != favorites.end(); ++iter) {
- const FavoriteState* favorite = *iter;
- if (favorite->type() != shill::kTypeWifi &&
- favorite->type() != shill::kTypeVPN)
+ NetworkStateHandler::NetworkStateList networks;
+ NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
+ NetworkTypePattern::Default(),
+ true /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &networks);
+ for (NetworkStateHandler::NetworkStateList::const_iterator iter =
+ networks.begin(); iter != networks.end(); ++iter) {
+ const NetworkState* network = *iter;
+ if (network->type() != shill::kTypeWifi &&
+ network->type() != shill::kTypeVPN)
continue;
list->Append(
- BuildFavoriteDictionary(favorite,
- web_ui()->GetDeviceScaleFactor(),
- Profile::FromWebUI(web_ui())->GetPrefs()));
+ BuildNetworkDictionary(network,
+ web_ui()->GetDeviceScaleFactor(),
+ Profile::FromWebUI(web_ui())->GetPrefs()));
}
return list;
diff --git a/chrome/browser/ui/webui/options/preferences_browsertest.cc b/chrome/browser/ui/webui/options/preferences_browsertest.cc
index c531de7..77a35fe 100644
--- a/chrome/browser/ui/webui/options/preferences_browsertest.cc
+++ b/chrome/browser/ui/webui/options/preferences_browsertest.cc
@@ -45,7 +45,6 @@
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_profile_client.h"
#include "chromeos/dbus/shill_service_client.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/settings/cros_settings_names.h"
@@ -824,10 +823,9 @@ class ProxyPreferencesBrowserTest : public PreferencesBrowserTest {
ProxyConfigDictionary proxy_config(proxy_config_dict.get());
- const chromeos::FavoriteState* network = GetDefaultFavoriteNetwork();
+ const chromeos::NetworkState* network = GetDefaultNetwork();
ASSERT_TRUE(network);
- chromeos::proxy_config::SetProxyConfigForFavoriteNetwork(proxy_config,
- *network);
+ chromeos::proxy_config::SetProxyConfigForNetwork(proxy_config, *network);
std::string url = base::StringPrintf("%s?network=%s",
chrome::kChromeUIProxySettingsURL,
@@ -890,10 +888,10 @@ class ProxyPreferencesBrowserTest : public PreferencesBrowserTest {
content::RunAllPendingInMessageLoop();
}
- const chromeos::FavoriteState* GetDefaultFavoriteNetwork() {
+ const chromeos::NetworkState* GetDefaultNetwork() {
chromeos::NetworkStateHandler* handler =
chromeos::NetworkHandler::Get()->network_state_handler();
- return handler->DefaultFavoriteNetwork();
+ return handler->DefaultNetwork();
}
void SetProxyPref(const std::string& name, const base::Value& value) {
@@ -918,11 +916,11 @@ class ProxyPreferencesBrowserTest : public PreferencesBrowserTest {
void VerifyCurrentProxyServer(const std::string& expected_server,
onc::ONCSource expected_source) {
- const chromeos::FavoriteState* network = GetDefaultFavoriteNetwork();
+ const chromeos::NetworkState* network = GetDefaultNetwork();
ASSERT_TRUE(network);
onc::ONCSource actual_source;
scoped_ptr<ProxyConfigDictionary> proxy_dict =
- chromeos::proxy_config::GetProxyConfigForFavoriteNetwork(
+ chromeos::proxy_config::GetProxyConfigForNetwork(
pref_service_,
g_browser_process->local_state(),
*network,
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
index d97e43d..686b7ae 100644
--- a/chromeos/chromeos.gyp
+++ b/chromeos/chromeos.gyp
@@ -274,8 +274,6 @@
'network/client_cert_util.h',
'network/device_state.cc',
'network/device_state.h',
- 'network/favorite_state.cc',
- 'network/favorite_state.h',
'network/geolocation_handler.cc',
'network/geolocation_handler.h',
'network/managed_network_configuration_handler.cc',
diff --git a/chromeos/dbus/fake_shill_manager_client.cc b/chromeos/dbus/fake_shill_manager_client.cc
index 69f6c28..3b9a02d 100644
--- a/chromeos/dbus/fake_shill_manager_client.cc
+++ b/chromeos/dbus/fake_shill_manager_client.cc
@@ -39,13 +39,14 @@ struct ValueEquals {
};
// Appends string entries from |service_list_in| whose entries in ServiceClient
-// have Type |match_type| to either an active list or an inactive list
-// based on the entry's State.
+// have Type |match_type| to one of the output lists based on the entry's State.
void AppendServicesForType(
const base::ListValue* service_list_in,
const char* match_type,
+ bool technology_enabled,
std::vector<std::string>* active_service_list_out,
- std::vector<std::string>* inactive_service_list_out) {
+ std::vector<std::string>* inactive_service_list_out,
+ std::vector<std::string>* disabled_service_list_out) {
ShillServiceClient::TestInterface* service_client =
DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
for (base::ListValue::const_iterator iter = service_list_in->begin();
@@ -63,6 +64,19 @@ void AppendServicesForType(
properties->GetString(shill::kTypeProperty, &type);
if (type != match_type)
continue;
+ if (!technology_enabled) {
+ std::string profile;
+ properties->GetString(shill::kProfileProperty, &profile);
+ if (profile.empty())
+ continue;
+ }
+ bool visible = false;
+ if (technology_enabled)
+ properties->GetBoolean(shill::kVisibleProperty, &visible);
+ if (!visible) {
+ disabled_service_list_out->push_back(service_path);
+ continue;
+ }
std::string state;
properties->GetString(shill::kStateProperty, &state);
if (state == shill::kStateOnline ||
@@ -127,6 +141,7 @@ void FakeShillManagerClient::RemovePropertyChangedObserver(
void FakeShillManagerClient::GetProperties(
const DictionaryValueCallback& callback) {
+ DVLOG(1) << "Manager.GetProperties";
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(
&FakeShillManagerClient::PassStubProperties,
@@ -446,32 +461,28 @@ void FakeShillManagerClient::SetManagerProperty(const std::string& key,
base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback));
}
-void FakeShillManagerClient::AddManagerService(const std::string& service_path,
- bool add_to_visible_list) {
- DVLOG(2) << "AddManagerService: " << service_path
- << " Visible: " << add_to_visible_list;
- // Always add to ServiceCompleteListProperty.
+void FakeShillManagerClient::AddManagerService(
+ const std::string& service_path) {
+ DVLOG(2) << "AddManagerService: " << service_path;
GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent(
base::Value::CreateStringValue(service_path));
- // If visible, add to Services and notify if new.
- if (add_to_visible_list &&
- GetListProperty(shill::kServicesProperty)->AppendIfNotPresent(
- base::Value::CreateStringValue(service_path))) {
+ SortManagerServices(false);
+ CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty);
+ // SortManagerServices will add the service to Services if it is visible.
+ const base::ListValue* services = GetListProperty(shill::kServicesProperty);
+ if (services->Find(base::StringValue(service_path)) != services->end())
CallNotifyObserversPropertyChanged(shill::kServicesProperty);
- }
}
void FakeShillManagerClient::RemoveManagerService(
- const std::string& service_path,
- bool remove_from_complete_list) {
+ const std::string& service_path) {
DVLOG(2) << "RemoveManagerService: " << service_path;
base::StringValue service_path_value(service_path);
- if (remove_from_complete_list) {
- GetListProperty(shill::kServiceCompleteListProperty)->Remove(
- service_path_value, NULL);
- }
+ GetListProperty(shill::kServiceCompleteListProperty)->Remove(
+ service_path_value, NULL);
+ CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty);
if (GetListProperty(shill::kServicesProperty)->Remove(
- service_path_value, NULL)) {
+ service_path_value, NULL)) {
CallNotifyObserversPropertyChanged(shill::kServicesProperty);
}
}
@@ -480,6 +491,7 @@ void FakeShillManagerClient::ClearManagerServices() {
DVLOG(1) << "ClearManagerServices";
GetListProperty(shill::kServiceCompleteListProperty)->Clear();
GetListProperty(shill::kServicesProperty)->Clear();
+ CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty);
CallNotifyObserversPropertyChanged(shill::kServicesProperty);
}
@@ -494,42 +506,53 @@ void FakeShillManagerClient::ServiceStateChanged(
}
}
-void FakeShillManagerClient::SortManagerServices() {
+void FakeShillManagerClient::SortManagerServices(bool notify) {
DVLOG(1) << "SortManagerServices";
- SortServiceList(shill::kServicesProperty);
- SortServiceList(shill::kServiceCompleteListProperty);
-}
-
-void FakeShillManagerClient::SortServiceList(const std::string& property) {
- static const char* ordered_types[] = {
- shill::kTypeEthernet,
- shill::kTypeWifi,
- shill::kTypeCellular,
- shill::kTypeWimax,
- shill::kTypeVPN
- };
+ static const char* ordered_types[] = {shill::kTypeEthernet,
+ shill::kTypeWifi,
+ shill::kTypeCellular,
+ shill::kTypeWimax,
+ shill::kTypeVPN};
- base::ListValue* service_list = GetListProperty(property);
+ base::ListValue* service_list = GetListProperty(shill::kServicesProperty);
scoped_ptr<base::ListValue> prev_service_list(service_list->DeepCopy());
+ base::ListValue* complete_list =
+ GetListProperty(shill::kServiceCompleteListProperty);
+ if (complete_list->empty())
+ return;
+ scoped_ptr<base::ListValue> prev_complete_list(complete_list->DeepCopy());
+
std::vector<std::string> active_services;
std::vector<std::string> inactive_services;
- if (service_list && !service_list->empty()) {
- for (size_t i = 0; i < arraysize(ordered_types); ++i) {
- AppendServicesForType(service_list, ordered_types[i],
- &active_services, &inactive_services);
- }
- service_list->Clear();
- for (size_t i = 0; i < active_services.size(); ++i)
- service_list->AppendString(active_services[i]);
- for (size_t i = 0; i < inactive_services.size(); ++i)
- service_list->AppendString(inactive_services[i]);
+ std::vector<std::string> disabled_services;
+ for (size_t i = 0; i < arraysize(ordered_types); ++i) {
+ AppendServicesForType(complete_list,
+ ordered_types[i],
+ TechnologyEnabled(ordered_types[i]),
+ &active_services,
+ &inactive_services,
+ &disabled_services);
+ }
+ service_list->Clear();
+ complete_list->Clear();
+ for (size_t i = 0; i < active_services.size(); ++i) {
+ complete_list->AppendString(active_services[i]);
+ service_list->AppendString(active_services[i]);
+ }
+ for (size_t i = 0; i < inactive_services.size(); ++i) {
+ complete_list->AppendString(inactive_services[i]);
+ service_list->AppendString(inactive_services[i]);
+ }
+ for (size_t i = 0; i < disabled_services.size(); ++i) {
+ complete_list->AppendString(disabled_services[i]);
}
- if (property != shill::kServicesProperty)
- return;
-
- if (!service_list->Equals(prev_service_list.get()))
- CallNotifyObserversPropertyChanged(shill::kServicesProperty);
+ if (notify) {
+ if (!service_list->Equals(prev_service_list.get()))
+ CallNotifyObserversPropertyChanged(shill::kServicesProperty);
+ if (!complete_list->Equals(prev_complete_list.get()))
+ CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty);
+ }
// Set the first active service as the Default service.
std::string new_default_service;
@@ -783,7 +806,7 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
"/service/vpn2", shill::kProviderProperty, provider_properties);
}
- SortManagerServices();
+ SortManagerServices(true);
}
// Private methods
@@ -792,10 +815,6 @@ void FakeShillManagerClient::PassStubProperties(
const DictionaryValueCallback& callback) const {
scoped_ptr<base::DictionaryValue> stub_properties(
stub_properties_.DeepCopy());
- // Remove disabled services from the list.
- stub_properties->SetWithoutPathExpansion(
- shill::kServicesProperty,
- GetEnabledServiceList(shill::kServicesProperty));
callback.Run(DBUS_METHOD_CALL_SUCCESS, *stub_properties);
}
@@ -820,23 +839,6 @@ void FakeShillManagerClient::CallNotifyObserversPropertyChanged(
void FakeShillManagerClient::NotifyObserversPropertyChanged(
const std::string& property) {
DVLOG(1) << "NotifyObserversPropertyChanged: " << property;
- if (property == shill::kServicesProperty) {
- scoped_ptr<base::ListValue> services(GetEnabledServiceList(property));
- FOR_EACH_OBSERVER(ShillPropertyChangedObserver,
- observer_list_,
- OnPropertyChanged(property, *(services.get())));
- return;
- }
- if (property == shill::kDevicesProperty) {
- base::ListValue* devices = NULL;
- if (stub_properties_.GetListWithoutPathExpansion(
- shill::kDevicesProperty, &devices)) {
- FOR_EACH_OBSERVER(ShillPropertyChangedObserver,
- observer_list_,
- OnPropertyChanged(property, *devices));
- }
- return;
- }
base::Value* value = NULL;
if (!stub_properties_.GetWithoutPathExpansion(property, &value)) {
LOG(ERROR) << "Notify for unknown property: " << property;
@@ -885,35 +887,8 @@ void FakeShillManagerClient::SetTechnologyEnabled(
CallNotifyObserversPropertyChanged(
shill::kEnabledTechnologiesProperty);
base::MessageLoop::current()->PostTask(FROM_HERE, callback);
- // May affect available services
- CallNotifyObserversPropertyChanged(shill::kServicesProperty);
-}
-
-base::ListValue* FakeShillManagerClient::GetEnabledServiceList(
- const std::string& property) const {
- base::ListValue* new_service_list = new base::ListValue;
- const base::ListValue* service_list;
- if (stub_properties_.GetListWithoutPathExpansion(property, &service_list)) {
- ShillServiceClient::TestInterface* service_client =
- DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
- for (base::ListValue::const_iterator iter = service_list->begin();
- iter != service_list->end(); ++iter) {
- std::string service_path;
- if (!(*iter)->GetAsString(&service_path))
- continue;
- const base::DictionaryValue* properties =
- service_client->GetServiceProperties(service_path);
- if (!properties) {
- LOG(ERROR) << "Properties not found for service: " << service_path;
- continue;
- }
- std::string type;
- properties->GetString(shill::kTypeProperty, &type);
- if (TechnologyEnabled(type))
- new_service_list->Append((*iter)->DeepCopy());
- }
- }
- return new_service_list;
+ // May affect available services.
+ SortManagerServices(true);
}
void FakeShillManagerClient::ScanCompleted(const std::string& device_path,
@@ -925,6 +900,7 @@ void FakeShillManagerClient::ScanCompleted(const std::string& device_path,
base::FundamentalValue(false));
}
DVLOG(2) << "ScanCompleted";
+ CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty);
CallNotifyObserversPropertyChanged(shill::kServicesProperty);
base::MessageLoop::current()->PostTask(FROM_HERE, callback);
}
diff --git a/chromeos/dbus/fake_shill_manager_client.h b/chromeos/dbus/fake_shill_manager_client.h
index e0f4a22..97dd663 100644
--- a/chromeos/dbus/fake_shill_manager_client.h
+++ b/chromeos/dbus/fake_shill_manager_client.h
@@ -93,14 +93,12 @@ class CHROMEOS_EXPORT FakeShillManagerClient
virtual void ClearProperties() OVERRIDE;
virtual void SetManagerProperty(const std::string& key,
const base::Value& value) OVERRIDE;
- virtual void AddManagerService(const std::string& service_path,
- bool add_to_visible_list) OVERRIDE;
- virtual void RemoveManagerService(const std::string& service_path,
- bool remove_from_complete_list) OVERRIDE;
+ virtual void AddManagerService(const std::string& service_path) OVERRIDE;
+ virtual void RemoveManagerService(const std::string& service_path) OVERRIDE;
virtual void ClearManagerServices() OVERRIDE;
virtual void ServiceStateChanged(const std::string& service_path,
const std::string& state) OVERRIDE;
- virtual void SortManagerServices() OVERRIDE;
+ virtual void SortManagerServices(bool notify) OVERRIDE;
virtual void SetupDefaultEnvironment() OVERRIDE;
virtual int GetInteractiveDelay() const OVERRIDE;
virtual void SetBestServiceToConnect(
@@ -123,7 +121,6 @@ class CHROMEOS_EXPORT FakeShillManagerClient
void SetTechnologyEnabled(const std::string& type,
const base::Closure& callback,
bool enabled);
- base::ListValue* GetEnabledServiceList(const std::string& property) const;
void ScanCompleted(const std::string& device_path,
const base::Closure& callback);
diff --git a/chromeos/dbus/fake_shill_profile_client.cc b/chromeos/dbus/fake_shill_profile_client.cc
index 55caad8f..2a5f9ca 100644
--- a/chromeos/dbus/fake_shill_profile_client.cc
+++ b/chromeos/dbus/fake_shill_profile_client.cc
@@ -145,7 +145,7 @@ void FakeShillProfileClient::AddEntry(const std::string& profile_path,
DCHECK(profile);
profile->entries.SetWithoutPathExpansion(entry_path, properties.DeepCopy());
DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- AddManagerService(entry_path, false /* visible */);
+ AddManagerService(entry_path);
}
bool FakeShillProfileClient::AddService(const std::string& profile_path,
@@ -153,14 +153,12 @@ bool FakeShillProfileClient::AddService(const std::string& profile_path,
ProfileProperties* profile = GetProfile(dbus::ObjectPath(profile_path),
ErrorCallback());
if (!profile) {
- LOG(ERROR) << "AddService: No matching profile: " << profile_path;
+ LOG(ERROR) << "AddService: No matching profile: " << profile_path
+ << " for: " << service_path;
return false;
}
- if (profile->entries.HasKey(service_path)) {
- LOG(ERROR) << "AddService: Profile: " << profile_path
- << " already contains Service: " << service_path;
+ if (profile->entries.HasKey(service_path))
return false;
- }
return AddOrUpdateServiceImpl(profile_path, service_path, profile);
}
@@ -169,7 +167,8 @@ bool FakeShillProfileClient::UpdateService(const std::string& profile_path,
ProfileProperties* profile = GetProfile(dbus::ObjectPath(profile_path),
ErrorCallback());
if (!profile) {
- LOG(ERROR) << "UpdateService: No matching profile: " << profile_path;
+ LOG(ERROR) << "UpdateService: No matching profile: " << profile_path
+ << " for: " << service_path;
return false;
}
if (!profile->entries.HasKey(service_path)) {
diff --git a/chromeos/dbus/fake_shill_service_client.cc b/chromeos/dbus/fake_shill_service_client.cc
index 6df6ec2..647625c 100644
--- a/chromeos/dbus/fake_shill_service_client.cc
+++ b/chromeos/dbus/fake_shill_service_client.cc
@@ -39,7 +39,7 @@ void PassStubServiceProperties(
void CallSortManagerServices() {
DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- SortManagerServices();
+ SortManagerServices(true);
}
int GetInteractiveDelay() {
@@ -322,8 +322,6 @@ void FakeShillServiceClient::AddServiceWithIPConfig(
const std::string& state,
const std::string& ipconfig_path,
bool add_to_visible_list) {
- DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- AddManagerService(service_path, add_to_visible_list);
std::string device_path =
DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()->
GetDevicePathForType(type);
@@ -366,6 +364,9 @@ void FakeShillServiceClient::AddServiceWithIPConfig(
properties->SetWithoutPathExpansion(
shill::kStateProperty,
new base::StringValue(state));
+ properties->SetWithoutPathExpansion(
+ shill::kVisibleProperty,
+ new base::FundamentalValue(add_to_visible_list));
if (!ipconfig_path.empty()) {
properties->SetWithoutPathExpansion(
shill::kIPConfigProperty,
@@ -377,20 +378,20 @@ void FakeShillServiceClient::AddServiceWithIPConfig(
new base::StringValue(shill::kSecurityNone));
}
- CallSortManagerServices();
-
if (!profile_path.empty()) {
DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()->
UpdateService(profile_path, service_path);
}
-}
-void FakeShillServiceClient::RemoveService(const std::string& service_path) {
DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
- RemoveManagerService(service_path, true);
+ AddManagerService(service_path);
+}
+void FakeShillServiceClient::RemoveService(const std::string& service_path) {
stub_services_.RemoveWithoutPathExpansion(service_path, NULL);
connect_behavior_.erase(service_path);
+ DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
+ RemoveManagerService(service_path);
}
bool FakeShillServiceClient::SetServiceProperty(const std::string& service_path,
@@ -448,9 +449,10 @@ bool FakeShillServiceClient::SetServiceProperty(const std::string& service_path,
ServiceStateChanged(service_path, state);
}
- // If the State changes, the sort order of Services may change and the
- // DefaultService property may change.
- if (property == shill::kStateProperty) {
+ // If the State or Visibility changes, the sort order of service lists may
+ // change and the DefaultService property may change.
+ if (property == shill::kStateProperty ||
+ property == shill::kVisibleProperty) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&CallSortManagerServices));
}
diff --git a/chromeos/dbus/shill_manager_client.h b/chromeos/dbus/shill_manager_client.h
index 73de329..23ca24a 100644
--- a/chromeos/dbus/shill_manager_client.h
+++ b/chromeos/dbus/shill_manager_client.h
@@ -62,10 +62,8 @@ class CHROMEOS_EXPORT ShillManagerClient : public DBusClient {
const base::Value& value) = 0;
// Modify services in the Manager's list.
- virtual void AddManagerService(const std::string& service_path,
- bool add_to_visible_list) = 0;
- virtual void RemoveManagerService(const std::string& service_path,
- bool remove_from_complete_list) = 0;
+ virtual void AddManagerService(const std::string& service_path) = 0;
+ virtual void RemoveManagerService(const std::string& service_path) = 0;
virtual void ClearManagerServices() = 0;
// Called by ShillServiceClient when a service's State property changes,
@@ -74,10 +72,11 @@ class CHROMEOS_EXPORT ShillManagerClient : public DBusClient {
virtual void ServiceStateChanged(const std::string& service_path,
const std::string& state) = 0;
- // Called by ShillServiceClient when a service's State property changes,
- // after notifying observers. Services are sorted first by Active or
- // Inactive State, then by Type.
- virtual void SortManagerServices() = 0;
+ // Called by ShillServiceClient when a service's State or Visibile
+ // property changes. If |notify| is true, notifies observers if a list
+ // changed. Services are sorted first by active, inactive, or disabled
+ // state, then by type.
+ virtual void SortManagerServices(bool notify) = 0;
// Sets up the default fake environment based on default initial states
// or states provided by the command line.
diff --git a/chromeos/network/client_cert_resolver.cc b/chromeos/network/client_cert_resolver.cc
index 32f7ed7..96261dd 100644
--- a/chromeos/network/client_cert_resolver.cc
+++ b/chromeos/network/client_cert_resolver.cc
@@ -23,9 +23,8 @@
#include "chromeos/dbus/shill_service_client.h"
#include "chromeos/network/certificate_pattern.h"
#include "chromeos/network/client_cert_util.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/network/network_state.h"
#include "chromeos/network/network_ui_data.h"
#include "chromeos/tpm_token_loader.h"
#include "components/onc/onc_constants.h"
@@ -309,12 +308,17 @@ void ClientCertResolver::NetworkListChanged() {
std::set<std::string> old_resolved_networks;
old_resolved_networks.swap(resolved_networks_);
- FavoriteStateList networks;
- network_state_handler_->GetFavoriteList(&networks);
-
- FavoriteStateList networks_to_check;
- for (FavoriteStateList::const_iterator it = networks.begin();
- it != networks.end(); ++it) {
+ NetworkStateHandler::NetworkStateList networks;
+ network_state_handler_->GetNetworkListByType(
+ NetworkTypePattern::Default(),
+ true /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &networks);
+
+ NetworkStateHandler::NetworkStateList networks_to_check;
+ for (NetworkStateHandler::NetworkStateList::const_iterator it =
+ networks.begin(); it != networks.end(); ++it) {
const std::string& service_path = (*it)->path();
if (ContainsKey(old_resolved_networks, service_path)) {
resolved_networks_.insert(service_path);
@@ -333,8 +337,13 @@ void ClientCertResolver::OnCertificatesLoaded(
if (!ClientCertificatesLoaded())
return;
// Compare all networks with all certificates.
- FavoriteStateList networks;
- network_state_handler_->GetFavoriteList(&networks);
+ NetworkStateHandler::NetworkStateList networks;
+ network_state_handler_->GetNetworkListByType(
+ NetworkTypePattern::Default(),
+ true /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &networks);
ResolveNetworks(networks);
}
@@ -343,27 +352,28 @@ void ClientCertResolver::PolicyApplied(const std::string& service_path) {
if (!ClientCertificatesLoaded())
return;
// Compare this network with all certificates.
- const FavoriteState* network =
- network_state_handler_->GetFavoriteStateFromServicePath(
+ const NetworkState* network =
+ network_state_handler_->GetNetworkStateFromServicePath(
service_path, true /* configured_only */);
if (!network) {
LOG(ERROR) << "service path '" << service_path << "' unknown.";
return;
}
- FavoriteStateList networks;
+ NetworkStateHandler::NetworkStateList networks;
networks.push_back(network);
ResolveNetworks(networks);
}
-void ClientCertResolver::ResolveNetworks(const FavoriteStateList& networks) {
+void ClientCertResolver::ResolveNetworks(
+ const NetworkStateHandler::NetworkStateList& networks) {
scoped_ptr<std::vector<NetworkAndCertPattern> > networks_with_pattern(
new std::vector<NetworkAndCertPattern>);
// Filter networks with ClientCertPattern. As ClientCertPatterns can only be
// set by policy, we check there.
- for (FavoriteStateList::const_iterator it = networks.begin();
- it != networks.end(); ++it) {
- const FavoriteState* network = *it;
+ for (NetworkStateHandler::NetworkStateList::const_iterator it =
+ networks.begin(); it != networks.end(); ++it) {
+ const NetworkState* network = *it;
// In any case, don't check this network again in NetworkListChanged.
resolved_networks_.insert(network->path());
diff --git a/chromeos/network/client_cert_resolver.h b/chromeos/network/client_cert_resolver.h
index da5fd8f..9e70a57 100644
--- a/chromeos/network/client_cert_resolver.h
+++ b/chromeos/network/client_cert_resolver.h
@@ -15,6 +15,7 @@
#include "chromeos/cert_loader.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/network/network_policy_observer.h"
+#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_state_handler_observer.h"
namespace base {
@@ -23,8 +24,7 @@ class TaskRunner;
namespace chromeos {
-class FavoriteState;
-class NetworkStateHandler;
+class NetworkState;
class ManagedNetworkConfigurationHandler;
// Observes the known networks. If a network is configured with a client
@@ -48,8 +48,6 @@ class CHROMEOS_EXPORT ClientCertResolver : public NetworkStateHandlerObserver,
const scoped_refptr<base::TaskRunner>& task_runner);
private:
- typedef std::vector<const FavoriteState*> FavoriteStateList;
-
// NetworkStateHandlerObserver overrides
virtual void NetworkListChanged() OVERRIDE;
@@ -63,7 +61,7 @@ class CHROMEOS_EXPORT ClientCertResolver : public NetworkStateHandlerObserver,
// Check which networks of |networks| are configured with a client certificate
// pattern. Search for certificates, on the worker thread, and configure the
// networks for which a matching cert is found (see ConfigureCertificates).
- void ResolveNetworks(const FavoriteStateList& networks);
+ void ResolveNetworks(const NetworkStateHandler::NetworkStateList& networks);
// |matches| contains networks for which a matching certificate was found.
// Configures these networks.
diff --git a/chromeos/network/client_cert_resolver_unittest.cc b/chromeos/network/client_cert_resolver_unittest.cc
index 56015f0..8a6cd6e 100644
--- a/chromeos/network/client_cert_resolver_unittest.cc
+++ b/chromeos/network/client_cert_resolver_unittest.cc
@@ -141,7 +141,7 @@ class ClientCertResolverTest : public testing::Test {
managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl());
client_cert_resolver_.reset(new ClientCertResolver());
- network_profile_handler_->Init(network_state_handler_.get());
+ network_profile_handler_->Init();
network_config_handler_->Init(network_state_handler_.get());
managed_config_handler_->Init(network_state_handler_.get(),
network_profile_handler_.get(),
diff --git a/chromeos/network/favorite_state.cc b/chromeos/network/favorite_state.cc
deleted file mode 100644
index 8fa8c8e..0000000
--- a/chromeos/network/favorite_state.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromeos/network/favorite_state.h"
-
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/stringprintf.h"
-#include "chromeos/network/network_event_log.h"
-#include "chromeos/network/network_profile_handler.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/onc/onc_utils.h"
-#include "chromeos/network/shill_property_util.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-
-namespace chromeos {
-
-FavoriteState::FavoriteState(const std::string& path)
- : ManagedState(MANAGED_TYPE_FAVORITE, path) {
-}
-
-FavoriteState::~FavoriteState() {
-}
-
-bool FavoriteState::PropertyChanged(const std::string& key,
- const base::Value& value) {
- if (ManagedStatePropertyChanged(key, value))
- return true;
- if (key == shill::kProfileProperty) {
- return GetStringValue(key, value, &profile_path_);
- } else if (key == shill::kUIDataProperty) {
- scoped_ptr<NetworkUIData> new_ui_data =
- shill_property_util::GetUIDataFromValue(value);
- if (!new_ui_data) {
- NET_LOG_ERROR("Failed to parse " + key, path());
- return false;
- }
- ui_data_ = *new_ui_data;
- return true;
- } else if (key == shill::kGuidProperty) {
- return GetStringValue(key, value, &guid_);
- } else if (key == shill::kProxyConfigProperty) {
- std::string proxy_config_str;
- if (!value.GetAsString(&proxy_config_str)) {
- NET_LOG_ERROR("Failed to parse " + key, path());
- return false;
- }
-
- proxy_config_.Clear();
- if (proxy_config_str.empty())
- return true;
-
- scoped_ptr<base::DictionaryValue> proxy_config_dict(
- onc::ReadDictionaryFromJson(proxy_config_str));
- if (proxy_config_dict) {
- // Warning: The DictionaryValue returned from
- // ReadDictionaryFromJson/JSONParser is an optimized derived class that
- // doesn't allow releasing ownership of nested values. A Swap in the wrong
- // order leads to memory access errors.
- proxy_config_.MergeDictionary(proxy_config_dict.get());
- } else {
- NET_LOG_ERROR("Failed to parse " + key, path());
- }
- return true;
- } else if (key == shill::kSecurityProperty) {
- return GetStringValue(key, value, &security_);
- }
- return false;
-}
-
-void FavoriteState::GetStateProperties(
- base::DictionaryValue* dictionary) const {
- ManagedState::GetStateProperties(dictionary);
-
- dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid());
- dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty,
- security_);
-
- // Note: The following are added for debugging, but do not translate to ONC.
- dictionary->SetStringWithoutPathExpansion(shill::kProfileProperty,
- profile_path());
- dictionary->SetStringWithoutPathExpansion(NetworkUIData::kKeyONCSource,
- ui_data_.GetONCSourceAsString());
-}
-
-std::string FavoriteState::GetSpecifier() const {
- if (!update_received()) {
- NET_LOG_ERROR("GetSpecifier called before update", path());
- return std::string();
- }
- if (type() == shill::kTypeWifi)
- return name() + "_" + security_;
- if (!name().empty())
- return name();
- return type(); // For unnamed networks such as ethernet.
-}
-
-void FavoriteState::SetGuid(const std::string& guid) {
- DCHECK(guid_.empty());
- guid_ = guid;
-}
-
-bool FavoriteState::IsInProfile() const {
- // kTypeEthernetEap is always saved. We need this check because it does
- // not show up in the visible list, but its properties may not be available
- // when it first shows up in ServiceCompleteList. See crbug.com/355117.
- return !profile_path_.empty() || type() == shill::kTypeEthernetEap;
-}
-
-bool FavoriteState::IsPrivate() const {
- return !profile_path_.empty() &&
- profile_path_ != NetworkProfileHandler::GetSharedProfilePath();
-}
-
-} // namespace chromeos
diff --git a/chromeos/network/favorite_state.h b/chromeos/network/favorite_state.h
deleted file mode 100644
index e68f3a3..0000000
--- a/chromeos/network/favorite_state.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMEOS_NETWORK_FAVORITE_STATE_H_
-#define CHROMEOS_NETWORK_FAVORITE_STATE_H_
-
-#include <string>
-
-#include "base/values.h"
-#include "chromeos/network/managed_state.h"
-#include "chromeos/network/network_ui_data.h"
-#include "components/onc/onc_constants.h"
-
-namespace chromeos {
-
-// A simple class to provide essential information for Services created
-// by Shill corresponding to Profile Entries (i.e. 'preferred' or 'favorite'
-// networks).
-// Note: NetworkStateHandler will store an entry for each member of
-// Manager.ServiceCompleteList, even for visible entries that are not
-// saved. This is necessary to avoid unnecessarily re-requesting entries,
-// and to limit the code complexity. It is also convenient for tracking the
-// complete list of "known" networks. The IsInProfile() accessor is used to
-// skip entries that are not actually saved in a profile.
-class CHROMEOS_EXPORT FavoriteState : public ManagedState {
- public:
- explicit FavoriteState(const std::string& path);
- virtual ~FavoriteState();
-
- // ManagedState overrides
- virtual bool PropertyChanged(const std::string& key,
- const base::Value& value) OVERRIDE;
- virtual void GetStateProperties(
- base::DictionaryValue* dictionary) const OVERRIDE;
-
- // Accessors
- const std::string& profile_path() const { return profile_path_; }
- const NetworkUIData& ui_data() const { return ui_data_; }
- const base::DictionaryValue& proxy_config() const { return proxy_config_; }
- const std::string& guid() const { return guid_; }
-
- // Returns true if this is a favorite stored in a profile (see note above).
- bool IsInProfile() const;
-
- // Returns true if the network properties are stored in a user profile.
- bool IsPrivate() const;
-
- // Returns a specifier for identifying this network in the absence of a GUID.
- // This should only be used by NetworkStateHandler for keeping track of
- // GUIDs assigned to unsaved networks.
- std::string GetSpecifier() const;
-
- // Set the GUID. Called exclusively by NetworkStateHandler.
- void SetGuid(const std::string& guid);
-
- private:
- std::string profile_path_;
- NetworkUIData ui_data_;
- std::string guid_;
-
- // Keep track of Service.Security. Only used for specifying wifi networks.
- std::string security_;
-
- // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler
- // provides proxy configuration. crbug.com/241775
- base::DictionaryValue proxy_config_;
-
- DISALLOW_COPY_AND_ASSIGN(FavoriteState);
-};
-
-} // namespace chromeos
-
-#endif // CHROMEOS_NETWORK_FAVORITE_STATE_H_
diff --git a/chromeos/network/managed_network_configuration_handler_impl.cc b/chromeos/network/managed_network_configuration_handler_impl.cc
index b7495c4..9bcf193 100644
--- a/chromeos/network/managed_network_configuration_handler_impl.cc
+++ b/chromeos/network/managed_network_configuration_handler_impl.cc
@@ -19,7 +19,6 @@
#include "chromeos/dbus/shill_profile_client.h"
#include "chromeos/dbus/shill_service_client.h"
#include "chromeos/network/device_state.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_device_handler.h"
#include "chromeos/network/network_event_log.h"
@@ -242,8 +241,8 @@ void ManagedNetworkConfigurationHandlerImpl::SetProperties(
const base::DictionaryValue& user_settings,
const base::Closure& callback,
const network_handler::ErrorCallback& error_callback) const {
- const FavoriteState* state =
- network_state_handler_->GetFavoriteStateFromServicePath(
+ const NetworkState* state =
+ network_state_handler_->GetNetworkStateFromServicePath(
service_path, true /* configured_only */);
if (!state) {
InvokeErrorCallback(service_path, error_callback, kUnknownNetwork);
@@ -507,9 +506,6 @@ void ManagedNetworkConfigurationHandlerImpl::
}
void ManagedNetworkConfigurationHandlerImpl::OnPoliciesApplied() {
- // After all policies were applied, trigger an update of the network lists.
- if (network_state_handler_)
- network_state_handler_->UpdateManagerProperties();
}
const base::DictionaryValue*
diff --git a/chromeos/network/managed_network_configuration_handler_unittest.cc b/chromeos/network/managed_network_configuration_handler_unittest.cc
index 529691b..b880437 100644
--- a/chromeos/network/managed_network_configuration_handler_unittest.cc
+++ b/chromeos/network/managed_network_configuration_handler_unittest.cc
@@ -134,7 +134,7 @@ class ShillProfileTestClient {
class TestNetworkProfileHandler : public NetworkProfileHandler {
public:
TestNetworkProfileHandler() {
- Init(NULL /* No NetworkStateHandler */);
+ Init();
}
virtual ~TestNetworkProfileHandler() {}
diff --git a/chromeos/network/managed_state.cc b/chromeos/network/managed_state.cc
index 2c41781..75fce5b 100644
--- a/chromeos/network/managed_state.cc
+++ b/chromeos/network/managed_state.cc
@@ -7,7 +7,6 @@
#include "base/logging.h"
#include "base/values.h"
#include "chromeos/network/device_state.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_type_pattern.h"
@@ -24,8 +23,6 @@ std::string ManagedState::TypeToString(ManagedType type) {
switch (type) {
case MANAGED_TYPE_NETWORK:
return "Network";
- case MANAGED_TYPE_FAVORITE:
- return "Favorite";
case MANAGED_TYPE_DEVICE:
return "Device";
}
@@ -46,8 +43,6 @@ ManagedState* ManagedState::Create(ManagedType type, const std::string& path) {
switch (type) {
case MANAGED_TYPE_NETWORK:
return new NetworkState(path);
- case MANAGED_TYPE_FAVORITE:
- return new FavoriteState(path);
case MANAGED_TYPE_DEVICE:
return new DeviceState(path);
}
@@ -66,12 +61,6 @@ DeviceState* ManagedState::AsDeviceState() {
return NULL;
}
-FavoriteState* ManagedState::AsFavoriteState() {
- if (managed_type() == MANAGED_TYPE_FAVORITE)
- return static_cast<FavoriteState*>(this);
- return NULL;
-}
-
bool ManagedState::InitialPropertiesReceived(
const base::DictionaryValue& properties) {
return false;
diff --git a/chromeos/network/managed_state.h b/chromeos/network/managed_state.h
index 28e647d..5fc39e0 100644
--- a/chromeos/network/managed_state.h
+++ b/chromeos/network/managed_state.h
@@ -19,7 +19,6 @@ class DictionaryValue;
namespace chromeos {
class DeviceState;
-class FavoriteState;
class NetworkState;
class NetworkTypePattern;
@@ -29,7 +28,6 @@ class CHROMEOS_EXPORT ManagedState {
public:
enum ManagedType {
MANAGED_TYPE_NETWORK,
- MANAGED_TYPE_FAVORITE,
MANAGED_TYPE_DEVICE
};
@@ -43,7 +41,6 @@ class CHROMEOS_EXPORT ManagedState {
// NULL if it is not.
NetworkState* AsNetworkState();
DeviceState* AsDeviceState();
- FavoriteState* AsFavoriteState();
// Called by NetworkStateHandler when a property was received. The return
// value indicates if the state changed and is used to reduce the number of
diff --git a/chromeos/network/network_cert_migrator.cc b/chromeos/network/network_cert_migrator.cc
index 693ebf5..29a3410 100644
--- a/chromeos/network/network_cert_migrator.cc
+++ b/chromeos/network/network_cert_migrator.cc
@@ -263,7 +263,7 @@ void NetworkCertMigrator::NetworkListChanged() {
scoped_refptr<MigrationTask> helper(new MigrationTask(
CertLoader::Get()->cert_list(), weak_ptr_factory_.GetWeakPtr()));
NetworkStateHandler::NetworkStateList networks;
- network_state_handler_->GetNetworkList(&networks);
+ network_state_handler_->GetVisibleNetworkList(&networks);
helper->Run(networks);
}
diff --git a/chromeos/network/network_change_notifier_chromeos_unittest.cc b/chromeos/network/network_change_notifier_chromeos_unittest.cc
index 90e5162..04d549f 100644
--- a/chromeos/network/network_change_notifier_chromeos_unittest.cc
+++ b/chromeos/network/network_change_notifier_chromeos_unittest.cc
@@ -127,6 +127,7 @@ class NetworkChangeNotifierChromeosUpdateTest : public testing::Test {
// Sets the default network state used for notifier updates.
void SetDefaultNetworkState(
const DefaultNetworkState& default_network_state) {
+ default_network_.visible_ = true;
if (default_network_state.is_connected)
default_network_.connection_state_ = shill::kStateOnline;
else
diff --git a/chromeos/network/network_configuration_handler.cc b/chromeos/network/network_configuration_handler.cc
index 81c473c..79ad45d 100644
--- a/chromeos/network/network_configuration_handler.cc
+++ b/chromeos/network/network_configuration_handler.cc
@@ -174,8 +174,6 @@ class NetworkConfigurationHandler::ProfileEntryDeleter
// Run the callback if this is the last pending deletion.
if (!callback_.is_null())
callback_.Run();
- // Request NetworkStateHandler manager update to update ServiceCompleteList.
- owner_->network_state_handler_->UpdateManagerProperties();
owner_->ProfileEntryDeleterCompleted(service_path_); // Deletes this.
}
diff --git a/chromeos/network/network_connection_handler.cc b/chromeos/network/network_connection_handler.cc
index 380a052..ea61851 100644
--- a/chromeos/network/network_connection_handler.cc
+++ b/chromeos/network/network_connection_handler.cc
@@ -819,8 +819,8 @@ void NetworkConnectionHandler::DisconnectIfPolicyRequires() {
// Get the list of unmanaged & shared networks that are connected or
// connecting.
NetworkStateHandler::NetworkStateList networks;
- network_state_handler_->GetNetworkListByType(NetworkTypePattern::Wireless(),
- &networks);
+ network_state_handler_->GetVisibleNetworkListByType(
+ NetworkTypePattern::Wireless(), &networks);
for (NetworkStateHandler::NetworkStateList::const_iterator it =
networks.begin();
it != networks.end();
diff --git a/chromeos/network/network_connection_handler_unittest.cc b/chromeos/network/network_connection_handler_unittest.cc
index ed2d786..257a0f4 100644
--- a/chromeos/network/network_connection_handler_unittest.cc
+++ b/chromeos/network/network_connection_handler_unittest.cc
@@ -101,7 +101,7 @@ class NetworkConnectionHandlerTest : public testing::Test {
network_state_handler_.get()));
network_profile_handler_.reset(new NetworkProfileHandler());
- network_profile_handler_->Init(network_state_handler_.get());
+ network_profile_handler_->Init();
managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl());
managed_config_handler_->Init(network_state_handler_.get(),
diff --git a/chromeos/network/network_handler.cc b/chromeos/network/network_handler.cc
index 4685367..ae26710 100644
--- a/chromeos/network/network_handler.cc
+++ b/chromeos/network/network_handler.cc
@@ -54,7 +54,7 @@ NetworkHandler::~NetworkHandler() {
void NetworkHandler::Init() {
network_state_handler_->InitShillPropertyHandler();
network_device_handler_->Init(network_state_handler_.get());
- network_profile_handler_->Init(network_state_handler_.get());
+ network_profile_handler_->Init();
network_configuration_handler_->Init(network_state_handler_.get());
managed_network_configuration_handler_->Init(
network_state_handler_.get(),
diff --git a/chromeos/network/network_profile_handler.cc b/chromeos/network/network_profile_handler.cc
index f4f381e..c8353cc 100644
--- a/chromeos/network/network_profile_handler.cc
+++ b/chromeos/network/network_profile_handler.cc
@@ -13,7 +13,6 @@
#include "chromeos/dbus/shill_manager_client.h"
#include "chromeos/dbus/shill_profile_client.h"
#include "chromeos/network/network_profile_observer.h"
-#include "chromeos/network/network_state_handler.h"
#include "dbus/object_path.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -132,11 +131,6 @@ void NetworkProfileHandler::OnPropertyChanged(const std::string& name,
*it),
base::Bind(&LogProfileRequestError, *it));
}
-
- // When the profile list changes, ServiceCompleteList may also change, so
- // trigger a Manager update to request the updated list.
- if (network_state_handler_)
- network_state_handler_->UpdateManagerProperties();
}
void NetworkProfileHandler::GetProfilePropertiesCallback(
@@ -200,13 +194,10 @@ const NetworkProfile* NetworkProfileHandler::GetDefaultUserProfile() const {
}
NetworkProfileHandler::NetworkProfileHandler()
- : network_state_handler_(NULL),
- weak_ptr_factory_(this) {
+ : weak_ptr_factory_(this) {
}
-void NetworkProfileHandler::Init(NetworkStateHandler* network_state_handler) {
- network_state_handler_ = network_state_handler;
-
+void NetworkProfileHandler::Init() {
DBusThreadManager::Get()->GetShillManagerClient()->
AddPropertyChangedObserver(this);
diff --git a/chromeos/network/network_profile_handler.h b/chromeos/network/network_profile_handler.h
index a5c1d0a..dcbbea92 100644
--- a/chromeos/network/network_profile_handler.h
+++ b/chromeos/network/network_profile_handler.h
@@ -66,14 +66,12 @@ class CHROMEOS_EXPORT NetworkProfileHandler
NetworkProfileHandler();
// Add ShillManagerClient property observer and request initial list.
- // Sets |network_state_handler_| for triggering Manager updates (can be NULL).
- void Init(NetworkStateHandler* network_state_handler);
+ void Init();
void AddProfile(const NetworkProfile& profile);
void RemoveProfile(const std::string& profile_path);
private:
- NetworkStateHandler* network_state_handler_;
ProfileList profiles_;
ObserverList<NetworkProfileObserver> observers_;
diff --git a/chromeos/network/network_sms_handler_unittest.cc b/chromeos/network/network_sms_handler_unittest.cc
index 9c9d6b8..b1c06e1 100644
--- a/chromeos/network/network_sms_handler_unittest.cc
+++ b/chromeos/network/network_sms_handler_unittest.cc
@@ -13,7 +13,6 @@
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
-#include "chromeos/dbus/shill_manager_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -62,15 +61,12 @@ class NetworkSmsHandlerTest : public testing::Test {
// Initialize DBusThreadManager with a stub implementation.
DBusThreadManager::InitializeWithStub();
- ShillManagerClient::TestInterface* manager_test =
- DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface();
- ASSERT_TRUE(manager_test);
- manager_test->AddDevice("stub_cellular_device2");
ShillDeviceClient::TestInterface* device_test =
DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
ASSERT_TRUE(device_test);
- device_test->AddDevice("stub_cellular_device2", shill::kTypeCellular,
- "/org/freedesktop/ModemManager1/stub/0");
+ device_test->AddDevice("/org/freedesktop/ModemManager1/stub/0",
+ shill::kTypeCellular,
+ "stub_cellular_device2");
// This relies on the stub dbus implementations for ShillManagerClient,
// ShillDeviceClient, GsmSMSClient, ModemMessagingClient and SMSClient.
diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc
index cc1b10b..2aa1b94 100644
--- a/chromeos/network/network_state.cc
+++ b/chromeos/network/network_state.cc
@@ -5,11 +5,11 @@
#include "chromeos/network/network_state.h"
#include "base/strings/stringprintf.h"
-#include "base/values.h"
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_profile_handler.h"
#include "chromeos/network/network_type_pattern.h"
#include "chromeos/network/network_util.h"
+#include "chromeos/network/onc/onc_utils.h"
#include "chromeos/network/shill_property_util.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -61,6 +61,7 @@ namespace chromeos {
NetworkState::NetworkState(const std::string& path)
: ManagedState(MANAGED_TYPE_NETWORK, path),
+ visible_(false),
connectable_(false),
prefix_length_(0),
signal_strength_(0),
@@ -120,6 +121,29 @@ bool NetworkState::PropertyChanged(const std::string& key,
return GetBooleanValue(key, value, &activate_over_non_cellular_networks_);
} else if (key == shill::kOutOfCreditsProperty) {
return GetBooleanValue(key, value, &cellular_out_of_credits_);
+ } else if (key == shill::kProxyConfigProperty) {
+ std::string proxy_config_str;
+ if (!value.GetAsString(&proxy_config_str)) {
+ NET_LOG_ERROR("Failed to parse " + key, path());
+ return false;
+ }
+
+ proxy_config_.Clear();
+ if (proxy_config_str.empty())
+ return true;
+
+ scoped_ptr<base::DictionaryValue> proxy_config_dict(
+ onc::ReadDictionaryFromJson(proxy_config_str));
+ if (proxy_config_dict) {
+ // Warning: The DictionaryValue returned from
+ // ReadDictionaryFromJson/JSONParser is an optimized derived class that
+ // doesn't allow releasing ownership of nested values. A Swap in the wrong
+ // order leads to memory access errors.
+ proxy_config_.MergeDictionary(proxy_config_dict.get());
+ } else {
+ NET_LOG_ERROR("Failed to parse " + key, path());
+ }
+ return true;
}
return false;
}
@@ -142,7 +166,7 @@ bool NetworkState::InitialPropertiesReceived(
changed |= had_ca_cert_nss != has_ca_cert_nss_;
// By convention, all visible WiFi networks have a SignalStrength > 0.
- if (type() == shill::kTypeWifi) {
+ if (visible() && type() == shill::kTypeWifi) {
if (signal_strength_ <= 0)
signal_strength_ = 1;
}
@@ -155,21 +179,26 @@ void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const {
// Properties shared by all types.
dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid());
- dictionary->SetStringWithoutPathExpansion(shill::kStateProperty,
- connection_state());
dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty,
security());
- if (!error().empty())
- dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error());
+ if (visible()) {
+ if (!error().empty())
+ dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error());
+ dictionary->SetStringWithoutPathExpansion(shill::kStateProperty,
+ connection_state());
+ }
+
+ // Wireless properties
if (!NetworkTypePattern::Wireless().MatchesType(type()))
return;
- // Wireless properties
- dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty,
- connectable());
- dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty,
- signal_strength());
+ if (visible()) {
+ dictionary->SetBooleanWithoutPathExpansion(shill::kConnectableProperty,
+ connectable());
+ dictionary->SetIntegerWithoutPathExpansion(shill::kSignalStrengthProperty,
+ signal_strength());
+ }
// Wifi properties
if (NetworkTypePattern::WiFi().MatchesType(type())) {
@@ -236,12 +265,25 @@ bool NetworkState::RequiresActivation() const {
activation_state() != shill::kActivationStateUnknown);
}
+std::string NetworkState::connection_state() const {
+ if (!visible())
+ return shill::kStateDisconnect;
+ return connection_state_;
+}
+
bool NetworkState::IsConnectedState() const {
- return StateIsConnected(connection_state_);
+ return visible() && StateIsConnected(connection_state_);
}
bool NetworkState::IsConnectingState() const {
- return StateIsConnecting(connection_state_);
+ return visible() && StateIsConnecting(connection_state_);
+}
+
+bool NetworkState::IsInProfile() const {
+ // kTypeEthernetEap is always saved. We need this check because it does
+ // not show up in the visible list, but its properties may not be available
+ // when it first shows up in ServiceCompleteList. See crbug.com/355117.
+ return !profile_path_.empty() || type() == shill::kTypeEthernetEap;
}
bool NetworkState::IsPrivate() const {
@@ -263,6 +305,18 @@ std::string NetworkState::GetNetmask() const {
return network_util::PrefixLengthToNetmask(prefix_length_);
}
+std::string NetworkState::GetSpecifier() const {
+ if (!update_received()) {
+ NET_LOG_ERROR("GetSpecifier called before update", path());
+ return std::string();
+ }
+ if (type() == shill::kTypeWifi)
+ return name() + "_" + security_;
+ if (!name().empty())
+ return name();
+ return type(); // For unnamed networks such as ethernet.
+}
+
void NetworkState::SetGuid(const std::string& guid) {
guid_ = guid;
}
diff --git a/chromeos/network/network_state.h b/chromeos/network/network_state.h
index 276c368..7c81501 100644
--- a/chromeos/network/network_state.h
+++ b/chromeos/network/network_state.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/values.h"
#include "chromeos/network/managed_state.h"
#include "chromeos/network/network_ui_data.h"
#include "components/onc/onc_constants.h"
@@ -25,6 +26,11 @@ namespace chromeos {
// on to. Store network_state->path() (defined in ManagedState) instead and
// call NetworkStateHandler::GetNetworkState(path) to retrieve the state for
// the network.
+//
+// Note: NetworkStateHandler will store an entry for each member of
+// Manager.ServiceCompleteList. The visible() method indicates whether the
+// network is visible, and the IsInProfile() method indicates whether the
+// network is saved in a profile.
class CHROMEOS_EXPORT NetworkState : public ManagedState {
public:
explicit NetworkState(const std::string& path);
@@ -45,16 +51,20 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
bool RequiresActivation() const;
// Accessors
+ bool visible() const { return visible_; }
const std::string& security() const { return security_; }
const std::string& device_path() const { return device_path_; }
const std::string& guid() const { return guid_; }
- const std::string& connection_state() const { return connection_state_; }
const std::string& profile_path() const { return profile_path_; }
const std::string& error() const { return error_; }
const std::string& last_error() const { return last_error_; }
void clear_last_error() { last_error_.clear(); }
+ // Returns |connection_state_| if visible, kStateDisconnect otherwise.
+ std::string connection_state() const;
+
const NetworkUIData& ui_data() const { return ui_data_; }
+ const base::DictionaryValue& proxy_config() const { return proxy_config_; }
// IPConfig Properties. These require an extra call to ShillIPConfigClient,
// so cache them to avoid excessively complex client code.
@@ -90,6 +100,9 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
bool IsConnectedState() const;
bool IsConnectingState() const;
+ // Returns true if this is a network stored in a profile.
+ bool IsInProfile() const;
+
// Returns true if the network properties are stored in a user profile.
bool IsPrivate() const;
@@ -99,6 +112,11 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
// Converts the prefix length to a netmask string.
std::string GetNetmask() const;
+ // Returns a specifier for identifying this network in the absence of a GUID.
+ // This should only be used by NetworkStateHandler for keeping track of
+ // GUIDs assigned to unsaved networks.
+ std::string GetSpecifier() const;
+
// Set the GUID. Called exclusively by NetworkStateHandler.
void SetGuid(const std::string& guid);
@@ -116,6 +134,11 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
// Returns true if |name_| changes.
bool UpdateName(const base::DictionaryValue& properties);
+ void set_visible(bool visible) { visible_ = visible; }
+
+ // Set to true if the network is a member of Manager.Services.
+ bool visible_;
+
// Network Service properties. Avoid adding any additional properties here.
// Instead use NetworkConfigurationHandler::GetProperties() to asynchronously
// request properties from Shill.
@@ -162,6 +185,10 @@ class CHROMEOS_EXPORT NetworkState : public ManagedState {
// for migration to PEM.
bool has_ca_cert_nss_;
+ // TODO(pneubeck): Remove this once (Managed)NetworkConfigurationHandler
+ // provides proxy configuration. crbug.com/241775
+ base::DictionaryValue proxy_config_;
+
DISALLOW_COPY_AND_ASSIGN(NetworkState);
};
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
index 77b0b27..179df28 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -15,7 +15,6 @@
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chromeos/network/device_state.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/managed_state.h"
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h"
@@ -38,8 +37,6 @@ std::string GetManagedStateLogType(const ManagedState* state) {
switch (state->managed_type()) {
case ManagedState::MANAGED_TYPE_NETWORK:
return "Network";
- case ManagedState::MANAGED_TYPE_FAVORITE:
- return "Favorite";
case ManagedState::MANAGED_TYPE_DEVICE:
return "Device";
}
@@ -47,7 +44,7 @@ std::string GetManagedStateLogType(const ManagedState* state) {
return "";
}
-std::string GetManagedStateLogName(const ManagedState* state) {
+std::string GetLogName(const ManagedState* state) {
if (!state)
return "None";
return base::StringPrintf("%s (%s)", state->name().c_str(),
@@ -64,7 +61,6 @@ NetworkStateHandler::NetworkStateHandler() {
NetworkStateHandler::~NetworkStateHandler() {
STLDeleteContainerPointers(network_list_.begin(), network_list_.end());
- STLDeleteContainerPointers(favorite_list_.begin(), favorite_list_.end());
STLDeleteContainerPointers(device_list_.begin(), device_list_.end());
}
@@ -100,11 +96,6 @@ void NetworkStateHandler::RemoveObserver(
"NetworkStateHandler::RemoveObserver", "");
}
-void NetworkStateHandler::UpdateManagerProperties() {
- NET_LOG_USER("UpdateManagerProperties", "");
- shill_property_handler_->UpdateManagerProperties();
-}
-
NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState(
const NetworkTypePattern& type) const {
std::string technology = GetTechnologyForType(type);
@@ -190,19 +181,6 @@ const NetworkState* NetworkStateHandler::DefaultNetwork() const {
return GetNetworkState(default_network_path_);
}
-const FavoriteState* NetworkStateHandler::DefaultFavoriteNetwork() const {
- const NetworkState* default_network = DefaultNetwork();
- if (!default_network)
- return NULL;
- const FavoriteState* default_favorite = GetFavoriteStateFromServicePath(
- default_network->path(), true /* configured_only */);
- DCHECK(default_network->type() != shill::kTypeWifi || default_favorite)
- << "No favorite for: " << default_network->path();
- DCHECK(!default_favorite || default_favorite->update_received())
- << "No update received for: " << default_network->path();
- return default_favorite;
-}
-
const NetworkState* NetworkStateHandler::ConnectedNetworkByType(
const NetworkTypePattern& type) const {
for (ManagedStateList::const_iterator iter = network_list_.begin();
@@ -243,6 +221,8 @@ const NetworkState* NetworkStateHandler::FirstNetworkByType(
DCHECK(network);
if (!network->update_received())
continue;
+ if (!network->visible())
+ break;
if (network->Matches(type))
return network;
}
@@ -262,109 +242,89 @@ std::string NetworkStateHandler::FormattedHardwareAddressForType(
return network_util::FormattedMacAddress(device->mac_address());
}
-void NetworkStateHandler::GetNetworkList(NetworkStateList* list) const {
- GetNetworkListByType(NetworkTypePattern::Default(), list);
+void NetworkStateHandler::GetVisibleNetworkListByType(
+ const NetworkTypePattern& type,
+ NetworkStateList* list) const {
+ GetNetworkListByType(type,
+ false /* configured_only */,
+ true /* visible_only */,
+ 0 /* no limit */,
+ list);
+}
+
+void NetworkStateHandler::GetVisibleNetworkList(NetworkStateList* list) const {
+ GetVisibleNetworkListByType(NetworkTypePattern::Default(), list);
}
void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type,
+ bool configured_only,
+ bool visible_only,
+ int limit,
NetworkStateList* list) const {
DCHECK(list);
list->clear();
+ int count = 0;
for (ManagedStateList::const_iterator iter = network_list_.begin();
iter != network_list_.end(); ++iter) {
const NetworkState* network = (*iter)->AsNetworkState();
DCHECK(network);
- if (network->update_received() && network->Matches(type))
- list->push_back(network);
- }
-}
-
-void NetworkStateHandler::GetDeviceList(DeviceStateList* list) const {
- GetDeviceListByType(NetworkTypePattern::Default(), list);
-}
-
-void NetworkStateHandler::GetDeviceListByType(const NetworkTypePattern& type,
- DeviceStateList* list) const {
- DCHECK(list);
- list->clear();
- for (ManagedStateList::const_iterator iter = device_list_.begin();
- iter != device_list_.end(); ++iter) {
- const DeviceState* device = (*iter)->AsDeviceState();
- DCHECK(device);
- if (device->update_received() && device->Matches(type))
- list->push_back(device);
- }
-}
-
-void NetworkStateHandler::GetFavoriteList(FavoriteStateList* list) const {
- GetFavoriteListByType(NetworkTypePattern::Default(),
- true /* configured_only */,
- false /* visible_only */,
- 0 /* no limit */,
- list);
-}
-
-void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type,
- bool configured_only,
- bool visible_only,
- int limit,
- 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();
- int count = 0;
- 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->Matches(type))
+ if (!network->update_received() || !network->Matches(type))
continue;
- if (configured_only && !favorite->IsInProfile())
+ if (configured_only && !network->IsInProfile())
continue;
- if (visible_only && !ContainsKey(visible_networks, favorite->path()))
+ if (visible_only && !network->visible())
continue;
- list->push_back(favorite);
+ list->push_back(network);
if (limit > 0 && ++count >= limit)
break;
}
}
-const FavoriteState* NetworkStateHandler::GetFavoriteStateFromServicePath(
+const NetworkState* NetworkStateHandler::GetNetworkStateFromServicePath(
const std::string& service_path,
bool configured_only) const {
ManagedState* managed =
- GetModifiableManagedState(&favorite_list_, service_path);
+ GetModifiableManagedState(&network_list_, service_path);
if (!managed)
return NULL;
- const FavoriteState* favorite = managed->AsFavoriteState();
- DCHECK(favorite);
- if (!favorite->update_received() ||
- (configured_only && !favorite->IsInProfile())) {
+ const NetworkState* network = managed->AsNetworkState();
+ DCHECK(network);
+ if (!network->update_received() ||
+ (configured_only && !network->IsInProfile())) {
return NULL;
}
- return favorite;
+ return network;
}
-const FavoriteState* NetworkStateHandler::GetFavoriteStateFromGuid(
+const NetworkState* NetworkStateHandler::GetNetworkStateFromGuid(
const std::string& guid) const {
DCHECK(!guid.empty());
- for (ManagedStateList::const_iterator iter = favorite_list_.begin();
- iter != favorite_list_.end(); ++iter) {
- const FavoriteState* favorite = (*iter)->AsFavoriteState();
- if (favorite->guid() == guid)
- return favorite;
+ for (ManagedStateList::const_iterator iter = network_list_.begin();
+ iter != network_list_.end(); ++iter) {
+ const NetworkState* network = (*iter)->AsNetworkState();
+ if (network->guid() == guid)
+ return network;
}
return NULL;
}
+void NetworkStateHandler::GetDeviceList(DeviceStateList* list) const {
+ GetDeviceListByType(NetworkTypePattern::Default(), list);
+}
+
+void NetworkStateHandler::GetDeviceListByType(const NetworkTypePattern& type,
+ DeviceStateList* list) const {
+ DCHECK(list);
+ list->clear();
+ for (ManagedStateList::const_iterator iter = device_list_.begin();
+ iter != device_list_.end(); ++iter) {
+ const DeviceState* device = (*iter)->AsDeviceState();
+ DCHECK(device);
+ if (device->update_received() && device->Matches(type))
+ list->push_back(device);
+ }
+}
+
void NetworkStateHandler::RequestScan() const {
NET_LOG_USER("RequestScan", "");
shill_property_handler_->RequestScan();
@@ -407,7 +367,7 @@ void NetworkStateHandler::SetCheckPortalList(
shill_property_handler_->SetCheckPortalList(check_portal_list);
}
-const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
+const NetworkState* NetworkStateHandler::GetEAPForEthernet(
const std::string& service_path) const {
const NetworkState* network = GetNetworkState(service_path);
if (!network) {
@@ -436,12 +396,12 @@ const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
if (!device->eap_authentication_completed())
return NULL;
- FavoriteStateList list;
- GetFavoriteListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap),
- true /* configured_only */,
- false /* visible_only */,
- 1 /* limit */,
- &list);
+ NetworkStateList list;
+ GetNetworkListByType(NetworkTypePattern::Primitive(shill::kTypeEthernetEap),
+ true /* configured_only */,
+ false /* visible_only */,
+ 1 /* limit */,
+ &list);
if (list.empty()) {
NET_LOG_ERROR("GetEAPForEthernet",
base::StringPrintf(
@@ -459,11 +419,12 @@ const FavoriteState* NetworkStateHandler::GetEAPForEthernet(
void NetworkStateHandler::UpdateManagedList(ManagedState::ManagedType type,
const base::ListValue& entries) {
ManagedStateList* managed_list = GetManagedList(type);
- NET_LOG_DEBUG(base::StringPrintf("UpdateManagedList:%d", type),
+ NET_LOG_DEBUG("UpdateManagedList: " + ManagedState::TypeToString(type),
base::StringPrintf("%" PRIuS, entries.GetSize()));
// Create a map of existing entries. Assumes all entries in |managed_list|
// are unique.
- std::map<std::string, ManagedState*> managed_map;
+ typedef std::map<std::string, ManagedState*> ManagedMap;
+ ManagedMap managed_map;
for (ManagedStateList::iterator iter = managed_list->begin();
iter != managed_list->end(); ++iter) {
ManagedState* managed = *iter;
@@ -482,19 +443,16 @@ void NetworkStateHandler::UpdateManagedList(ManagedState::ManagedType type,
NET_LOG_ERROR(base::StringPrintf("Bad path in list:%d", type), path);
continue;
}
- std::map<std::string, ManagedState*>::iterator found =
- managed_map.find(path);
- ManagedState* managed;
+ ManagedMap::iterator found = managed_map.find(path);
if (found == managed_map.end()) {
if (list_entries.count(path) != 0) {
NET_LOG_ERROR("Duplicate entry in list", path);
continue;
}
- managed = ManagedState::Create(type, path);
+ ManagedState* managed = ManagedState::Create(type, path);
managed_list->push_back(managed);
} else {
- managed = found->second;
- managed_list->push_back(managed);
+ managed_list->push_back(found->second);
managed_map.erase(found);
}
list_entries.insert(path);
@@ -503,12 +461,42 @@ void NetworkStateHandler::UpdateManagedList(ManagedState::ManagedType type,
STLDeleteContainerPairSecondPointers(managed_map.begin(), managed_map.end());
}
+void NetworkStateHandler::UpdateVisibleNetworks(
+ const base::ListValue& entries) {
+ NET_LOG_DEBUG(base::StringPrintf("UpdateVisibleNetworks"),
+ base::StringPrintf("%" PRIuS, entries.GetSize()));
+ // Create a map of all networks and clear the visible state.
+ ManagedStateList* network_list =
+ GetManagedList(ManagedState::MANAGED_TYPE_NETWORK);
+ typedef std::map<std::string, NetworkState*> NetworkMap;
+ NetworkMap network_map;
+ for (ManagedStateList::iterator iter = network_list->begin();
+ iter != network_list->end(); ++iter) {
+ NetworkState* network = (*iter)->AsNetworkState();
+ network_map[network->path()] = network;
+ network->set_visible(false);
+ }
+ // Look up each entry and set the associated network to visible.
+ for (base::ListValue::const_iterator iter = entries.begin();
+ iter != entries.end(); ++iter) {
+ std::string path;
+ (*iter)->GetAsString(&path);
+ NetworkMap::iterator found = network_map.find(path);
+ if (found != network_map.end())
+ found->second->set_visible(true);
+ else
+ NET_LOG_DEBUG("Visible network not in list", path);
+ }
+}
+
void NetworkStateHandler::ProfileListChanged() {
NET_LOG_EVENT("ProfileListChanged", "Re-Requesting Network Properties");
- for (ManagedStateList::iterator iter = favorite_list_.begin();
- iter != favorite_list_.end(); ++iter) {
+ for (ManagedStateList::iterator iter = network_list_.begin();
+ iter != network_list_.end(); ++iter) {
+ NetworkState* network = (*iter)->AsNetworkState();
+ DCHECK(network);
shill_property_handler_->RequestProperties(
- ManagedState::MANAGED_TYPE_NETWORK, (*iter)->path());
+ ManagedState::MANAGED_TYPE_NETWORK, network->path());
}
}
@@ -519,33 +507,25 @@ void NetworkStateHandler::UpdateManagedStateProperties(
ManagedStateList* managed_list = GetManagedList(type);
ManagedState* managed = GetModifiableManagedState(managed_list, path);
if (!managed) {
- if (type != ManagedState::MANAGED_TYPE_FAVORITE) {
- // The network has been removed from the list of visible networks.
- NET_LOG_DEBUG("UpdateManagedStateProperties: Not found", path);
- return;
- }
- // 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 = ManagedState::Create(type, path);
- managed_list->push_back(managed);
+ // The network has been removed from the list of networks.
+ NET_LOG_DEBUG("UpdateManagedStateProperties: Not found", path);
+ return;
}
managed->set_update_received();
std::string desc = GetManagedStateLogType(managed) + " Properties Received";
- NET_LOG_DEBUG(desc, GetManagedStateLogName(managed));
+ NET_LOG_DEBUG(desc, GetLogName(managed));
if (type == ManagedState::MANAGED_TYPE_NETWORK) {
UpdateNetworkStateProperties(managed->AsNetworkState(), properties);
} else {
- // Device, Favorite
+ // Device
for (base::DictionaryValue::Iterator iter(properties);
!iter.IsAtEnd(); iter.Advance()) {
managed->PropertyChanged(iter.key(), iter.value());
}
managed->InitialPropertiesReceived(properties);
}
- UpdateGuid(managed);
managed->set_update_requested(false);
}
@@ -566,23 +546,17 @@ void NetworkStateHandler::UpdateNetworkStateProperties(
// Signal connection state changed after all properties have been updated.
if (ConnectionStateChanged(network, prev_connection_state))
OnNetworkConnectionStateChanged(network);
- NET_LOG_EVENT("NetworkPropertiesUpdated", GetManagedStateLogName(network));
+ NET_LOG_EVENT("NetworkPropertiesUpdated", GetLogName(network));
NotifyNetworkPropertiesUpdated(network);
}
+ UpdateGuid(network);
}
void NetworkStateHandler::UpdateNetworkServiceProperty(
const std::string& service_path,
const std::string& key,
const base::Value& value) {
- // Update any associated FavoriteState.
- ManagedState* favorite =
- GetModifiableManagedState(&favorite_list_, service_path);
bool changed = false;
- if (favorite)
- changed |= favorite->PropertyChanged(key, value);
-
- // Update the NetworkState.
NetworkState* network = GetModifiableNetworkState(service_path);
if (!network)
return;
@@ -631,7 +605,7 @@ void NetworkStateHandler::UpdateNetworkServiceProperty(
// All property updates signal 'NetworkPropertiesUpdated'.
NotifyNetworkPropertiesUpdated(network);
- // If added to a Profile, request a full update so that a FavoriteState
+ // If added to a Profile, request a full update so that a NetworkState
// gets created.
if (prev_profile_path.empty() && !network->profile_path().empty())
RequestUpdateForNetwork(service_path);
@@ -657,7 +631,11 @@ void NetworkStateHandler::UpdateDeviceProperty(const std::string& device_path,
if (key == shill::kEapAuthenticationCompletedProperty) {
// Notify a change for each Ethernet service using this device.
NetworkStateList ethernet_services;
- GetNetworkListByType(NetworkTypePattern::Ethernet(), &ethernet_services);
+ GetNetworkListByType(NetworkTypePattern::Ethernet(),
+ false /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &ethernet_services);
for (NetworkStateList::const_iterator it = ethernet_services.begin();
it != ethernet_services.end(); ++it) {
const NetworkState* ethernet_service = *it;
@@ -703,30 +681,25 @@ void NetworkStateHandler::ManagedStateListChanged(
ManagedState::ManagedType type) {
if (type == ManagedState::MANAGED_TYPE_NETWORK) {
// Notify observers that the list of networks has changed.
- NET_LOG_EVENT("NetworkListChanged",
+ NET_LOG_EVENT("NOTIFY:NetworkListChanged",
base::StringPrintf("Size:%" PRIuS, network_list_.size()));
FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
NetworkListChanged());
// Update UMA stats.
- UMA_HISTOGRAM_COUNTS_100("Networks.Visible", network_list_.size());
- } else if (type == ManagedState::MANAGED_TYPE_FAVORITE) {
- NET_LOG_DEBUG("FavoriteListChanged",
- base::StringPrintf("Size:%" PRIuS, favorite_list_.size()));
- // The FavoriteState list only changes when the NetworkState list changes,
- // so no need to signal observers here again.
-
- // Update UMA stats.
- size_t shared = 0, unshared = 0;
- for (ManagedStateList::iterator iter = favorite_list_.begin();
- iter != favorite_list_.end(); ++iter) {
- FavoriteState* favorite = (*iter)->AsFavoriteState();
- if (!favorite->IsInProfile())
- continue;
- if (favorite->IsPrivate())
- ++unshared;
- else
- ++shared;
+ size_t shared = 0, unshared = 0, visible = 0;
+ for (ManagedStateList::iterator iter = network_list_.begin();
+ iter != network_list_.end(); ++iter) {
+ NetworkState* network = (*iter)->AsNetworkState();
+ if (network->visible())
+ ++visible;
+ if (network->IsInProfile()) {
+ if (network->IsPrivate())
+ ++unshared;
+ else
+ ++shared;
+ }
}
+ UMA_HISTOGRAM_COUNTS_100("Networks.Visible", visible);
UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared);
UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared);
} else if (type == ManagedState::MANAGED_TYPE_DEVICE) {
@@ -737,7 +710,7 @@ void NetworkStateHandler::ManagedStateListChanged(
devices += ", ";
devices += (*iter)->name();
}
- NET_LOG_EVENT("DeviceList:", devices);
+ NET_LOG_EVENT("DeviceList", devices);
NotifyDeviceListChanged();
} else {
NOTREACHED();
@@ -748,10 +721,12 @@ void NetworkStateHandler::DefaultNetworkServiceChanged(
const std::string& service_path) {
// Shill uses '/' for empty service path values; check explicitly for that.
const char* kEmptyServicePath = "/";
- if (service_path == kEmptyServicePath)
- default_network_path_.clear();
- else
- default_network_path_ = service_path;
+ std::string new_service_path =
+ (service_path != kEmptyServicePath) ? service_path : "";
+ if (new_service_path == default_network_path_)
+ return;
+
+ default_network_path_ = service_path;
NET_LOG_EVENT("DefaultNetworkServiceChanged:", default_network_path_);
const NetworkState* network = NULL;
if (!default_network_path_.empty()) {
@@ -775,51 +750,34 @@ void NetworkStateHandler::DefaultNetworkServiceChanged(
//------------------------------------------------------------------------------
// Private methods
-void NetworkStateHandler::UpdateGuid(ManagedState* managed) {
- if (managed->managed_type() == ManagedState::MANAGED_TYPE_FAVORITE) {
- FavoriteState* favorite = managed->AsFavoriteState();
- std::string specifier = favorite->GetSpecifier();
- if (!favorite->guid().empty()) {
- // If the favorite is saved in a profile, remove the entry from the map.
- // Otherwise ensure that the entry matches the specified GUID.
- if (favorite->IsInProfile())
- specifier_guid_map_.erase(specifier);
- else
- specifier_guid_map_[specifier] = favorite->guid();
- return;
- }
- // Ensure that the FavoriteState has a valid GUID.
- 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;
- // ShillPropertyHandler will always call UpdateManagedStateProperties with
- // type FAVORITE before type NETWORK, so there should always be a
- // corresponding FavoriteState here.
- FavoriteState* favorite = GetModifiableFavoriteState(network->path());
- DCHECK(favorite);
- if (favorite && !favorite->guid().empty())
- network->SetGuid(favorite->guid());
+void NetworkStateHandler::UpdateGuid(NetworkState* network) {
+ std::string specifier = network->GetSpecifier();
+ DCHECK(!specifier.empty());
+ if (!network->guid().empty()) {
+ // If the network is saved in a profile, remove the entry from the map.
+ // Otherwise ensure that the entry matches the specified GUID. (e.g. in
+ // case a visible network with a specified guid gets configured with a
+ // new guid).
+ if (network->IsInProfile())
+ specifier_guid_map_.erase(specifier);
+ else
+ specifier_guid_map_[specifier] = network->guid();
+ return;
+ }
+ // Ensure that the NetworkState has a valid GUID.
+ 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;
}
+ network->SetGuid(guid);
}
void NetworkStateHandler::NotifyDeviceListChanged() {
- NET_LOG_DEBUG("NotifyDeviceListChanged",
+ NET_LOG_DEBUG("NOTIFY:DeviceListChanged",
base::StringPrintf("Size:%" PRIuS, device_list_.size()));
FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
DeviceListChanged());
@@ -842,15 +800,6 @@ 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 {
@@ -868,8 +817,6 @@ NetworkStateHandler::ManagedStateList* NetworkStateHandler::GetManagedList(
switch (type) {
case ManagedState::MANAGED_TYPE_NETWORK:
return &network_list_;
- case ManagedState::MANAGED_TYPE_FAVORITE:
- return &favorite_list_;
case ManagedState::MANAGED_TYPE_DEVICE:
return &device_list_;
}
@@ -889,8 +836,8 @@ void NetworkStateHandler::OnNetworkConnectionStateChanged(
network->path());
}
}
- NET_LOG_EVENT(event + ": " + network->connection_state(),
- GetManagedStateLogName(network));
+ NET_LOG_EVENT("NOTIFY:" + event + ": " + network->connection_state(),
+ GetLogName(network));
FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
NetworkConnectionStateChanged(network));
if (network->path() == default_network_path_)
@@ -899,12 +846,14 @@ void NetworkStateHandler::OnNetworkConnectionStateChanged(
void NetworkStateHandler::NotifyDefaultNetworkChanged(
const NetworkState* default_network) {
+ NET_LOG_EVENT("NOTIFY:DefaultNetworkChanged", GetLogName(default_network));
FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
DefaultNetworkChanged(default_network));
}
void NetworkStateHandler::NotifyNetworkPropertiesUpdated(
const NetworkState* network) {
+ NET_LOG_DEBUG("NOTIFY:NetworkPropertiesUpdated", GetLogName(network));
FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
NetworkPropertiesUpdated(network));
}
diff --git a/chromeos/network/network_state_handler.h b/chromeos/network/network_state_handler.h
index 538b4743..2d2914b 100644
--- a/chromeos/network/network_state_handler.h
+++ b/chromeos/network/network_state_handler.h
@@ -50,20 +50,17 @@ class NetworkStateHandlerTest;
// It will invoke its own more specific observer methods when the specified
// changes occur.
//
-// Some notes about NetworkState, FavoriteState, and GUIDs:
-// * A FavoriteState exists for all network services stored in a profile, and
+// Some notes about NetworkState and GUIDs:
+// * A NetworkState exists for all network services stored in a profile, and
// all "visible" networks (physically connected networks like ethernet and
// cellular or in-range wifi networks). If the network is stored in a profile,
-// FavoriteState.IsInProfile() will return true.
-// * A NetworkState exists for "visible" networks only. There will always be a
-// corresponding FavoriteState with the same service_path() property.
+// NetworkState.IsInProfile() will return true.
+// * "Visible" networks return true for NetworkState.visible().
// * All networks saved to a profile will have a saved GUID that is persistent
// across sessions.
// * Networks that are not saved to a profile will have a GUID assigned when
// the initial properties are received. The GUID will be consistent for
// the duration of a session, even if the network drops out and returns.
-// * Both FavoriteState and NetworkState store the GUID. It will always be the
-// same for the same network (i.e. entries with the same service_path()).
class CHROMEOS_EXPORT NetworkStateHandler
: public internal::ShillPropertyHandler::Listener {
@@ -71,7 +68,6 @@ class CHROMEOS_EXPORT NetworkStateHandler
typedef std::vector<ManagedState*> ManagedStateList;
typedef std::vector<const NetworkState*> NetworkStateList;
typedef std::vector<const DeviceState*> DeviceStateList;
- typedef std::vector<const FavoriteState*> FavoriteStateList;
enum TechnologyState {
TECHNOLOGY_UNAVAILABLE,
@@ -89,11 +85,6 @@ class CHROMEOS_EXPORT NetworkStateHandler
void RemoveObserver(NetworkStateHandlerObserver* observer,
const tracked_objects::Location& from_here);
- // Requests all Manager properties, specifically to update the complete
- // list of services which determines the list of Favorites. This should be
- // called any time a new service is configured or a Profile is loaded.
- void UpdateManagerProperties();
-
// Returns the state for technology |type|. Only
// NetworkTypePattern::Primitive, ::Mobile and ::Ethernet are supported.
TechnologyState GetTechnologyState(const NetworkTypePattern& type) const;
@@ -134,10 +125,6 @@ class CHROMEOS_EXPORT NetworkStateHandler
// differ.
const NetworkState* DefaultNetwork() const;
- // Returns the FavoriteState associated to DefaultNetwork. Returns NULL if,
- // and only if, DefaultNetwork returns NULL.
- const FavoriteState* DefaultFavoriteNetwork() const;
-
// Returns the primary connected network of matching |type|, otherwise NULL.
const NetworkState* ConnectedNetworkByType(
const NetworkTypePattern& type) const;
@@ -146,8 +133,8 @@ class CHROMEOS_EXPORT NetworkStateHandler
const NetworkState* ConnectingNetworkByType(
const NetworkTypePattern& type) const;
- // Like ConnectedNetworkByType() but returns any matching network or NULL.
- // Mostly useful for mobile networks where there is generally only one
+ // Like ConnectedNetworkByType() but returns any matching visible network or
+ // NULL. Mostly useful for mobile networks where there is generally only one
// network. Note: O(N).
const NetworkState* FirstNetworkByType(const NetworkTypePattern& type) const;
@@ -156,16 +143,38 @@ class CHROMEOS_EXPORT NetworkStateHandler
std::string FormattedHardwareAddressForType(
const NetworkTypePattern& type) const;
- // Sets |list| to contain the list of networks. The returned list contains
- // a copy of NetworkState pointers which should not be stored or used beyond
- // the scope of the calling function (i.e. they may later become invalid, but
- // only on the UI thread).
- void GetNetworkList(NetworkStateList* list) const;
+ // Convenience method to call GetNetworkListByType(visible=true).
+ void GetVisibleNetworkListByType(const NetworkTypePattern& type,
+ NetworkStateList* list) const;
- // Like GetNetworkList() but only returns networks with matching |type|.
+ // Convenience method for GetVisibleNetworkListByType(Default).
+ void GetVisibleNetworkList(NetworkStateList* list) const;
+
+ // Sets |list| to contain the list of networks with matching |type| and the
+ // following properties:
+ // |configured_only| - if true only include networks where IsInProfile is true
+ // |visible_only| - if true only include networks in the visible Services list
+ // |limit| - if > 0 limits the number of results.
+ // The returned list contains a copy of NetworkState pointers which should not
+ // be stored or used beyond the scope of the calling function (i.e. they may
+ // later become invalid, but only on the UI thread).
void GetNetworkListByType(const NetworkTypePattern& type,
+ bool configured_only,
+ bool visible_only,
+ int limit,
NetworkStateList* list) const;
+ // Finds and returns the NetworkState associated with |service_path| or NULL
+ // if not found. If |configured_only| is true, only returns saved entries
+ // (IsInProfile is true).
+ const NetworkState* GetNetworkStateFromServicePath(
+ const std::string& service_path,
+ bool configured_only) const;
+
+ // Finds and returns the NetworkState associated with |guid| or NULL if not
+ // found. This returns all entries (IsInProfile() may be true or false).
+ const NetworkState* GetNetworkStateFromGuid(const std::string& guid) const;
+
// Sets |list| to contain the list of devices. The returned list contains
// a copy of DeviceState pointers which should not be stored or used beyond
// the scope of the calling function (i.e. they may later become invalid, but
@@ -176,35 +185,6 @@ class CHROMEOS_EXPORT NetworkStateHandler
void GetDeviceListByType(const NetworkTypePattern& type,
DeviceStateList* list) const;
- // Sets |list| to contain the list of favorite (aka "preferred") networks.
- // See GetNetworkList() for usage, and notes for |favorite_list_|.
- // Favorites that are visible have the same path() as the entries in
- // GetNetworkList(), so GetNetworkState() can be used to determine if a
- // favorite is visible and retrieve the complete properties (and vice-versa).
- void GetFavoriteList(FavoriteStateList* list) const;
-
- // Like GetFavoriteList() but only returns favorites with matching |type| and
- // the following properties:
- // |configured_only| - if true only include networks where IsInProfile is true
- // |visible_only| - if true only include networks in the visible Services list
- // |limit| - if > 0 limits the number of results.
- void GetFavoriteListByType(const NetworkTypePattern& type,
- bool configured_only,
- bool visible_only,
- int limit,
- FavoriteStateList* list) const;
-
- // Finds and returns the FavoriteState associated with |service_path| or NULL
- // if not found. If |configured_only| is true, only returns saved entries
- // (IsInProfile is true).
- const FavoriteState* GetFavoriteStateFromServicePath(
- const std::string& service_path,
- bool configured_only) const;
-
- // Finds and returns the FavoriteState associated with |guid| or NULL if not
- // found. This returns all entries (IsInProfile() may be true or false).
- const FavoriteState* GetFavoriteStateFromGuid(const std::string& guid) const;
-
// Requests a network scan. This may trigger updates to the network
// list, which will trigger the appropriate observer calls.
void RequestScan() const;
@@ -236,11 +216,11 @@ class CHROMEOS_EXPORT NetworkStateHandler
return check_portal_list_;
}
- // Returns the FavoriteState of the EthernetEAP service, which contains the
+ // Returns the NetworkState of the EthernetEAP service, which contains the
// EAP parameters used by the ethernet with |service_path|. If |service_path|
// doesn't refer to an ethernet service or if the ethernet service is not
// connected using EAP, returns NULL.
- const FavoriteState* GetEAPForEthernet(const std::string& service_path) const;
+ const NetworkState* GetEAPForEthernet(const std::string& service_path) const;
const std::string& default_network_path() const {
return default_network_path_;
@@ -259,11 +239,16 @@ class CHROMEOS_EXPORT NetworkStateHandler
// ShillPropertyHandler::Listener overrides.
- // This adds new entries to the managed list specified by |type| and deletes
- // any entries that are no longer in the list.
+ // This adds new entries to |network_list_| or |device_list_| and deletes any
+ // entries that are no longer in the list.
virtual void UpdateManagedList(ManagedState::ManagedType type,
const base::ListValue& entries) OVERRIDE;
+ // Updates the visibility of entries in |network_list_|. This should not
+ // contain entries that are not in |network_list_|. Any such entries will be
+ // ignored with an error message.
+ virtual void UpdateVisibleNetworks(const base::ListValue& entries) OVERRIDE;
+
// The list of profiles changed (i.e. a user has logged in). Re-request
// properties for all services since they may have changed.
virtual void ProfileListChanged() OVERRIDE;
@@ -331,9 +316,8 @@ class CHROMEOS_EXPORT NetworkStateHandler
void UpdateNetworkStateProperties(NetworkState* network,
const base::DictionaryValue& properties);
- // Ensure a valid GUID for FavoriteState and update the NetworkState GUID from
- // the corresponding FavoriteState if necessary.
- void UpdateGuid(ManagedState* managed);
+ // Ensure a valid GUID for NetworkState.
+ void UpdateGuid(NetworkState* network);
// Sends DeviceListChanged() to observers and logs an event.
void NotifyDeviceListChanged();
@@ -344,8 +328,6 @@ class CHROMEOS_EXPORT NetworkStateHandler
DeviceState* GetModifiableDeviceState(const std::string& device_path) const;
NetworkState* GetModifiableNetworkState(
const std::string& service_path) const;
- FavoriteState* GetModifiableFavoriteState(
- const std::string& service_path) const;
ManagedState* GetModifiableManagedState(const ManagedStateList* managed_list,
const std::string& path) const;
@@ -381,11 +363,6 @@ class CHROMEOS_EXPORT NetworkStateHandler
// List of managed network states
ManagedStateList network_list_;
- // List of managed favorite states; this list includes all entries in
- // Manager.ServiceCompleteList, but only entries with a non-empty Profile
- // property are returned in GetFavoriteList().
- ManagedStateList favorite_list_;
-
// List of managed device states
ManagedStateList device_list_;
@@ -399,7 +376,7 @@ class CHROMEOS_EXPORT NetworkStateHandler
ScanCompleteCallbackMap scan_complete_callbacks_;
// Map of network specifiers to guids. Contains an entry for each
- // FavoriteState that is not saved in a profile.
+ // NetworkState that is not saved in a profile.
SpecifierGuidMap specifier_guid_map_;
DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler);
diff --git a/chromeos/network/network_state_handler_unittest.cc b/chromeos/network/network_state_handler_unittest.cc
index 3f95116..a3a3e92 100644
--- a/chromeos/network/network_state_handler_unittest.cc
+++ b/chromeos/network/network_state_handler_unittest.cc
@@ -17,8 +17,8 @@
#include "chromeos/dbus/shill_manager_client.h"
#include "chromeos/dbus/shill_profile_client.h"
#include "chromeos/dbus/shill_service_client.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_state.h"
+#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_state_handler_observer.h"
#include "dbus/object_path.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -46,8 +46,7 @@ class TestObserver : public chromeos::NetworkStateHandlerObserver {
device_list_changed_count_(0),
device_count_(0),
network_count_(0),
- default_network_change_count_(0),
- favorite_count_(0) {
+ default_network_change_count_(0) {
}
virtual ~TestObserver() {
@@ -62,15 +61,16 @@ class TestObserver : public chromeos::NetworkStateHandlerObserver {
virtual void NetworkListChanged() OVERRIDE {
NetworkStateHandler::NetworkStateList networks;
- handler_->GetNetworkList(&networks);
+ handler_->GetNetworkListByType(chromeos::NetworkTypePattern::Default(),
+ false /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &networks);
network_count_ = networks.size();
if (network_count_ == 0) {
default_network_ = "";
default_network_connection_state_ = "";
}
- NetworkStateHandler::FavoriteStateList favorites;
- handler_->GetFavoriteList(&favorites);
- favorite_count_ = favorites.size();
}
virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE {
@@ -108,7 +108,6 @@ class TestObserver : public chromeos::NetworkStateHandlerObserver {
std::string default_network_connection_state() {
return default_network_connection_state_;
}
- size_t favorite_count() { return favorite_count_; }
int PropertyUpdatesForService(const std::string& service_path) {
return property_updates_[service_path];
@@ -131,7 +130,6 @@ class TestObserver : public chromeos::NetworkStateHandlerObserver {
size_t default_network_change_count_;
std::string default_network_;
std::string default_network_connection_state_;
- size_t favorite_count_;
std::map<std::string, int> property_updates_;
std::map<std::string, int> connection_state_changes_;
std::map<std::string, std::string> network_connection_state_;
@@ -225,8 +223,6 @@ class NetworkStateHandlerTest : public testing::Test {
void UpdateManagerProperties() {
message_loop_.RunUntilIdle();
- network_state_handler_->UpdateManagerProperties();
- message_loop_.RunUntilIdle();
}
base::MessageLoopForUI message_loop_;
@@ -272,6 +268,94 @@ TEST_F(NetworkStateHandlerTest, NetworkStateHandlerStub) {
test_observer_->default_network_connection_state());
}
+TEST_F(NetworkStateHandlerTest, GetNetworkList) {
+ // Ensure that the network list is the expected size.
+ const size_t kNumShillManagerClientStubImplServices = 4;
+ EXPECT_EQ(kNumShillManagerClientStubImplServices,
+ test_observer_->network_count());
+ // Add a non-visible network to the profile.
+ const std::string profile = "/profile/profile1";
+ const std::string wifi_favorite_path = "/service/wifi_faviorite";
+ service_test_->AddService(wifi_favorite_path, "wifi_faviorite",
+ shill::kTypeWifi, shill::kStateIdle,
+ false /* add_to_visible */);
+ profile_test_->AddProfile(profile, "" /* userhash */);
+ EXPECT_TRUE(profile_test_->AddService(profile, wifi_favorite_path));
+ UpdateManagerProperties();
+ message_loop_.RunUntilIdle();
+ EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
+ test_observer_->network_count());
+
+ // Get all networks.
+ NetworkStateHandler::NetworkStateList networks;
+ network_state_handler_->GetNetworkListByType(NetworkTypePattern::Default(),
+ false /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &networks);
+ EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, networks.size());
+ // Limit number of results.
+ network_state_handler_->GetNetworkListByType(NetworkTypePattern::Default(),
+ false /* configured_only */,
+ false /* visible_only */,
+ 2 /* limit */,
+ &networks);
+ EXPECT_EQ(2u, networks.size());
+ // Get all wifi networks.
+ network_state_handler_->GetNetworkListByType(NetworkTypePattern::WiFi(),
+ false /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &networks);
+ EXPECT_EQ(3u, networks.size());
+ // Get visible networks.
+ network_state_handler_->GetNetworkListByType(NetworkTypePattern::Default(),
+ false /* configured_only */,
+ true /* visible_only */,
+ 0 /* no limit */,
+ &networks);
+ EXPECT_EQ(kNumShillManagerClientStubImplServices, networks.size());
+ network_state_handler_->GetVisibleNetworkList(&networks);
+ EXPECT_EQ(kNumShillManagerClientStubImplServices, networks.size());
+ // Get configured (profile) networks.
+ network_state_handler_->GetNetworkListByType(NetworkTypePattern::Default(),
+ true /* configured_only */,
+ false /* visible_only */,
+ 0 /* no limit */,
+ &networks);
+ EXPECT_EQ(1u, networks.size());
+}
+
+TEST_F(NetworkStateHandlerTest, GetVisibleNetworks) {
+ // Ensure that the network list is the expected size.
+ const size_t kNumShillManagerClientStubImplServices = 4;
+ EXPECT_EQ(kNumShillManagerClientStubImplServices,
+ test_observer_->network_count());
+ // Add a non-visible network to the profile.
+ const std::string profile = "/profile/profile1";
+ const std::string wifi_favorite_path = "/service/wifi_faviorite";
+ service_test_->AddService(wifi_favorite_path, "wifi_faviorite",
+ shill::kTypeWifi, shill::kStateIdle,
+ false /* add_to_visible */);
+ message_loop_.RunUntilIdle();
+ EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
+ test_observer_->network_count());
+
+ // Get visible networks.
+ NetworkStateHandler::NetworkStateList networks;
+ network_state_handler_->GetVisibleNetworkList(&networks);
+ EXPECT_EQ(kNumShillManagerClientStubImplServices, networks.size());
+
+ // Change the visible state of a network.
+ DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
+ dbus::ObjectPath(kShillManagerClientStubWifi2),
+ shill::kVisibleProperty, base::FundamentalValue(false),
+ base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
+ message_loop_.RunUntilIdle();
+ network_state_handler_->GetVisibleNetworkList(&networks);
+ EXPECT_EQ(kNumShillManagerClientStubImplServices - 1, networks.size());
+}
+
TEST_F(NetworkStateHandlerTest, TechnologyChanged) {
// Disable a technology. Will immediately set the state to AVAILABLE and
// notify observers.
@@ -379,24 +463,17 @@ TEST_F(NetworkStateHandlerTest, GetState) {
EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
UpdateManagerProperties();
- // Ensure that a NetworkState and corresponding FavoriteState exist.
+ // Ensure that a NetworkState exists.
const NetworkState* wifi_network =
- network_state_handler_->GetNetworkState(wifi_path);
- ASSERT_TRUE(wifi_network);
- const FavoriteState* wifi_favorite =
- network_state_handler_->GetFavoriteStateFromServicePath(
+ network_state_handler_->GetNetworkStateFromServicePath(
wifi_path, true /* configured_only */);
- ASSERT_TRUE(wifi_favorite);
- EXPECT_EQ(wifi_network->path(), wifi_favorite->path());
-
- // Ensure that we are notified that a Favorite was added.
- EXPECT_EQ(1u, test_observer_->favorite_count());
+ ASSERT_TRUE(wifi_network);
// Test looking up by GUID.
- ASSERT_FALSE(wifi_favorite->guid().empty());
- const FavoriteState* wifi_favorite_guid =
- network_state_handler_->GetFavoriteStateFromGuid(wifi_favorite->guid());
- EXPECT_EQ(wifi_favorite, wifi_favorite_guid);
+ ASSERT_FALSE(wifi_network->guid().empty());
+ const NetworkState* wifi_network_guid =
+ network_state_handler_->GetNetworkStateFromGuid(wifi_network->guid());
+ EXPECT_EQ(wifi_network, wifi_network_guid);
// Remove the service, verify that there is no longer a NetworkState for it.
service_test_->RemoveService(wifi_path);
@@ -426,6 +503,7 @@ TEST_F(NetworkStateHandlerTest, DefaultServiceDisconnected) {
const std::string eth1 = kShillManagerClientStubDefaultService;
const std::string wifi1 = kShillManagerClientStubDefaultWifi;
+ EXPECT_EQ(0u, test_observer_->default_network_change_count());
// Disconnect ethernet.
base::StringValue connection_state_idle_value(shill::kStateIdle);
service_test_->SetServiceProperty(eth1, shill::kStateProperty,
@@ -544,16 +622,10 @@ TEST_F(NetworkStateHandlerTest, NetworkGuidInProfile) {
EXPECT_TRUE(profile_test_->AddService(profile, wifi_path));
UpdateManagerProperties();
- // Verify that a FavoriteState exists with a matching GUID.
- const FavoriteState* favorite =
- network_state_handler_->GetFavoriteStateFromServicePath(
- wifi_path, is_service_configured);
- ASSERT_TRUE(favorite);
- EXPECT_EQ(wifi_guid, favorite->guid());
-
- // Verify that a NetworkState exists with the same GUID.
+ // Verify that a NetworkState exists with a matching GUID.
const NetworkState* network =
- network_state_handler_->GetNetworkState(wifi_path);
+ network_state_handler_->GetNetworkStateFromServicePath(
+ wifi_path, is_service_configured);
ASSERT_TRUE(network);
EXPECT_EQ(wifi_guid, network->guid());
@@ -566,15 +638,10 @@ TEST_F(NetworkStateHandlerTest, NetworkGuidInProfile) {
// the NetworkState was created with the same GUID.
AddService(wifi_path, wifi_path, shill::kTypeWifi, shill::kStateOnline);
UpdateManagerProperties();
- network = network_state_handler_->GetNetworkState(wifi_path);
+ network = network_state_handler_->GetNetworkStateFromServicePath(
+ wifi_path, is_service_configured);
ASSERT_TRUE(network);
EXPECT_EQ(wifi_guid, network->guid());
-
- // Also verify FavoriteState (mostly to test the stub behavior).
- favorite = network_state_handler_->GetFavoriteStateFromServicePath(
- wifi_path, is_service_configured);
- ASSERT_TRUE(favorite);
- EXPECT_EQ(wifi_guid, favorite->guid());
}
TEST_F(NetworkStateHandlerTest, NetworkGuidNotInProfile) {
@@ -585,19 +652,13 @@ TEST_F(NetworkStateHandlerTest, NetworkGuidNotInProfile) {
AddService(wifi_path, wifi_path, shill::kTypeWifi, shill::kStateOnline);
UpdateManagerProperties();
- // Verify that a FavoriteState exists with an assigned GUID.
- const FavoriteState* favorite =
- network_state_handler_->GetFavoriteStateFromServicePath(
- wifi_path, is_service_configured);
- ASSERT_TRUE(favorite);
- std::string wifi_guid = favorite->guid();
- EXPECT_FALSE(wifi_guid.empty());
-
- // Verify that a NetworkState exists with the same GUID.
+ // Verify that a NetworkState exists with an assigned GUID.
const NetworkState* network =
- network_state_handler_->GetNetworkState(wifi_path);
+ network_state_handler_->GetNetworkStateFromServicePath(
+ wifi_path, is_service_configured);
ASSERT_TRUE(network);
- EXPECT_EQ(wifi_guid, network->guid());
+ std::string wifi_guid = network->guid();
+ EXPECT_FALSE(wifi_guid.empty());
// Remove the service (simulating a network going out of range).
service_test_->RemoveService(wifi_path);
@@ -608,15 +669,10 @@ TEST_F(NetworkStateHandlerTest, NetworkGuidNotInProfile) {
// the NetworkState was created with the same GUID.
AddService(wifi_path, wifi_path, shill::kTypeWifi, shill::kStateOnline);
UpdateManagerProperties();
- network = network_state_handler_->GetNetworkState(wifi_path);
+ network = network_state_handler_->GetNetworkStateFromServicePath(
+ wifi_path, is_service_configured);
ASSERT_TRUE(network);
EXPECT_EQ(wifi_guid, network->guid());
-
- // Also verify FavoriteState (mostly to test the stub behavior).
- favorite = network_state_handler_->GetFavoriteStateFromServicePath(
- wifi_path, is_service_configured);
- ASSERT_TRUE(favorite);
- EXPECT_EQ(wifi_guid, favorite->guid());
}
} // namespace chromeos
diff --git a/chromeos/network/network_util.cc b/chromeos/network/network_util.cc
index 3426cad..377167f 100644
--- a/chromeos/network/network_util.cc
+++ b/chromeos/network/network_util.cc
@@ -7,7 +7,6 @@
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/onc/onc_signature.h"
@@ -140,21 +139,11 @@ bool ParseCellularScanResults(const base::ListValue& list,
return true;
}
-scoped_ptr<base::DictionaryValue> TranslateFavoriteStateToONC(
- const FavoriteState* favorite) {
- // Get the properties from the FavoriteState.
+scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
+ const NetworkState* network) {
+ // Get the properties from the NetworkState.
base::DictionaryValue shill_dictionary;
- favorite->GetStateProperties(&shill_dictionary);
-
- // If a corresponding NetworkState exists, merge its State properties.
- const NetworkState* network_state =
- NetworkHandler::Get()->network_state_handler()->GetNetworkState(
- favorite->path());
- if (network_state) {
- base::DictionaryValue shill_network_dictionary;
- network_state->GetStateProperties(&shill_network_dictionary);
- shill_dictionary.MergeDictionary(&shill_network_dictionary);
- }
+ network->GetStateProperties(&shill_dictionary);
scoped_ptr<base::DictionaryValue> onc_dictionary =
TranslateShillServiceToONCPart(
@@ -168,19 +157,20 @@ scoped_ptr<base::ListValue> TranslateNetworkListToONC(
bool visible_only,
int limit,
bool debugging_properties) {
- NetworkStateHandler::FavoriteStateList favorite_states;
- NetworkHandler::Get()->network_state_handler()->GetFavoriteListByType(
- pattern, configured_only, visible_only, limit, &favorite_states);
+ NetworkStateHandler::NetworkStateList network_states;
+ NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
+ pattern, configured_only, visible_only, limit, &network_states);
scoped_ptr<base::ListValue> network_properties_list(new base::ListValue);
- for (NetworkStateHandler::FavoriteStateList::iterator it =
- favorite_states.begin();
- it != favorite_states.end();
+ for (NetworkStateHandler::NetworkStateList::iterator it =
+ network_states.begin();
+ it != network_states.end();
++it) {
scoped_ptr<base::DictionaryValue> onc_dictionary =
- TranslateFavoriteStateToONC(*it);
+ TranslateNetworkStateToONC(*it);
if (debugging_properties) {
+ onc_dictionary->SetBoolean("visible", (*it)->visible());
onc_dictionary->SetString("profile_path", (*it)->profile_path());
std::string onc_source = (*it)->ui_data().GetONCSourceAsString();
if (!onc_source.empty())
diff --git a/chromeos/network/network_util.h b/chromeos/network/network_util.h
index 0d4b8ecc..99707bd 100644
--- a/chromeos/network/network_util.h
+++ b/chromeos/network/network_util.h
@@ -26,7 +26,7 @@ class ListValue;
namespace chromeos {
-class FavoriteState;
+class NetworkState;
class NetworkTypePattern;
// Struct for passing wifi access point data.
@@ -91,10 +91,10 @@ CHROMEOS_EXPORT std::string FormattedMacAddress(
CHROMEOS_EXPORT bool ParseCellularScanResults(
const base::ListValue& list, std::vector<CellularScanResult>* scan_results);
-// Retrieves the ONC state dictionary for |favorite| using GetStateProperties.
+// Retrieves the ONC state dictionary for |network| using GetStateProperties.
// This includes properties from the corresponding NetworkState if it exists.
-CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateFavoriteStateToONC(
- const FavoriteState* favorite);
+CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
+ const NetworkState* network);
// Retrieves the list of network services by passing |pattern|,
// |configured_only|, and |visible_only| to NetworkStateHandler::
diff --git a/chromeos/network/shill_property_handler.cc b/chromeos/network/shill_property_handler.cc
index c833106..6e895494 100644
--- a/chromeos/network/shill_property_handler.cc
+++ b/chromeos/network/shill_property_handler.cc
@@ -211,8 +211,7 @@ void ShillPropertyHandler::RequestProperties(ManagedState::ManagedType type,
NET_LOG_DEBUG("Request Properties: " + ManagedState::TypeToString(type),
path);
pending_updates_[type].insert(path);
- if (type == ManagedState::MANAGED_TYPE_NETWORK ||
- type == ManagedState::MANAGED_TYPE_FAVORITE) {
+ if (type == ManagedState::MANAGED_TYPE_NETWORK) {
DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
dbus::ObjectPath(path),
base::Bind(&ShillPropertyHandler::GetPropertiesCallback,
@@ -257,15 +256,14 @@ void ShillPropertyHandler::ManagerPropertiesCallback(
else
ManagerPropertyChanged(iter.key(), iter.value());
}
- // Update Services which can safely assume other properties have been set.
- if (update_service_value)
- ManagerPropertyChanged(shill::kServicesProperty, *update_service_value);
- // Update ServiceCompleteList which skips entries that have already been
- // requested for Services.
+ // Update Service lists after other Manager properties. Update
+ // ServiceCompleteList first so that Services (visible) entries already exist.
if (update_service_complete_value) {
ManagerPropertyChanged(shill::kServiceCompleteListProperty,
*update_service_complete_value);
}
+ if (update_service_value)
+ ManagerPropertyChanged(shill::kServicesProperty, *update_service_value);
CheckPendingStateListUpdates("");
}
@@ -273,21 +271,20 @@ void ShillPropertyHandler::ManagerPropertiesCallback(
void ShillPropertyHandler::CheckPendingStateListUpdates(
const std::string& key) {
// Once there are no pending updates, signal the state list changed callbacks.
- if ((key.empty() || key == shill::kServicesProperty) &&
+ if ((key.empty() || key == shill::kServiceCompleteListProperty) &&
pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) {
listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK);
}
- // Both Network update requests and Favorite update requests will affect
- // the list of favorites, so wait for both to complete.
- if ((key.empty() || key == shill::kServiceCompleteListProperty) &&
- pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0 &&
- pending_updates_[ManagedState::MANAGED_TYPE_FAVORITE].size() == 0) {
- listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE);
- }
if ((key.empty() || key == shill::kDevicesProperty) &&
pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) {
listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE);
}
+ // For emitted Services updates only, we also need to signal that the list
+ // changed in case the visibility changed.
+ if (key == shill::kServicesProperty &&
+ pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) {
+ listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK);
+ }
}
void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key,
@@ -300,8 +297,12 @@ void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key,
} else if (key == shill::kServicesProperty) {
const base::ListValue* vlist = GetListValue(key, value);
if (vlist) {
- listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
- UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
+ // Update the visibility of networks in ServiceCompleteList. Note that
+ // this relies on Shill emitting changes to ServiceCompleteList before
+ // changes to Services. TODO(stevenjb): Eliminate this and rely on
+ // Service.Visible instead.
+ listener_->UpdateVisibleNetworks(*vlist);
+
// UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK,
// however that prevents us from receiving Strength updates from inactive
// networks. The overhead for observing all services is not unreasonable
@@ -311,9 +312,11 @@ void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key,
} else if (key == shill::kServiceCompleteListProperty) {
const base::ListValue* vlist = GetListValue(key, value);
if (vlist) {
- listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_FAVORITE, *vlist);
- UpdateProperties(ManagedState::MANAGED_TYPE_FAVORITE, *vlist);
+ listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
+ UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
}
+ } else if (key == shill::kServiceWatchListProperty) {
+ // Currently we ignore the watch list.
} else if (key == shill::kDevicesProperty) {
const base::ListValue* vlist = GetListValue(key, value);
if (vlist) {
@@ -347,8 +350,6 @@ void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key,
void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type,
const base::ListValue& entries) {
std::set<std::string>& requested_updates = requested_updates_[type];
- std::set<std::string>& requested_service_updates =
- requested_updates_[ManagedState::MANAGED_TYPE_NETWORK]; // For favorites
std::set<std::string> new_requested_updates;
NET_LOG_DEBUG("UpdateProperties: " + ManagedState::TypeToString(type),
base::StringPrintf("%" PRIuS, entries.GetSize()));
@@ -358,22 +359,14 @@ void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type,
(*iter)->GetAsString(&path);
if (path.empty())
continue;
- // Only request properties once. Favorites that are visible will be updated
- // when the Network entry is updated. Since 'Services' is always processed
- // before ServiceCompleteList, only Favorites that are not visible will be
- // requested here, and GetPropertiesCallback() will only get called with
- // type == FAVORITE for non-visible Favorites.
- if (type == ManagedState::MANAGED_TYPE_FAVORITE &&
- requested_service_updates.count(path) > 0) {
- continue;
- }
// We add a special case for devices here to work around an issue in shill
// that prevents it from sending property changed signals for cellular
// devices (see crbug.com/321854).
if (type == ManagedState::MANAGED_TYPE_DEVICE ||
- requested_updates.find(path) == requested_updates.end())
+ requested_updates.find(path) == requested_updates.end()) {
RequestProperties(type, path);
+ }
new_requested_updates.insert(path);
}
requested_updates.swap(new_requested_updates);
@@ -381,8 +374,6 @@ void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type,
void ShillPropertyHandler::UpdateObserved(ManagedState::ManagedType type,
const base::ListValue& entries) {
- DCHECK(type == ManagedState::MANAGED_TYPE_NETWORK ||
- type == ManagedState::MANAGED_TYPE_DEVICE);
ShillPropertyObserverMap& observer_map =
(type == ManagedState::MANAGED_TYPE_NETWORK)
? observed_networks_ : observed_devices_;
@@ -491,14 +482,6 @@ void ShillPropertyHandler::GetPropertiesCallback(
base::StringPrintf("%s: %d", path.c_str(), call_status));
return;
}
- // Update Favorite properties for networks in the Services list. Call this
- // for all networks, regardless of whether or not Profile is set, because
- // we track all networks in the Favorites list (even if they aren't saved
- // in a Profile). See notes in UpdateProperties() and favorite_state.h.
- if (type == ManagedState::MANAGED_TYPE_NETWORK) {
- listener_->UpdateManagedStateProperties(
- ManagedState::MANAGED_TYPE_FAVORITE, path, properties);
- }
listener_->UpdateManagedStateProperties(type, path, properties);
if (type == ManagedState::MANAGED_TYPE_NETWORK) {
@@ -514,15 +497,8 @@ void ShillPropertyHandler::GetPropertiesCallback(
}
// Notify the listener only when all updates for that type have completed.
- if (pending_updates_[type].size() == 0) {
+ if (pending_updates_[type].size() == 0)
listener_->ManagedStateListChanged(type);
- // Notify that Favorites have changed when notifying for Networks if there
- // are no additional Favorite updates pending.
- if (type == ManagedState::MANAGED_TYPE_NETWORK &&
- pending_updates_[ManagedState::MANAGED_TYPE_FAVORITE].size() == 0) {
- listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE);
- }
- }
}
void ShillPropertyHandler::PropertyChangedCallback(
diff --git a/chromeos/network/shill_property_handler.h b/chromeos/network/shill_property_handler.h
index 5a78f19..0df6d3b 100644
--- a/chromeos/network/shill_property_handler.h
+++ b/chromeos/network/shill_property_handler.h
@@ -50,6 +50,9 @@ class CHROMEOS_EXPORT ShillPropertyHandler
virtual void UpdateManagedList(ManagedState::ManagedType type,
const base::ListValue& entries) = 0;
+ // Called when the entries in the visible network list have changed.
+ virtual void UpdateVisibleNetworks(const base::ListValue& entries) = 0;
+
// Called when the properties for a managed state have changed.
virtual void UpdateManagedStateProperties(
ManagedState::ManagedType type,
@@ -156,13 +159,7 @@ class CHROMEOS_EXPORT ShillPropertyHandler
void ManagerPropertyChanged(const std::string& key,
const base::Value& value);
- // Requests properties for new entries in the list for |type| as follows:
- // * Any new Device objects for MANAGED_TYPE_DEVICE
- // * Any new Service objects for MANAGED_TYPE_NETWORK
- // * Additional new Service objects for MANAGED_TYPE_FAVORITE that were not
- // requested for MANAGED_TYPE_NETWORK (i.e. only request objects once).
- // For this to avoid duplicate requests, this must be called with
- // MANAGED_TYPE_NETWORK before MANAGED_TYPE_FAVORITE.
+ // Requests properties for new entries in the list for |type|.
void UpdateProperties(ManagedState::ManagedType type,
const base::ListValue& entries);
diff --git a/chromeos/network/shill_property_handler_unittest.cc b/chromeos/network/shill_property_handler_unittest.cc
index 0b8a94d..7ac23322 100644
--- a/chromeos/network/shill_property_handler_unittest.cc
+++ b/chromeos/network/shill_property_handler_unittest.cc
@@ -42,14 +42,22 @@ class TestListener : public internal::ShillPropertyHandler::Listener {
virtual void UpdateManagedList(ManagedState::ManagedType type,
const base::ListValue& entries) OVERRIDE {
+ VLOG(1) << "UpdateManagedList[" << ManagedState::TypeToString(type) << "]: "
+ << entries.GetSize();
UpdateEntries(GetTypeString(type), entries);
}
+ virtual void UpdateVisibleNetworks(const base::ListValue& entries) OVERRIDE {
+ VLOG(1) << "UpdateVisibleNetworks: " << entries.GetSize();
+ UpdateEntries(shill::kServicesProperty, entries);
+ }
+
virtual void UpdateManagedStateProperties(
ManagedState::ManagedType type,
const std::string& path,
const base::DictionaryValue& properties) OVERRIDE {
- AddInitialPropertyUpdate(GetTypeString(type), path);
+ VLOG(2) << "UpdateManagedStateProperties: " << GetTypeString(type);
+ initial_property_updates(GetTypeString(type))[path] += 1;
}
virtual void ProfileListChanged() OVERRIDE {
@@ -59,7 +67,7 @@ class TestListener : public internal::ShillPropertyHandler::Listener {
const std::string& service_path,
const std::string& key,
const base::Value& value) OVERRIDE {
- AddPropertyUpdate(shill::kServicesProperty, service_path);
+ AddPropertyUpdate(shill::kServiceCompleteListProperty, service_path);
}
virtual void UpdateDeviceProperty(
@@ -88,6 +96,7 @@ class TestListener : public internal::ShillPropertyHandler::Listener {
virtual void ManagedStateListChanged(
ManagedState::ManagedType type) OVERRIDE {
+ VLOG(1) << "ManagedStateListChanged: " << GetTypeString(type);
AddStateListUpdate(GetTypeString(type));
}
@@ -116,15 +125,11 @@ class TestListener : public internal::ShillPropertyHandler::Listener {
private:
std::string GetTypeString(ManagedState::ManagedType type) {
- if (type == ManagedState::MANAGED_TYPE_NETWORK) {
- return shill::kServicesProperty;
- } else if (type == ManagedState::MANAGED_TYPE_FAVORITE) {
+ if (type == ManagedState::MANAGED_TYPE_NETWORK)
return shill::kServiceCompleteListProperty;
- } else if (type == ManagedState::MANAGED_TYPE_DEVICE) {
+ if (type == ManagedState::MANAGED_TYPE_DEVICE)
return shill::kDevicesProperty;
- }
- LOG(ERROR) << "UpdateManagedList called with unrecognized type: " << type;
- ++errors_;
+ NOTREACHED();
return std::string();
}
@@ -141,23 +146,13 @@ class TestListener : public internal::ShillPropertyHandler::Listener {
}
void AddPropertyUpdate(const std::string& type, const std::string& path) {
- if (type.empty())
- return;
+ DCHECK(!type.empty());
VLOG(2) << "AddPropertyUpdate: " << type;
property_updates(type)[path] += 1;
}
- void AddInitialPropertyUpdate(const std::string& type,
- const std::string& path) {
- if (type.empty())
- return;
- VLOG(2) << "AddInitialPropertyUpdate: " << type;
- initial_property_updates(type)[path] += 1;
- }
-
void AddStateListUpdate(const std::string& type) {
- if (type.empty())
- return;
+ DCHECK(!type.empty());
list_updates_[type] += 1;
}
@@ -224,9 +219,9 @@ class ShillPropertyHandlerTest : public testing::Test {
void AddService(const std::string& type,
const std::string& id,
const std::string& state) {
+ VLOG(2) << "AddService: " << type << ": " << id << ": " << state;
ASSERT_TRUE(IsValidType(type));
- service_test_->AddService(id, id, type, state,
- true /* visible */);
+ service_test_->AddService(id, id, type, state, true /* visible */);
}
void AddServiceWithIPConfig(const std::string& type,
@@ -380,13 +375,13 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) {
const std::string kTestServicePath("test_wifi_service1");
AddService(shill::kTypeWifi, kTestServicePath, shill::kStateIdle);
message_loop_.RunUntilIdle();
- // Add should trigger a service list update and should update entries.
- EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty));
+ // Add should trigger a service list update and update entries.
+ EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
listener_->entries(shill::kServicesProperty).size());
// Service receives an initial property update.
EXPECT_EQ(1, listener_->initial_property_updates(
- shill::kServicesProperty)[kTestServicePath]);
+ shill::kServiceCompleteListProperty)[kTestServicePath]);
// Change a property.
base::FundamentalValue scan_interval(3);
DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
@@ -397,13 +392,25 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServicePropertyChanged) {
message_loop_.RunUntilIdle();
// Property change triggers an update (but not a service list update).
EXPECT_EQ(1, listener_->property_updates(
- shill::kServicesProperty)[kTestServicePath]);
+ shill::kServiceCompleteListProperty)[kTestServicePath]);
+
+ // Change the visibility of a service. This will signal two service list
+ // updates, one for the complete list and one for the visible list.
+ listener_->reset_list_updates();
+ DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
+ dbus::ObjectPath(kTestServicePath),
+ shill::kVisibleProperty,
+ base::FundamentalValue(false),
+ base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
+ message_loop_.RunUntilIdle();
+ EXPECT_EQ(2, listener_->list_updates(shill::kServiceCompleteListProperty));
- // Remove a service.
+ // Remove a service. This will update the entries and signal a service list
+ // update.
listener_->reset_list_updates();
RemoveService(kTestServicePath);
message_loop_.RunUntilIdle();
- EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty));
+ EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
EXPECT_EQ(kNumShillManagerClientStubImplServices,
listener_->entries(shill::kServicesProperty).size());
@@ -445,7 +452,7 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) {
message_loop_.RunUntilIdle();
// This is the initial property update.
EXPECT_EQ(1, listener_->initial_property_updates(
- shill::kServicesProperty)[kTestServicePath1]);
+ shill::kServiceCompleteListProperty)[kTestServicePath1]);
DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
dbus::ObjectPath(kTestServicePath1),
shill::kIPConfigProperty,
@@ -467,64 +474,35 @@ TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerIPConfigPropertyChanged) {
shill::kIPConfigsProperty)[kTestIPConfigPath]);
}
-TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceCompleteList) {
- // Add a new entry to the profile only (triggers a Services update).
+TEST_F(ShillPropertyHandlerTest, ShillPropertyHandlerServiceList) {
+ // Add an entry to the profile only.
const std::string kTestServicePath1("stub_wifi_profile_only1");
AddServiceToProfile(shill::kTypeWifi, kTestServicePath1, false /* visible */);
message_loop_.RunUntilIdle();
// Update the Manager properties. This should trigger a single list update
- // for both Services and ServiceCompleteList, and a single property update
- // for ServiceCompleteList.
+ // and a single initial property update.
listener_->reset_list_updates();
shill_property_handler_->UpdateManagerProperties();
message_loop_.RunUntilIdle();
- EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty));
EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
- EXPECT_EQ(0, listener_->initial_property_updates(
- shill::kServicesProperty)[kTestServicePath1]);
EXPECT_EQ(1, listener_->initial_property_updates(
shill::kServiceCompleteListProperty)[kTestServicePath1]);
- EXPECT_EQ(0, listener_->property_updates(
- shill::kServicesProperty)[kTestServicePath1]);
+
EXPECT_EQ(0, listener_->property_updates(
shill::kServiceCompleteListProperty)[kTestServicePath1]);
// Add a new entry to the services and the profile; should also trigger a
- // single list update for both Services and ServiceCompleteList, and should
- // trigger tow property updates for Services (one when the Profile propety
- // changes, and one for the Request) and one ServiceCompleteList change for
- // the Request.
+ // service list update, and a property update.
listener_->reset_list_updates();
const std::string kTestServicePath2("stub_wifi_profile_only2");
AddServiceToProfile(shill::kTypeWifi, kTestServicePath2, true);
shill_property_handler_->UpdateManagerProperties();
message_loop_.RunUntilIdle();
- EXPECT_EQ(1, listener_->list_updates(shill::kServicesProperty));
EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty));
EXPECT_EQ(1, listener_->initial_property_updates(
- shill::kServicesProperty)[kTestServicePath2]);
- EXPECT_EQ(1, listener_->initial_property_updates(
shill::kServiceCompleteListProperty)[kTestServicePath2]);
- // Expect one property update for the Profile property of the Network.
EXPECT_EQ(1, listener_->property_updates(
- shill::kServicesProperty)[kTestServicePath2]);
- EXPECT_EQ(0, listener_->property_updates(
- shill::kServiceCompleteListProperty)[kTestServicePath2]);
-
- // Change a property of a Network in a Profile.
- base::FundamentalValue scan_interval(3);
- DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
- dbus::ObjectPath(kTestServicePath2),
- shill::kScanIntervalProperty,
- scan_interval,
- base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
- message_loop_.RunUntilIdle();
- // Property change should trigger an update for the Network only; no
- // property updates pushed by Shill affect Favorites.
- EXPECT_EQ(2, listener_->property_updates(
- shill::kServicesProperty)[kTestServicePath2]);
- EXPECT_EQ(0, listener_->property_updates(
shill::kServiceCompleteListProperty)[kTestServicePath2]);
}