diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 22:53:31 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 22:53:31 +0000 |
commit | 7be87f35e7b4ebbb92c298f998008be6ac33ecc2 (patch) | |
tree | afd1455fe7561f3ee4b50754c8c2da06b1222e31 | |
parent | fe2dd774543cb94fb60feb94df60444fd5b73c34 (diff) | |
download | chromium_src-7be87f35e7b4ebbb92c298f998008be6ac33ecc2.zip chromium_src-7be87f35e7b4ebbb92c298f998008be6ac33ecc2.tar.gz chromium_src-7be87f35e7b4ebbb92c298f998008be6ac33ecc2.tar.bz2 |
Fix connection logic for forgotten wifi networks.
Includes some small re-factoring.
BUG=chromium-os:11941, chromium-os:13242
TEST=See issue.
Review URL: http://codereview.chromium.org/6799006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82178 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 169 insertions, 104 deletions
diff --git a/chrome/browser/chromeos/cros/mock_network_library.h b/chrome/browser/chromeos/cros/mock_network_library.h index 014ee9a..4a385b5 100644 --- a/chrome/browser/chromeos/cros/mock_network_library.h +++ b/chrome/browser/chromeos/cros/mock_network_library.h @@ -72,6 +72,7 @@ class MockNetworkLibrary : public NetworkLibrary { CellularNetwork*(const std::string&)); MOCK_CONST_METHOD1(FindVirtualNetworkByPath, VirtualNetwork*(const std::string&)); + MOCK_CONST_METHOD1(FindNetworkFromRemembered,Network*(const Network*)); MOCK_CONST_METHOD1(GetDataPlans, CellularDataPlanVector*(const std::string&)); MOCK_CONST_METHOD1(GetSignificantDataPlan, diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index 8314719..cd959ea 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -28,10 +28,10 @@ // and services: // // NetworkDevice: e.g. ethernet, wifi modem, cellular modem -// device_map_: canonical map<name,NetworkDevice*> for devices +// device_map_: canonical map<path,NetworkDevice*> for devices // // Network: a network service ("network"). -// network_map_: canonical map<name,Network*> for all visible networks. +// network_map_: canonical map<path,Network*> for all visible networks. // EthernetNetwork // ethernet_: EthernetNetwork* to the active ethernet network in network_map_. // WirelessNetwork: a Wifi or Cellular Network. @@ -42,7 +42,8 @@ // CellularNetwork // active_cellular_: Cellular version of wifi_. // cellular_networks_: Cellular version of wifi_. -// remembered_network_map_: a canonical map<name,Network*> for all networks +// network_unique_id_map_: map<unique_id,Network*> for visible networks. +// remembered_network_map_: a canonical map<path,Network*> for all networks // remembered in the active Profile ("favorites"). // remembered_wifi_networks_: ordered vector of WifiNetwork* entries in // remembered_network_map_, in descending order of preference. @@ -194,6 +195,7 @@ const char* kSecurityWpa = "wpa"; const char* kSecurityWep = "wep"; const char* kSecurityRsn = "rsn"; const char* kSecurity8021x = "802_1x"; +const char* kSecurityPsk = "psk"; const char* kSecurityNone = "none"; // Flimflam L2TPIPsec property names. @@ -329,18 +331,20 @@ static const char* ConnectionTypeToString(ConnectionType type) { // TODO(stevenjb/njw): Deprecate in favor of setting EAP properties. static const char* SecurityToString(ConnectionSecurity security) { switch (security) { - case SECURITY_UNKNOWN: - break; - case SECURITY_8021X: - return kSecurity8021x; - case SECURITY_RSN: - return kSecurityRsn; - case SECURITY_WPA: - return kSecurityWpa; - case SECURITY_WEP: - return kSecurityWep; case SECURITY_NONE: return kSecurityNone; + case SECURITY_WEP: + return kSecurityWep; + case SECURITY_WPA: + return kSecurityWpa; + case SECURITY_RSN: + return kSecurityRsn; + case SECURITY_8021X: + return kSecurity8021x; + case SECURITY_PSK: + return kSecurityPsk; + case SECURITY_UNKNOWN: + break; } LOG(ERROR) << "SecurityToString called with unknown type: " << security; return kUnknownString; @@ -726,11 +730,12 @@ static NetworkRoamingState ParseRoamingState(const std::string& roaming_state) { // WifiNetwork static ConnectionSecurity ParseSecurity(const std::string& security) { static StringToEnum<ConnectionSecurity>::Pair table[] = { - { kSecurity8021x, SECURITY_8021X }, - { kSecurityRsn, SECURITY_RSN }, - { kSecurityWpa, SECURITY_WPA }, - { kSecurityWep, SECURITY_WEP }, { kSecurityNone, SECURITY_NONE }, + { kSecurityWep, SECURITY_WEP }, + { kSecurityWpa, SECURITY_WPA }, + { kSecurityRsn, SECURITY_RSN }, + { kSecurityPsk, SECURITY_PSK }, + { kSecurity8021x, SECURITY_8021X }, }; static StringToEnum<ConnectionSecurity> parser( table, arraysize(table), SECURITY_UNKNOWN); @@ -1618,6 +1623,17 @@ std::string CellularNetwork::GetRoamingStateString() const { //////////////////////////////////////////////////////////////////////////////// // WifiNetwork +// Called from ParseNetwork after calling ParseInfo. +void WifiNetwork::CalculateUniqueId() { + ConnectionSecurity encryption = encryption_; + // Flimflam treats wpa and rsn as psk internally, so convert those types + // to psk for unique naming. + if (encryption == SECURITY_WPA || encryption == SECURITY_RSN) + encryption = SECURITY_PSK; + std::string security = std::string(SecurityToString(encryption)); + unique_id_ = security + "|" + name_; +} + bool WifiNetwork::ParseValue(int index, const Value* value) { switch (index) { case PROPERTY_INDEX_SECURITY: { @@ -1692,6 +1708,11 @@ bool WifiNetwork::ParseValue(int index, const Value* value) { return false; } +void WifiNetwork::ParseInfo(const DictionaryValue* info) { + Network::ParseInfo(info); + CalculateUniqueId(); +} + const std::string& WifiNetwork::GetPassphrase() const { if (!user_passphrase_.empty()) return user_passphrase_; @@ -1702,13 +1723,15 @@ void WifiNetwork::SetPassphrase(const std::string& passphrase) { // Set the user_passphrase_ only; passphrase_ stores the flimflam value. // If the user sets an empty passphrase, restore it to the passphrase // remembered by flimflam. - if (!passphrase.empty()) + if (!passphrase.empty()) { user_passphrase_ = passphrase; - else + passphrase_ = passphrase; + } else { user_passphrase_ = passphrase_; + } // Send the change to flimflam. If the format is valid, it will propagate to // passphrase_ with a service update. - SetStringProperty(kPassphraseProperty, passphrase, NULL); + SetOrClearStringProperty(kPassphraseProperty, passphrase, NULL); } void WifiNetwork::SetSaveCredentials(bool save_credentials) { @@ -1720,11 +1743,11 @@ void WifiNetwork::SetSaveCredentials(bool save_credentials) { // flimflam will forget when SaveCredentials is false. void WifiNetwork::EraseCredentials() { WipeString(&passphrase_); + WipeString(&user_passphrase_); WipeString(&eap_client_cert_pkcs11_id_); WipeString(&eap_identity_); WipeString(&eap_anonymous_identity_); WipeString(&eap_passphrase_); - WipeString(&user_passphrase_); } void WifiNetwork::SetIdentity(const std::string& identity) { @@ -1832,6 +1855,8 @@ std::string WifiNetwork::GetEncryptionString() const { return "RSN"; case SECURITY_8021X: return "8021X"; + case SECURITY_PSK: + return "PSK"; } return "Unknown"; } @@ -2182,6 +2207,15 @@ class NetworkLibraryImpl : public NetworkLibrary { return NULL; } + virtual Network* FindNetworkFromRemembered( + const Network* remembered) const { + NetworkMap::const_iterator found = + network_unique_id_map_.find(remembered->unique_id()); + if (found != network_unique_id_map_.end()) + return found->second; + return NULL; + } + virtual const CellularDataPlanVector* GetDataPlans( const std::string& path) const { CellularDataPlanMap::const_iterator iter = data_plan_map_.find(path); @@ -2198,6 +2232,8 @@ class NetworkLibraryImpl : public NetworkLibrary { return NULL; } + ///////////////////////////////////////////////////////////////////////////// + virtual void ChangePin(const std::string& old_pin, const std::string& new_pin) { const NetworkDevice* cellular = FindCellularDevice(); @@ -2283,6 +2319,8 @@ class NetworkLibraryImpl : public NetworkLibrary { networklib->NotifyPinOperationCompleted(pin_error); } + ///////////////////////////////////////////////////////////////////////////// + virtual void RequestNetworkScan() { if (EnsureCrosLoaded()) { if (wifi_enabled()) { @@ -2378,6 +2416,9 @@ class NetworkLibraryImpl : public NetworkLibrary { void CallConnectToNetwork(Network* network) { + DCHECK(network); + if (!EnsureCrosLoaded() || !network) + return; // In order to be certain to trigger any notifications, set the connecting // state locally and notify observers. Otherwise there might be a state // change without a forced notify. @@ -2388,23 +2429,22 @@ class NetworkLibraryImpl : public NetworkLibrary { } virtual void ConnectToWifiNetwork(WifiNetwork* wifi) { - DCHECK(wifi); - if (!EnsureCrosLoaded() || !wifi) - return; + // This will happen if a network resets or gets out of range. + if (wifi->user_passphrase_ != wifi->passphrase_ || + wifi->passphrase_required()) + wifi->SetPassphrase(wifi->user_passphrase_); CallConnectToNetwork(wifi); } // Use this to connect to a wifi network by service path. virtual void ConnectToWifiNetwork(const std::string& service_path) { - if (!EnsureCrosLoaded()) - return; WifiNetwork* wifi = FindWifiNetworkByPath(service_path); if (!wifi) { LOG(WARNING) << "Attempt to connect to non existing network: " << service_path; return; } - CallConnectToNetwork(wifi); + ConnectToWifiNetwork(wifi); } // Use this to connect to an unlisted wifi network. @@ -2460,14 +2500,11 @@ class NetworkLibraryImpl : public NetworkLibrary { if (!data.cert_path.empty()) wifi->SetCertPath(data.cert_path); - CallConnectToNetwork(wifi); + ConnectToWifiNetwork(wifi); } - virtual void ConnectToCellularNetwork(CellularNetwork* network) { - DCHECK(network); - if (!EnsureCrosLoaded() || !network) - return; - CallConnectToNetwork(network); + virtual void ConnectToCellularNetwork(CellularNetwork* cellular) { + CallConnectToNetwork(cellular); } // Records information that cellular play payment had happened. @@ -2482,11 +2519,8 @@ class NetworkLibraryImpl : public NetworkLibrary { cellular_plan_payment_time_).InHours() < kRecentPlanPaymentHours; } - virtual void ConnectToVirtualNetwork(VirtualNetwork* network) { - DCHECK(network); - if (!EnsureCrosLoaded() || !network) - return; - CallConnectToNetwork(network); + virtual void ConnectToVirtualNetwork(VirtualNetwork* vpn) { + CallConnectToNetwork(vpn); } virtual void ConnectToVirtualNetworkPSK( @@ -2574,16 +2608,9 @@ class NetworkLibraryImpl : public NetworkLibrary { virtual void ForgetWifiNetwork(const std::string& service_path) { if (!EnsureCrosLoaded()) return; - // NOTE: service paths for remembered wifi networks do not match the - // service paths in wifi_networks_; calling a libcros funtion that - // operates on the wifi_networks_ list with this service_path will - // trigger a crash because the DBUS path does not exist. - // TODO(stevenjb): modify libcros to warn and fail instead of crash. - // https://crosbug.com/9295 - if (DeleteRememberedService(service_path.c_str())) { - DeleteRememberedNetwork(service_path); - NotifyNetworkManagerChanged(true); // Forced update. - } + DeleteRememberedService(service_path.c_str()); + DeleteRememberedWifiNetwork(service_path); + NotifyNetworkManagerChanged(true); // Forced update. } virtual bool ethernet_available() const { @@ -2931,7 +2958,7 @@ class NetworkLibraryImpl : public NetworkLibrary { if (service_path) { if (!info) { // Remembered network no longer exists. - networklib->DeleteRememberedNetwork(std::string(service_path)); + networklib->DeleteRememberedWifiNetwork(std::string(service_path)); } else { DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); @@ -3077,6 +3104,8 @@ class NetworkLibraryImpl : public NetworkLibrary { } Network* network = found->second; network_map_.erase(found); + if (!network->unique_id().empty()) + network_unique_id_map_.erase(network->unique_id()); ConnectionType type(network->type()); if (type == TYPE_ETHERNET) { if (network == ethernet_) { @@ -3125,18 +3154,15 @@ class NetworkLibraryImpl : public NetworkLibrary { delete network; } - void AddRememberedNetwork(Network* network) { + void AddRememberedWifiNetwork(WifiNetwork* wifi) { std::pair<NetworkMap::iterator,bool> result = remembered_network_map_.insert( - std::make_pair(network->service_path(), network)); + std::make_pair(wifi->service_path(), wifi)); DCHECK(result.second); // Should only get called with new network. - if (network->type() == TYPE_WIFI) { - WifiNetwork* wifi = static_cast<WifiNetwork*>(network); - remembered_wifi_networks_.push_back(wifi); - } + remembered_wifi_networks_.push_back(wifi); } - void DeleteRememberedNetwork(const std::string& service_path) { + void DeleteRememberedWifiNetwork(const std::string& service_path) { NetworkMap::iterator found = remembered_network_map_.find(service_path); if (found == remembered_network_map_.end()) { LOG(WARNING) << "Attempt to delete non-existant remembered network: " @@ -3150,6 +3176,16 @@ class NetworkLibraryImpl : public NetworkLibrary { remembered_network); if (iter != remembered_wifi_networks_.end()) remembered_wifi_networks_.erase(iter); + Network* network = FindNetworkFromRemembered(remembered_network); + if (network && network->type() == TYPE_WIFI) { + // Clear the stored credentials for any visible forgotten networks. + WifiNetwork* wifi = static_cast<WifiNetwork*>(network); + wifi->EraseCredentials(); + } else { + // Network is not in visible list. + VLOG(2) << "Remembered Network not found: " + << remembered_network->unique_id(); + } delete remembered_network; } @@ -3237,8 +3273,12 @@ class NetworkLibraryImpl : public NetworkLibrary { // RememberedNetworkServiceUpdate calls ParseRememberedNetwork. NetworkMap::iterator found = old_network_map.find(service_path); if (found != old_network_map.end()) { - AddRememberedNetwork(found->second); - old_network_map.erase(found); + Network* network = found->second; + if (network->type() == TYPE_WIFI) { + WifiNetwork* wifi = static_cast<WifiNetwork*>(network); + AddRememberedWifiNetwork(wifi); + old_network_map.erase(found); + } } // Always request updates for remembered networks. RequestNetworkProfileEntry(profile_path, @@ -3289,8 +3329,15 @@ class NetworkLibraryImpl : public NetworkLibrary { AddNetwork(network); } + // Erase entry from network_unique_id_map_ in case unique id changes. + if (!network->unique_id().empty()) + network_unique_id_map_.erase(network->unique_id()); + network->ParseInfo(info); // virtual. + if (!network->unique_id().empty()) + network_unique_id_map_[network->unique_id()] = network; + UpdateActiveNetwork(network); // Find and erase entry in update_requests, and set network priority. @@ -3313,6 +3360,8 @@ class NetworkLibraryImpl : public NetworkLibrary { return network; } + // Returns NULL if |service_path| refers to a network that is not a + // remembered type. Network* ParseRememberedNetwork(const std::string& service_path, const DictionaryValue* info) { Network* network; @@ -3321,8 +3370,15 @@ class NetworkLibraryImpl : public NetworkLibrary { network = found->second; } else { ConnectionType type = ParseTypeFromDictionary(info); - network = CreateNewNetwork(type, service_path); - AddRememberedNetwork(network); + if (type == TYPE_WIFI) { + network = CreateNewNetwork(type, service_path); + WifiNetwork* wifi = static_cast<WifiNetwork*>(network); + AddRememberedWifiNetwork(wifi); + } else { + VLOG(1) << "Ignoring remembered network: " << service_path + << " Type: " << ConnectionTypeToString(type); + return NULL; + } } network->ParseInfo(info); // virtual. VLOG(1) << "ParseRememberedNetwork: " << network->name(); @@ -3334,6 +3390,7 @@ class NetworkLibraryImpl : public NetworkLibrary { if (delete_networks) STLDeleteValues(&network_map_); network_map_.clear(); + network_unique_id_map_.clear(); ethernet_ = NULL; active_wifi_ = NULL; active_cellular_ = NULL; @@ -3779,7 +3836,7 @@ class NetworkLibraryImpl : public NetworkLibrary { remembered_wifi2->set_strength(70); remembered_wifi2->set_connected(true); remembered_wifi2->set_encryption(SECURITY_WEP); - AddRememberedNetwork(remembered_wifi2); + AddRememberedWifiNetwork(remembered_wifi2); // VPNs. VirtualNetwork* vpn1 = new VirtualNetwork("fv1"); @@ -3841,6 +3898,9 @@ class NetworkLibraryImpl : public NetworkLibrary { // A service path based map of all Networks. NetworkMap network_map_; + // A unique_id_ based map of Networks. + NetworkMap network_unique_id_map_; + // A service path based map of all remembered Networks. NetworkMap remembered_network_map_; @@ -4010,6 +4070,8 @@ class NetworkLibraryStubImpl : public NetworkLibrary { const std::string& path) const { return NULL; } virtual VirtualNetwork* FindVirtualNetworkByPath( const std::string& path) const { return NULL; } + virtual Network* FindNetworkFromRemembered( + const Network* remembered) const { return NULL; } virtual const CellularDataPlanVector* GetDataPlans( const std::string& path) const { return NULL; } virtual const CellularDataPlan* GetSignificantDataPlan( diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index 5d39b28..9bc002d 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -46,6 +46,7 @@ enum ConnectionSecurity { SECURITY_WPA = 3, SECURITY_RSN = 4, SECURITY_8021X = 5, + SECURITY_PSK = 6, }; enum ConnectionState { @@ -267,6 +268,8 @@ class Network { ConnectivityState connectivity_state() const { return connectivity_state_; } bool added() const { return added_; } + const std::string& unique_id() const { return unique_id_; } + // We don't have a setter for |favorite_| because to unfavorite a network is // equivalent to forget a network, so we call forget network on cros for // that. See ForgetWifiNetwork(). @@ -327,6 +330,9 @@ class Network { bool auto_connect_; ConnectivityState connectivity_state_; + // Unique identifier, set the first time the network is parsed. + std::string unique_id_; + private: void set_name(const std::string& name) { name_ = name; } void set_connecting(bool connecting) { @@ -623,6 +629,7 @@ class WifiNetwork : public WirelessNetwork { const std::string& passphrase() const { return passphrase_; } const std::string& identity() const { return identity_; } const std::string& cert_path() const { return cert_path_; } + bool passphrase_required() const { return passphrase_required_; } EAPMethod eap_method() const { return eap_method_; } EAPPhase2Auth eap_phase_2_auth() const { return eap_phase_2_auth_; } @@ -667,11 +674,13 @@ class WifiNetwork : public WirelessNetwork { // Return true if cert_path_ indicates that we have loaded the certificate. bool IsCertificateLoaded() const; - protected: + private: // WirelessNetwork overrides. virtual bool ParseValue(int index, const Value* value); + virtual void ParseInfo(const DictionaryValue* info); + + void CalculateUniqueId(); - private: void set_encryption(ConnectionSecurity encryption) { encryption_ = encryption; } @@ -970,6 +979,11 @@ class NetworkLibrary { virtual VirtualNetwork* FindVirtualNetworkByPath( const std::string& path) const = 0; + // Returns the visible wifi network corresponding to the remembered + // wifi network, or NULL if the remembered network is not visible. + virtual Network* FindNetworkFromRemembered( + const Network* remembered) const = 0; + // Retrieves the data plans associated with |path|, NULL if there are no // associated plans. virtual const CellularDataPlanVector* GetDataPlans( diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index d569c94..587f078 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -366,14 +366,23 @@ void WifiConfigView::UpdateErrorLabel() { NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); const WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); if (wifi && wifi->failed()) { - if (wifi->error() == ERROR_BAD_PASSPHRASE) { - error_msg = l10n_util::GetStringUTF8( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE); - } else if (wifi->error() == ERROR_BAD_WEPKEY) { - error_msg = l10n_util::GetStringUTF8( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_WEPKEY); - } else { - error_msg = wifi->GetErrorString(); + bool passphrase_empty = wifi->GetPassphrase().empty(); + switch (wifi->error()) { + case ERROR_BAD_PASSPHRASE: + if (!passphrase_empty) { + error_msg = l10n_util::GetStringUTF8( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE); + } + break; + case ERROR_BAD_WEPKEY: + if (!passphrase_empty) { + error_msg = l10n_util::GetStringUTF8( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_WEPKEY); + } + break; + default: + error_msg = wifi->GetErrorString(); + break; } } } 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 33f41c8..a578286 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -1146,10 +1146,6 @@ ListValue* InternetOptionsHandler::GetWirelessList() { return list; } -std::string GetWifiUniqueIdentifier(const chromeos::WifiNetwork* wifi) { - return wifi->encryption() + "|" + wifi->name(); -} - ListValue* InternetOptionsHandler::GetRememberedList() { chromeos::NetworkLibrary* cros = chromeos::CrosLibrary::Get()->GetNetworkLibrary(); @@ -1158,52 +1154,35 @@ ListValue* InternetOptionsHandler::GetRememberedList() { const chromeos::WifiNetworkVector& remembered_wifi_networks = cros->remembered_wifi_networks(); - const chromeos::WifiNetworkVector& wifi_networks = - cros->wifi_networks(); const chromeos::Network* active_network = cros->active_network(); bool vpn_on_wireless = active_network && cros->virtual_network() && active_network->type() == chromeos::TYPE_WIFI; - // The remembered networks from libcros/flimflam don't include the signal - // strength, so fall back to the detected networks for this data. We - // consider networks to be the same if they have the same name and encryption - // type, so create a map of detected networks indexed by name + encryption. - std::map<std::string, chromeos::WifiNetwork*> wifi_map; - for (chromeos::WifiNetworkVector::const_iterator it = wifi_networks.begin(); - it != wifi_networks.end(); ++it) { - wifi_map[GetWifiUniqueIdentifier(*it)] = *it; - } - for (chromeos::WifiNetworkVector::const_iterator rit = remembered_wifi_networks.begin(); rit != remembered_wifi_networks.end(); ++rit) { - chromeos::WifiNetwork* wifi = *rit; - // Check if this remembered network has a matching detected network. - std::map<std::string, chromeos::WifiNetwork*>::const_iterator it = - wifi_map.find(GetWifiUniqueIdentifier(wifi)); - bool found = it != wifi_map.end(); - - // Don't show the active network in the remembered list. - if (found && (it->second)->connected()) - continue; - const SkBitmap* icon = found ? - chromeos::NetworkMenu::IconForNetworkStrength(it->second, true) : + chromeos::WifiNetwork* remembered = *rit; + chromeos::Network* network = cros->FindNetworkFromRemembered(remembered); + + const SkBitmap* icon = network ? + chromeos::NetworkMenu::IconForNetworkStrength( + static_cast<chromeos::WifiNetwork*>(network), true) : rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); // Place the secure badge on the icon if the remembered network is // encrypted (the matching detected network, if any, will have the same // encrypted property by definition). - const SkBitmap* bottom_right_badge = wifi->encrypted() ? + const SkBitmap* bottom_right_badge = remembered->encrypted() ? rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL; const SkBitmap* bottom_left_badge = - vpn_on_wireless && active_network == wifi ? + vpn_on_wireless && active_network == network ? chromeos::NetworkMenu::BadgeForPrivateNetworkStatus(NULL) : NULL; list->Append(GetNetwork( - wifi->service_path(), + remembered->service_path(), chromeos::NetworkMenu::IconForDisplay(icon, bottom_right_badge, NULL, bottom_left_badge), - wifi->name(), - wifi->connecting(), - wifi->connected(), + remembered->name(), + network ? network->connecting() : false, + network ? network->connected() : false, true, chromeos::TYPE_WIFI, true, |