diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-25 02:05:31 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-25 02:05:31 +0000 |
commit | 2da92aa19dae47b40efa883ef15237bb8250c75d (patch) | |
tree | ba8585d31fe7d1a49b543db9719d13099817db25 | |
parent | cac523e1527ca56ea9c94b232402fb71cdb2acf0 (diff) | |
download | chromium_src-2da92aa19dae47b40efa883ef15237bb8250c75d.zip chromium_src-2da92aa19dae47b40efa883ef15237bb8250c75d.tar.gz chromium_src-2da92aa19dae47b40efa883ef15237bb8250c75d.tar.bz2 |
Forget newly connected networks when not owner.
BUG=chromium-os:8552
TEST=See issue, but note: networks should only be remembered if the owner is nogged in, i.e. 'guest' apples to any non owner login.
Review URL: http://codereview.chromium.org/5278011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67369 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/cros/network_library.cc | 31 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library.h | 8 |
2 files changed, 36 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index ca56b63..273e3a3 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -16,6 +16,7 @@ #include "base/values.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/common/time_format.h" #include "grit/generated_resources.h" @@ -334,6 +335,13 @@ std::string Network::GetErrorString() const { return l10n_util::GetStringUTF8(IDS_CHROMEOS_NETWORK_STATE_UNRECOGNIZED); } +std::string Network::GetBaseServicePath() const { + size_t idx = service_path_.find_last_of('/'); + if (idx == std::string::npos) + return service_path_; + return service_path_.substr(idx + 1); +} + void Network::InitIPAddress() { ip_address_.clear(); // If connected, get ip config. @@ -1058,6 +1066,15 @@ class NetworkLibraryImpl : public NetworkLibrary { wifi->set_connecting(true); wifi_ = wifi; } + // If we are not the owner, and we are providing a password, + // flag the network to be forgotten if we connect to it. + // TODO(stevenjb): Remove this once flimflam handles profiles correctly. + if (!UserManager::Get()->current_user_is_owner()) { + if (!password.empty() || !certpath.empty()) { + std::string path = network->GetBaseServicePath(); + networks_to_forget_.insert(path); + } + } NotifyNetworkManagerChanged(); return true; } else { @@ -1496,7 +1513,16 @@ class NetworkLibraryImpl : public NetworkLibrary { << " fav=" << service->favorite << " auto=" << service->auto_connect; if (service->type == TYPE_WIFI) { - remembered_wifi_networks_.push_back(new WifiNetwork(service)); + WifiNetwork* wifi = new WifiNetwork(service); + remembered_wifi_networks_.push_back(wifi); + // If we are not the owner, we may need to forget this network. + std::string path = wifi->GetBaseServicePath(); + std::set<std::string>::iterator iter = + networks_to_forget_.find(path); + if (iter != networks_to_forget_.end()) { + ForgetWifiNetwork(wifi->service_path()); + networks_to_forget_.erase(iter); + } } } } @@ -1865,6 +1891,9 @@ class NetworkLibraryImpl : public NetworkLibrary { // Delayed task to retrieve the network information. CancelableTask* update_task_; + // List of networks to forget when not the owner. + std::set<std::string> networks_to_forget_; + DISALLOW_COPY_AND_ASSIGN(NetworkLibraryImpl); }; diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index 41868f2..d562e2b 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -68,6 +68,10 @@ class Network { // Return a string representation of the error code. std::string GetErrorString() const; + // Strip the base path from service_path_ and return the result. + // Useful for comparing active networks with remembered networks. + std::string GetBaseServicePath() const; + protected: Network() : type_(TYPE_UNKNOWN), @@ -532,8 +536,8 @@ class NetworkLibrary { // Returns the current list of cellular networks. virtual const CellularNetworkVector& cellular_networks() const = 0; - // Search the current list of networks by path and if the network - // is available, copy the result and return true. + // Search the list of networks by path and if the network is available, + // return a pointer to the network. virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) = 0; virtual CellularNetwork* FindCellularNetworkByPath( const std::string& path) = 0; |