diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 21:26:28 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-24 21:26:28 +0000 |
commit | 66d38b20c86757002104c65b932cf2a0f28d868d (patch) | |
tree | 0e9eeefdfc685615390cb2202563fe92f4bcf64e | |
parent | d72dc0441d9bd4575d1cca121cfe22a7dea86ade (diff) | |
download | chromium_src-66d38b20c86757002104c65b932cf2a0f28d868d.zip chromium_src-66d38b20c86757002104c65b932cf2a0f28d868d.tar.gz chromium_src-66d38b20c86757002104c65b932cf2a0f28d868d.tar.bz2 |
Add remembered virtual networks to NetworkLibrary and internet options.
Also, request virtual networks from flimflam for any remembered virtual networks so that they can be connected to.
BUG=chromium-os:16230, chromium-os:16229
TEST=See issue for test plan.
Review URL: http://codereview.chromium.org/7247021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90439 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 203 insertions, 79 deletions
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc index 9e22316..fa8438a 100644 --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc @@ -478,7 +478,7 @@ void TestingAutomationProvider::ForgetWifiNetwork( return; } - CrosLibrary::Get()->GetNetworkLibrary()->ForgetWifiNetwork(service_path); + CrosLibrary::Get()->GetNetworkLibrary()->ForgetNetwork(service_path); AutomationJSONReply(this, reply_message).SendSuccess(NULL); } diff --git a/chrome/browser/chromeos/cros/mock_network_library.h b/chrome/browser/chromeos/cros/mock_network_library.h index a71dfc9..922e2c5 100644 --- a/chrome/browser/chromeos/cros/mock_network_library.h +++ b/chrome/browser/chromeos/cros/mock_network_library.h @@ -61,6 +61,8 @@ class MockNetworkLibrary : public NetworkLibrary { MOCK_CONST_METHOD0(remembered_wifi_networks, const WifiNetworkVector&(void)); MOCK_CONST_METHOD0(cellular_networks, const CellularNetworkVector&(void)); MOCK_CONST_METHOD0(virtual_networks, const VirtualNetworkVector&(void)); + MOCK_CONST_METHOD0(remembered_virtual_networks, + const VirtualNetworkVector&(void)); MOCK_CONST_METHOD1(FindNetworkDeviceByPath, NetworkDevice*(const std::string&)); @@ -124,7 +126,7 @@ class MockNetworkLibrary : public NetworkLibrary { MOCK_METHOD0(HasRecentCellularPlanPayment, bool(void)); MOCK_METHOD1(DisconnectFromNetwork, void(const Network*)); - MOCK_METHOD1(ForgetWifiNetwork, void(const std::string&)); + MOCK_METHOD1(ForgetNetwork, void(const std::string&)); MOCK_METHOD2(SetNetworkProfile, void(const std::string&, NetworkProfileType)); MOCK_CONST_METHOD0(GetCellularHomeCarrierId, std::string(void)); diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index 2a4ac3c..b392c01 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -55,6 +55,8 @@ // remembered in the active Profile ("favorites"). // remembered_wifi_networks_: ordered vector of WifiNetwork* entries in // remembered_network_map_, in descending order of preference. +// remembered_virtual_networks_: ordered vector of VirtualNetwork* entries in +// remembered_network_map_, in descending order of preference. // // network_manager_monitor_: a handle to the libcros network Manager handler. // NetworkManagerStatusChanged: This handles all messages from the Manager. @@ -1165,15 +1167,23 @@ void Network::ParseInfo(const DictionaryValue* info) { << " Unhandled key: " << key; } } + CalculateUniqueId(); } void Network::EraseCredentials() { } +void Network::CalculateUniqueId() { + unique_id_ = name_; +} + bool Network::RequiresUserProfile() const { return false; } +void Network::CopyCredentialsFromRemembered(Network* remembered) { +} + void Network::SetValueProperty(const char* prop, Value* val) { DCHECK(prop); DCHECK(val); @@ -1404,6 +1414,7 @@ bool VirtualNetwork::ParseValue(int index, const Value* value) { void VirtualNetwork::ParseInfo(const DictionaryValue* info) { Network::ParseInfo(info); VLOG(1) << "VPN: " << name() + << " Server: " << server_hostname() << " Type: " << ProviderTypeToString(provider_type()); if (provider_type_ == PROVIDER_TYPE_L2TP_IPSEC_PSK) { if (!client_cert_id_.empty()) @@ -1418,10 +1429,32 @@ void VirtualNetwork::EraseCredentials() { WipeString(&user_passphrase_); } +void VirtualNetwork::CalculateUniqueId() { + std::string provider_type(ProviderTypeToString(provider_type_)); + unique_id_ = provider_type + "|" + server_hostname_; +} + bool VirtualNetwork::RequiresUserProfile() const { return true; } +void VirtualNetwork::CopyCredentialsFromRemembered(Network* remembered) { + DCHECK(remembered->type() == TYPE_VPN); + VirtualNetwork* remembered_vpn = static_cast<VirtualNetwork*>(remembered); + VLOG(1) << "Copy VPN credentials: " << name() + << " username: " << remembered_vpn->username(); + if (ca_cert_nss_.empty()) + ca_cert_nss_ = remembered_vpn->ca_cert_nss(); + if (psk_passphrase_.empty()) + psk_passphrase_ = remembered_vpn->psk_passphrase(); + if (client_cert_id_.empty()) + client_cert_id_ = remembered_vpn->client_cert_id(); + if (username_.empty()) + username_ = remembered_vpn->username(); + if (user_passphrase_.empty()) + user_passphrase_ = remembered_vpn->user_passphrase(); +} + bool VirtualNetwork::NeedMoreInfoToConnect() const { if (server_hostname_.empty() || username_.empty() || user_passphrase_.empty()) return true; @@ -1964,7 +1997,6 @@ WifiNetwork::WifiNetwork(const std::string& service_path) WifiNetwork::~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 @@ -2098,11 +2130,6 @@ 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_; @@ -2276,7 +2303,9 @@ bool WifiNetwork::IsPassphraseRequired() const { bool WifiNetwork::RequiresUserProfile() const { // 8021X requires certificates which are only stored for individual users. - if (encryption_ == SECURITY_8021X) + if (encryption_ == SECURITY_8021X && + (eap_method_ == EAP_METHOD_TLS || + !eap_client_cert_pkcs11_id().empty())) return true; return false; } @@ -2536,6 +2565,10 @@ class NetworkLibraryImpl : public NetworkLibrary { return virtual_networks_; } + virtual const VirtualNetworkVector& remembered_virtual_networks() const { + return remembered_virtual_networks_; + } + ///////////////////////////////////////////////////////////////////////////// virtual const NetworkDevice* FindNetworkDeviceByPath( @@ -2621,6 +2654,15 @@ class NetworkLibraryImpl : public NetworkLibrary { return NULL; } + Network* FindRememberedFromNetwork(const Network* network) const { + for (NetworkMap::const_iterator iter = remembered_network_map_.begin(); + iter != remembered_network_map_.end(); ++iter) { + if (iter->second->unique_id() == network->unique_id()) + return iter->second; + } + return NULL; + } + virtual Network* FindRememberedNetworkByPath(const std::string& path) const { NetworkMap::const_iterator iter = remembered_network_map_.find(path); if (iter != remembered_network_map_.end()) @@ -3164,11 +3206,11 @@ class NetworkLibraryImpl : public NetworkLibrary { } } - virtual void ForgetWifiNetwork(const std::string& service_path) { + virtual void ForgetNetwork(const std::string& service_path) { if (!EnsureCrosLoaded()) return; // Remove network from remembered list and notify observers. - DeleteRememberedWifiNetwork(service_path); + DeleteRememberedNetwork(service_path); NotifyNetworkManagerChanged(true); // Forced update. } @@ -3671,7 +3713,7 @@ class NetworkLibraryImpl : public NetworkLibrary { if (service_path) { if (!info) { // Remembered network no longer exists. - networklib->DeleteRememberedWifiNetwork(std::string(service_path)); + networklib->DeleteRememberedNetwork(std::string(service_path)); } else { DCHECK_EQ(info->GetType(), Value::TYPE_DICTIONARY); const DictionaryValue* dict = static_cast<const DictionaryValue*>(info); @@ -3825,31 +3867,39 @@ class NetworkLibraryImpl : public NetworkLibrary { delete network; } - void AddRememberedWifiNetwork(WifiNetwork* wifi) { + void AddRememberedNetwork(Network* network) { std::pair<NetworkMap::iterator,bool> result = remembered_network_map_.insert( - std::make_pair(wifi->service_path(), wifi)); + std::make_pair(network->service_path(), network)); DCHECK(result.second); // Should only get called with new network. - remembered_wifi_networks_.push_back(wifi); + if (network->type() == TYPE_WIFI) { + remembered_wifi_networks_.push_back( + static_cast<WifiNetwork*>(network)); + } else if (network->type() == TYPE_VPN) { + remembered_virtual_networks_.push_back( + static_cast<VirtualNetwork*>(network)); + } else { + NOTREACHED(); + } // Find service path in profiles. Flimflam does not set the Profile // property for remembered networks, only active networks. for (NetworkProfileList::iterator iter = profile_list_.begin(); iter != profile_list_.end(); ++iter) { NetworkProfile& profile = *iter; - if (profile.services.find(wifi->service_path()) != + if (profile.services.find(network->service_path()) != profile.services.end()) { - wifi->set_profile_path(profile.path); - wifi->set_profile_type(profile.type); - VLOG(1) << "AddRememberedWifiNetwork: " << wifi->service_path() + network->set_profile_path(profile.path); + network->set_profile_type(profile.type); + VLOG(1) << "AddRememberedNetwork: " << network->service_path() << " Profile: " << profile.path; break; } } - DCHECK(!wifi->profile_path().empty()) - << "Wifi service path not in any profile: " << wifi->service_path(); + DCHECK(!network->profile_path().empty()) + << "Service path not in any profile: " << network->service_path(); } - void DeleteRememberedWifiNetwork(const std::string& service_path) { + void DeleteRememberedNetwork(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: " @@ -3860,12 +3910,22 @@ class NetworkLibraryImpl : public NetworkLibrary { // Delete remembered network from lists. Network* remembered_network = found->second; remembered_network_map_.erase(found); - WifiNetworkVector::iterator iter = std::find( - remembered_wifi_networks_.begin(), remembered_wifi_networks_.end(), - remembered_network); - if (iter != remembered_wifi_networks_.end()) - remembered_wifi_networks_.erase(iter); + if (remembered_network->type() == TYPE_WIFI) { + WifiNetworkVector::iterator iter = std::find( + remembered_wifi_networks_.begin(), + remembered_wifi_networks_.end(), + remembered_network); + if (iter != remembered_wifi_networks_.end()) + remembered_wifi_networks_.erase(iter); + } else if (remembered_network->type() == TYPE_VPN) { + VirtualNetworkVector::iterator iter = std::find( + remembered_virtual_networks_.begin(), + remembered_virtual_networks_.end(), + remembered_network); + if (iter != remembered_virtual_networks_.end()) + remembered_virtual_networks_.erase(iter); + } // Delete remembered network from all profiles it is in. for (NetworkProfileList::iterator iter = profile_list_.begin(); iter != profile_list_.end(); ++iter) { @@ -4094,6 +4154,11 @@ class NetworkLibraryImpl : public NetworkLibrary { UpdateActiveNetwork(network); + // Copy remembered credentials if required. + Network* remembered = FindRememberedFromNetwork(network); + if (remembered) + network->CopyCredentialsFromRemembered(remembered); + // Find and erase entry in update_requests, and set network priority. PriorityMap::iterator found2 = network_update_requests_.find(service_path); if (found2 != network_update_requests_.end()) { @@ -4120,31 +4185,49 @@ class NetworkLibraryImpl : public NetworkLibrary { // remembered type. Called from RememberedNetworkServiceUpdate. Network* ParseRememberedNetwork(const std::string& service_path, const DictionaryValue* info) { - Network* network; + Network* remembered; NetworkMap::iterator found = remembered_network_map_.find(service_path); if (found != remembered_network_map_.end()) { - network = found->second; + remembered = found->second; } else { ConnectionType type = ParseTypeFromDictionary(info); - if (type == TYPE_WIFI) { - network = CreateNewNetwork(type, service_path); - WifiNetwork* wifi = static_cast<WifiNetwork*>(network); - AddRememberedWifiNetwork(wifi); + if (type == TYPE_WIFI || type == TYPE_VPN) { + remembered = CreateNewNetwork(type, service_path); + AddRememberedNetwork(remembered); } else { VLOG(1) << "Ignoring remembered network: " << service_path << " Type: " << ConnectionTypeToString(type); return NULL; } } - network->ParseInfo(info); // virtual. + remembered->ParseInfo(info); // virtual. - SetProfileTypeFromPath(network); + SetProfileTypeFromPath(remembered); - VLOG(1) << "ParseRememberedNetwork: " << network->name() - << " Path: " << network->service_path() - << " Profile: " << network->profile_path_; + VLOG(1) << "ParseRememberedNetwork: " << remembered->name() + << " Path: " << remembered->service_path() + << " Profile: " << remembered->profile_path_; NotifyNetworkManagerChanged(false); // Not forced. - return network; + + if (remembered->type() == TYPE_VPN) { + // VPNs are only stored in profiles. If we don't have a network for it, + // request one. + if (!FindNetworkFromRemembered(remembered)) { + VirtualNetwork* vpn = static_cast<VirtualNetwork*>(remembered); + std::string provider_type = ProviderTypeToString(vpn->provider_type()); + VLOG(1) << "Requesting VPN: " << vpn->name() + << " Server: " << vpn->server_hostname() + << " Type: " << provider_type; + RequestVirtualNetwork( + vpn->name().c_str(), + vpn->server_hostname().c_str(), + provider_type.c_str(), + NetworkServiceUpdate, + this); + } + } + + return remembered; } void SetProfileType(Network* network, NetworkProfileType type) { @@ -4206,6 +4289,7 @@ class NetworkLibraryImpl : public NetworkLibrary { void ClearRememberedNetworks() { remembered_network_map_.clear(); remembered_wifi_networks_.clear(); + remembered_virtual_networks_.clear(); } void DeleteNetworks() { @@ -4698,18 +4782,6 @@ class NetworkLibraryImpl : public NetworkLibrary { cellular2->set_network_technology(NETWORK_TECHNOLOGY_UMTS); AddNetwork(cellular2); - // Remembered Networks - DeleteRememberedNetworks(); - NetworkProfile profile("default", PROFILE_SHARED); - profile.services.insert("fw2"); - profile_list_.push_back(profile); - WifiNetwork* remembered_wifi2 = new WifiNetwork("fw2"); - remembered_wifi2->set_name("Fake Wifi 2"); - remembered_wifi2->set_strength(70); - remembered_wifi2->set_connected(true); - remembered_wifi2->set_encryption(SECURITY_WEP); - AddRememberedWifiNetwork(remembered_wifi2); - // VPNs. VirtualNetwork* vpn1 = new VirtualNetwork("fv1"); vpn1->set_name("Fake VPN Provider 1"); @@ -4736,6 +4808,24 @@ class NetworkLibraryImpl : public NetworkLibrary { active_virtual_ = vpn2; + // Remembered Networks + DeleteRememberedNetworks(); + NetworkProfile profile("default", PROFILE_SHARED); + profile.services.insert("fw2"); + profile.services.insert("fv2"); + profile_list_.push_back(profile); + WifiNetwork* remembered_wifi2 = new WifiNetwork("fw2"); + remembered_wifi2->set_name("Fake Wifi 2"); + remembered_wifi2->set_encryption(SECURITY_WEP); + AddRememberedNetwork(remembered_wifi2); + VirtualNetwork* remembered_vpn2 = new VirtualNetwork("fv2"); + remembered_vpn2->set_name("Fake VPN Provider 2"); + remembered_vpn2->set_server_hostname("vpn2server.fake.com"); + remembered_vpn2->set_provider_type( + VirtualNetwork::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); + remembered_vpn2->set_connected(true); + AddRememberedNetwork(remembered_vpn2); + wifi_scanning_ = false; offline_mode_ = false; } @@ -4812,6 +4902,9 @@ class NetworkLibraryImpl : public NetworkLibrary { // The current connected (or connecting) virtual network. VirtualNetwork* active_virtual_; + // The remembered virtual networks. + VirtualNetworkVector remembered_virtual_networks_; + // The path of the active profile (for retrieving remembered services). std::string active_profile_path_; @@ -4938,6 +5031,9 @@ class NetworkLibraryStubImpl : public NetworkLibrary { virtual const VirtualNetworkVector& virtual_networks() const { return virtual_networks_; } + virtual const VirtualNetworkVector& remembered_virtual_networks() const { + return virtual_networks_; + } virtual bool has_cellular_networks() const { return cellular_networks_.begin() != cellular_networks_.end(); } @@ -5020,7 +5116,7 @@ class NetworkLibraryStubImpl : public NetworkLibrary { virtual void SignalCellularPlanPayment() {} virtual bool HasRecentCellularPlanPayment() { return false; } virtual void DisconnectFromNetwork(const Network* network) {} - virtual void ForgetWifiNetwork(const std::string& service_path) {} + virtual void ForgetNetwork(const std::string& service_path) {} virtual void SetNetworkProfile(const std::string& service_path, NetworkProfileType type) {} virtual std::string GetCellularHomeCarrierId() const { return std::string(); } diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index 45983e8..a19988e 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -327,7 +327,7 @@ class Network { // 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(). + // that. See ForgetNetwork(). void SetAutoConnect(bool auto_connect); @@ -344,6 +344,9 @@ class Network { // Return true if the network must be in the user profile (e.g. has certs). virtual bool RequiresUserProfile() const; + // Copy any credentials from a remembered network that are unset in |this|. + virtual void CopyCredentialsFromRemembered(Network* remembered); + // Static helper function. static bool IsConnectingState(ConnectionState state) { return (state == STATE_ASSOCIATION || @@ -365,6 +368,9 @@ class Network { // Erase cached credentials, used when "Save password" is unchecked. virtual void EraseCredentials(); + // Calculate a unique identifier for the network. + virtual void CalculateUniqueId(); + // Methods to asynchronously set network service properties virtual void SetStringProperty(const char* prop, const std::string& str, std::string* dest); @@ -479,6 +485,7 @@ class VirtualNetwork : public Network { // Network overrides. virtual bool RequiresUserProfile() const; + virtual void CopyCredentialsFromRemembered(Network* remembered); // Public getters. bool NeedMoreInfoToConnect() const; @@ -496,6 +503,7 @@ class VirtualNetwork : public Network { virtual bool ParseValue(int index, const Value* value); virtual void ParseInfo(const DictionaryValue* info); virtual void EraseCredentials(); + virtual void CalculateUniqueId(); // VirtualNetwork private methods. bool ParseProviderValue(int index, const Value* value); @@ -730,12 +738,10 @@ class WifiNetwork : public WirelessNetwork { private: // Network overrides. virtual void EraseCredentials(); + virtual void CalculateUniqueId(); // WirelessNetwork overrides. virtual bool ParseValue(int index, const Value* value); - virtual void ParseInfo(const DictionaryValue* info); - - void CalculateUniqueId(); void set_encryption(ConnectionSecurity encryption) { encryption_ = encryption; @@ -1012,6 +1018,9 @@ class NetworkLibrary { // Returns the current list of virtual networks. virtual const VirtualNetworkVector& virtual_networks() const = 0; + // Returns the current list of virtual networks. + virtual const VirtualNetworkVector& remembered_virtual_networks() const = 0; + // Return a pointer to the device, if it exists, or NULL. virtual const NetworkDevice* FindNetworkDeviceByPath( const std::string& path) const = 0; @@ -1040,8 +1049,8 @@ 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. + // Returns the visible network corresponding to the remembered network, + // or NULL if the remembered network is not visible. virtual Network* FindNetworkFromRemembered( const Network* remembered) const = 0; @@ -1162,8 +1171,8 @@ class NetworkLibrary { // Disconnect from the specified network. virtual void DisconnectFromNetwork(const Network* network) = 0; - // Forget the wifi network corresponding to service_path. - virtual void ForgetWifiNetwork(const std::string& service_path) = 0; + // Forget the network corresponding to service_path. + virtual void ForgetNetwork(const std::string& service_path) = 0; // Move the network to the shared/global profile. virtual void SetNetworkProfile(const std::string& service_path, 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 e3158aad..64f1203 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -802,6 +802,8 @@ void InternetOptionsHandler::PopulateVPNDetails( const chromeos::VirtualNetwork* vpn, DictionaryValue* dictionary) { dictionary->SetString("service_name", vpn->name()); + bool remembered = (vpn->profile_type() != chromeos::PROFILE_NONE); + dictionary->SetBoolean("remembered", remembered); dictionary->SetString("server_hostname", vpn->server_hostname()); dictionary->SetString("provider_type", vpn->GetProviderTypeString()); dictionary->SetString("username", vpn->username()); @@ -867,7 +869,7 @@ void InternetOptionsHandler::HandleWifiButtonClick( const std::string& command) { chromeos::WifiNetwork* wifi = NULL; if (command == "forget") { - cros_->ForgetWifiNetwork(service_path); + cros_->ForgetNetwork(service_path); } else if (service_path == kOtherNetworksFakePath) { // Other wifi networks. CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_WIFI)); @@ -912,8 +914,10 @@ void InternetOptionsHandler::HandleVPNButtonClick( const std::string& service_path, const std::string& command) { chromeos::VirtualNetwork* network = NULL; - // TODO(altimofeev): verify if service_path in condition is correct. - if (service_path == kOtherNetworksFakePath) { + if (command == "forget") { + cros_->ForgetNetwork(service_path); + } else if (service_path == kOtherNetworksFakePath) { + // TODO(altimofeev): verify if service_path in condition is correct. // Other VPN networks. CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_VPN)); } else if ((network = cros_->FindVirtualNetworkByPath(service_path))) { @@ -1142,35 +1146,22 @@ ListValue* InternetOptionsHandler::GetVPNList() { } ListValue* InternetOptionsHandler::GetRememberedList() { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ListValue* list = new ListValue(); - const chromeos::WifiNetworkVector& remembered_wifi_networks = - cros_->remembered_wifi_networks(); - for (chromeos::WifiNetworkVector::const_iterator rit = - remembered_wifi_networks.begin(); - rit != remembered_wifi_networks.end(); ++rit) { + cros_->remembered_wifi_networks().begin(); + rit != cros_->remembered_wifi_networks().end(); ++rit) { chromeos::WifiNetwork* remembered = *rit; chromeos::WifiNetwork* wifi = static_cast<chromeos::WifiNetwork*>( cros_->FindNetworkFromRemembered(remembered)); - const SkBitmap* icon = wifi ? - chromeos::NetworkMenu::IconForNetworkStrength(wifi) : - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0); - // 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 = remembered->encrypted() ? - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL; // Set in_active_profile. bool shared = cros_->HasMultipleProfiles() && remembered->profile_type() == chromeos::PROFILE_SHARED; list->Append(GetNetwork( remembered->service_path(), - chromeos::NetworkMenu::IconForDisplay( - icon, bottom_right_badge, NULL, NULL), + chromeos::NetworkMenu::IconForNetwork(wifi ? wifi : remembered), remembered->name(), wifi ? wifi->connecting() : false, wifi ? wifi->connected() : false, @@ -1181,6 +1172,32 @@ ListValue* InternetOptionsHandler::GetRememberedList() { chromeos::ACTIVATION_STATE_UNKNOWN, false)); } + + for (chromeos::VirtualNetworkVector::const_iterator rit = + cros_->remembered_virtual_networks().begin(); + rit != cros_->remembered_virtual_networks().end(); ++rit) { + chromeos::VirtualNetwork* remembered = *rit; + chromeos::VirtualNetwork* vpn = static_cast<chromeos::VirtualNetwork*>( + cros_->FindNetworkFromRemembered(remembered)); + + // Set in_active_profile. + bool shared = + cros_->HasMultipleProfiles() && + remembered->profile_type() == chromeos::PROFILE_SHARED; + list->Append(GetNetwork( + remembered->service_path(), + chromeos::NetworkMenu::IconForNetwork(vpn ? vpn : remembered), + remembered->name(), + vpn ? vpn->connecting() : false, + vpn ? vpn->connected() : false, + true, + chromeos::TYPE_WIFI, + true, + shared, + chromeos::ACTIVATION_STATE_UNKNOWN, + false)); + } + return list; } |