summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 00:54:34 +0000
committerstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 00:54:34 +0000
commit2f5a9a85c18ab34db218d3704a232f6147392eff (patch)
treef59f50d1f03a1c471d03c6bf3e8398b11c984ec8
parentbe8fb96d75b6b86e58b451533a120f2af048f347 (diff)
downloadchromium_src-2f5a9a85c18ab34db218d3704a232f6147392eff.zip
chromium_src-2f5a9a85c18ab34db218d3704a232f6147392eff.tar.gz
chromium_src-2f5a9a85c18ab34db218d3704a232f6147392eff.tar.bz2
Cleanup wifi connect and password code
BUG=chromium-os:11941 TEST=Run Network connection tests. See issue for detailed test. Review URL: http://codereview.chromium.org/6708012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78786 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/cros/mock_network_library.h4
-rw-r--r--chrome/browser/chromeos/cros/network_library.cc218
-rw-r--r--chrome/browser/chromeos/cros/network_library.h50
-rw-r--r--chrome/browser/chromeos/login/network_screen.h1
-rw-r--r--chrome/browser/chromeos/network_list.cc155
-rw-r--r--chrome/browser/chromeos/network_list.h120
-rw-r--r--chrome/browser/chromeos/network_login_observer.cc4
-rw-r--r--chrome/browser/chromeos/options/wifi_config_view.cc79
-rw-r--r--chrome/browser/chromeos/options/wifi_config_view.h11
-rw-r--r--chrome/browser/chromeos/status/network_menu.cc4
-rw-r--r--chrome/browser/chromeos/webui/internet_options_handler.cc40
-rw-r--r--chrome/browser/chromeos/webui/mobile_setup_ui.cc30
-rw-r--r--chrome/chrome_browser.gypi2
13 files changed, 247 insertions, 471 deletions
diff --git a/chrome/browser/chromeos/cros/mock_network_library.h b/chrome/browser/chromeos/cros/mock_network_library.h
index 66cb71a..75e358b 100644
--- a/chrome/browser/chromeos/cros/mock_network_library.h
+++ b/chrome/browser/chromeos/cros/mock_network_library.h
@@ -57,6 +57,8 @@ class MockNetworkLibrary : public NetworkLibrary {
MOCK_CONST_METHOD1(FindNetworkDeviceByPath,
NetworkDevice*(const std::string&));
+ MOCK_CONST_METHOD1(FindNetworkByPath,
+ Network*(const std::string&));
MOCK_CONST_METHOD1(FindWifiNetworkByPath,
WifiNetwork*(const std::string&));
MOCK_CONST_METHOD1(FindCellularNetworkByPath,
@@ -76,7 +78,7 @@ class MockNetworkLibrary : public NetworkLibrary {
const std::string&,
const std::string&,
bool));
- MOCK_METHOD1(ConnectToCellularNetwork, void(const CellularNetwork*));
+ MOCK_METHOD1(ConnectToCellularNetwork, void(CellularNetwork*));
MOCK_METHOD0(SignalCellularPlanPayment, void(void));
MOCK_METHOD0(HasRecentCellularPlanPayment, bool(void));
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index 551a21b..e97b838 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -202,6 +202,8 @@ const char* kErrorNeedEvdo = "need-evdo";
const char* kErrorNeedHomeNetwork = "need-home-network";
const char* kErrorOtaspFailed = "otasp-failed";
const char* kErrorAaaFailed = "aaa-failed";
+// Flimflam error messages.
+const char* kErrorPassphraseRequiredMsg = "Passphrase required";
const char* kUnknownString = "UNKNOWN";
@@ -1210,8 +1212,17 @@ bool WifiNetwork::ParseValue(int index, const Value* value) {
}
break;
}
- case PROPERTY_INDEX_PASSPHRASE:
- return value->GetAsString(&passphrase_);
+ case PROPERTY_INDEX_PASSPHRASE: {
+ std::string passphrase;
+ if (value->GetAsString(&passphrase)) {
+ // Only store the passphrase if we are the owner.
+ // TODO(stevenjb): Remove this when chromium-os:12948 is resolved.
+ if (chromeos::UserManager::Get()->current_user_is_owner())
+ passphrase_ = passphrase;
+ return true;
+ }
+ break;
+ }
case PROPERTY_INDEX_PASSPHRASE_REQUIRED:
return value->GetAsBoolean(&passphrase_required_);
case PROPERTY_INDEX_IDENTITY:
@@ -1224,8 +1235,22 @@ bool WifiNetwork::ParseValue(int index, const Value* value) {
return false;
}
+const std::string& WifiNetwork::GetPassphrase() const {
+ if (!user_passphrase_.empty())
+ return user_passphrase_;
+ return passphrase_;
+}
+
void WifiNetwork::SetPassphrase(const std::string& passphrase) {
- passphrase_ = 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())
+ user_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);
}
@@ -1392,7 +1417,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
if (is_locked_)
return;
is_locked_ = true;
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(true); // Forced update.
}
virtual void Unlock() {
@@ -1400,7 +1425,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
if (!is_locked_)
return;
is_locked_ = false;
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(true); // Forced update.
}
virtual bool IsLocked() {
@@ -1510,14 +1535,34 @@ class NetworkLibraryImpl : public NetworkLibrary {
return NULL;
}
- virtual WifiNetwork* FindWifiNetworkByPath(
- const std::string& path) const {
- return GetWifiNetworkByPath(path);
+ virtual Network* FindNetworkByPath(const std::string& path) const {
+ NetworkMap::const_iterator iter = network_map_.find(path);
+ if (iter != network_map_.end())
+ return iter->second;
+ return NULL;
+ }
+
+ WirelessNetwork* FindWirelessNetworkByPath(const std::string& path) const {
+ Network* network = FindNetworkByPath(path);
+ if (network &&
+ (network->type() == TYPE_WIFI || network->type() == TYPE_CELLULAR))
+ return static_cast<WirelessNetwork*>(network);
+ return NULL;
+ }
+
+ virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const {
+ Network* network = FindNetworkByPath(path);
+ if (network && network->type() == TYPE_WIFI)
+ return static_cast<WifiNetwork*>(network);
+ return NULL;
}
virtual CellularNetwork* FindCellularNetworkByPath(
const std::string& path) const {
- return GetCellularNetworkByPath(path);
+ Network* network = FindNetworkByPath(path);
+ if (network && network->type() == TYPE_CELLULAR)
+ return static_cast<CellularNetwork*>(network);
+ return NULL;
}
virtual const CellularDataPlanVector* GetDataPlans(
@@ -1581,19 +1626,27 @@ class NetworkLibraryImpl : public NetworkLibrary {
NetworkLibraryImpl* networklib = static_cast<NetworkLibraryImpl*>(object);
DCHECK(networklib);
- if (error != NETWORK_METHOD_ERROR_NONE) {
- LOG(ERROR) << "Error from ServiceConnect callback: "
- << error_message;
+ WirelessNetwork* wireless = networklib->FindWirelessNetworkByPath(path);
+ if (!wireless) {
+ LOG(ERROR) << "No wireless network for path: " << path;
return;
}
- WirelessNetwork* wireless = networklib->GetWirelessNetworkByPath(path);
- if (!wireless) {
- LOG(ERROR) << "No wireless network for path: " << path;
+ if (error != NETWORK_METHOD_ERROR_NONE) {
+ if (error_message &&
+ strcmp(error_message, kErrorPassphraseRequiredMsg) == 0) {
+ // This will trigger the connection failed notification.
+ // TODO(stevenjb): Remove if chromium-os:13203 gets fixed.
+ wireless->set_state(STATE_FAILURE);
+ wireless->set_error(ERROR_BAD_PASSPHRASE);
+ networklib->NotifyNetworkManagerChanged(true); // Forced update.
+ } else {
+ LOG(WARNING) << "Error from ServiceConnect callback: "
+ << error_message;
+ }
return;
}
- wireless->set_connecting(true);
// Update local cache and notify listeners.
if (wireless->type() == TYPE_WIFI)
networklib->active_wifi_ = static_cast<WifiNetwork *>(wireless);
@@ -1606,36 +1659,40 @@ class NetworkLibraryImpl : public NetworkLibrary {
// TODO(stevenjb): flimflam should do this automatically.
networklib->RequestRememberedNetworksUpdate();
// Notify observers.
- networklib->NotifyNetworkManagerChanged();
+ networklib->NotifyNetworkManagerChanged(false); // Not forced.
networklib->NotifyUserConnectionInitiated(wireless);
}
- void CallConnectToNetworkForWifi(const std::string& service_path) {
- RequestNetworkServiceConnect(service_path.c_str(),
+ void CallConnectToNetworkForWifi(WifiNetwork* wifi) {
+ // If we haven't correctly set the parameters (e.g. passphrase), flimflam
+ // might fail without attempting a connection. In order to trigger any
+ // notifications, set the state locally and notify observers.
+ // TODO(stevenjb): Remove if chromium-os:13203 gets fixed.
+ wifi->set_connecting(true);
+ NotifyNetworkManagerChanged(true); // Forced update.
+ RequestNetworkServiceConnect(wifi->service_path().c_str(),
WirelessConnectCallback, this);
}
- // Use this when the code needs to cache a copy of the WifiNetwork and
- // expects |network|->error_ to be set on failure.
- virtual void ConnectToWifiNetwork(WifiNetwork* network) {
- DCHECK(network);
- if (!EnsureCrosLoaded() || !network)
+ virtual void ConnectToWifiNetwork(WifiNetwork* wifi) {
+ DCHECK(wifi);
+ if (!EnsureCrosLoaded() || !wifi)
return;
- CallConnectToNetworkForWifi(network->service_path());
+ CallConnectToNetworkForWifi(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 = GetWifiNetworkByPath(service_path);
+ WifiNetwork* wifi = FindWifiNetworkByPath(service_path);
if (!wifi) {
LOG(WARNING) << "Attempt to connect to non existing network: "
<< service_path;
return;
}
- CallConnectToNetworkForWifi(service_path);
+ CallConnectToNetworkForWifi(wifi);
}
// Use this to connect to an unlisted wifi network.
@@ -1643,7 +1700,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
// The connection attempt will occur in the callback.
virtual void ConnectToWifiNetwork(ConnectionSecurity security,
const std::string& ssid,
- const std::string& password,
+ const std::string& passphrase,
const std::string& identity,
const std::string& certpath,
bool auto_connect) {
@@ -1654,7 +1711,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
WifiServiceUpdateAndConnect,
this);
// Store the connection data to be used by the callback.
- connect_data_.SetData(ssid, password, identity, certpath, auto_connect);
+ connect_data_.SetData(ssid, passphrase, identity, certpath, auto_connect);
}
// Callback
@@ -1682,18 +1739,18 @@ class NetworkLibraryImpl : public NetworkLibrary {
}
WifiNetwork *wifi = static_cast<WifiNetwork *>(network);
- if (!data.password.empty())
- wifi->SetPassphrase(data.password);
+ if (!data.passphrase.empty())
+ wifi->SetPassphrase(data.passphrase);
if (!data.identity.empty())
wifi->SetIdentity(data.identity);
if (!data.certpath.empty())
wifi->SetCertPath(data.certpath);
wifi->SetAutoConnect(data.auto_connect);
- CallConnectToNetworkForWifi(wifi->service_path());
+ CallConnectToNetworkForWifi(wifi);
}
- virtual void ConnectToCellularNetwork(const CellularNetwork* network) {
+ virtual void ConnectToCellularNetwork(CellularNetwork* network) {
DCHECK(network);
if (!EnsureCrosLoaded() || !network)
return;
@@ -1721,7 +1778,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
if (DisconnectFromNetwork(network->service_path().c_str())) {
// Update local cache and notify listeners.
WirelessNetwork* wireless =
- GetWirelessNetworkByPath(network->service_path());
+ FindWirelessNetworkByPath(network->service_path());
if (wireless) {
wireless->set_connected(false);
if (wireless == active_wifi_)
@@ -1729,7 +1786,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
else if (wireless == active_cellular_)
active_cellular_ = NULL;
}
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(false); // Not forced.
}
}
@@ -1744,7 +1801,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
// https://crosbug.com/9295
if (DeleteRememberedService(service_path.c_str())) {
DeleteRememberedNetwork(service_path);
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(false); // Not forced.
}
}
@@ -1989,7 +2046,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
case PROPERTY_INDEX_OFFLINE_MODE: {
DCHECK_EQ(value->GetType(), Value::TYPE_BOOLEAN);
value->GetAsBoolean(&offline_mode_);
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(false); // Not forced.
break;
}
case PROPERTY_INDEX_ACTIVE_PROFILE: {
@@ -2146,7 +2203,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
}
}
*bitfieldp = bitfield;
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(false); // Not forced.
}
void UpdateAvailableTechnologies(const ListValue* technologies) {
@@ -2442,11 +2499,8 @@ class NetworkLibraryImpl : public NetworkLibrary {
Network* ParseNetwork(const std::string& service_path,
const DictionaryValue* info) {
- Network* network;
- NetworkMap::iterator found = network_map_.find(service_path);
- if (found != network_map_.end()) {
- network = found->second;
- } else {
+ Network* network = FindNetworkByPath(service_path);
+ if (!network) {
ConnectionType type = ParseTypeFromDictionary(info);
network = CreateNewNetwork(type, service_path);
AddNetwork(network);
@@ -2466,12 +2520,13 @@ class NetworkLibraryImpl : public NetworkLibrary {
wifi_scanning_ = false;
}
} else {
- LOG(WARNING) << "ParseNetwork called with no update request entry: "
- << service_path;
+ // TODO(stevenjb): Enable warning once UpdateNetworkServiceList is fixed.
+ // LOG(WARNING) << "ParseNetwork called with no update request entry: "
+ // << service_path;
}
VLOG(1) << "ParseNetwork:" << network->name();
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(false); // Not forced.
return network;
}
@@ -2488,7 +2543,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
}
network->ParseInfo(info); // virtual.
VLOG(1) << "ParseRememberedNetwork:" << network->name();
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(false); // Not forced.
return network;
}
@@ -2569,35 +2624,11 @@ class NetworkLibraryImpl : public NetworkLibrary {
}
device->ParseInfo(info);
VLOG(1) << "ParseNetworkDevice:" << device->name();
- NotifyNetworkManagerChanged();
+ NotifyNetworkManagerChanged(false); // Not forced.
}
////////////////////////////////////////////////////////////////////////////
- WirelessNetwork* GetWirelessNetworkByPath(const std::string& path) const {
- NetworkMap::const_iterator iter = network_map_.find(path);
- if (iter != network_map_.end()) {
- Network* network = iter->second;
- if (network->type() == TYPE_WIFI || network->type() == TYPE_CELLULAR)
- return static_cast<WirelessNetwork*>(network);
- }
- return NULL;
- }
-
- WifiNetwork* GetWifiNetworkByPath(const std::string& path) const {
- WirelessNetwork* network = GetWirelessNetworkByPath(path);
- if (network && network->type() == TYPE_WIFI)
- return static_cast<WifiNetwork*>(network);
- return NULL;
- }
-
- CellularNetwork* GetCellularNetworkByPath(const std::string& path) const {
- WirelessNetwork* network = GetWirelessNetworkByPath(path);
- if (network && network->type() == TYPE_CELLULAR)
- return static_cast<CellularNetwork*>(network);
- return NULL;
- }
-
void EnableNetworkDeviceType(ConnectionType device, bool enable) {
if (!EnsureCrosLoaded())
return;
@@ -2623,15 +2654,23 @@ class NetworkLibraryImpl : public NetworkLibrary {
// We call this any time something in NetworkLibrary changes.
// TODO(stevenjb): We should consider breaking this into multiplie
// notifications, e.g. connection state, devices, services, etc.
- void NotifyNetworkManagerChanged() {
+ void NotifyNetworkManagerChanged(bool force_update) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Limit the frequency of notifications.
- if (notify_task_)
+ // Cancel any pending signals.
+ if (notify_task_) {
notify_task_->Cancel();
- notify_task_ = NewRunnableMethod(
- this, &NetworkLibraryImpl::SignalNetworkManagerObservers);
- BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, notify_task_,
- kNetworkNotifyDelayMs);
+ notify_task_ = NULL;
+ }
+ if (force_update) {
+ // Signal observers now.
+ SignalNetworkManagerObservers();
+ } else {
+ // Schedule a deleayed signal to limit the frequency of notifications.
+ notify_task_ = NewRunnableMethod(
+ this, &NetworkLibraryImpl::SignalNetworkManagerObservers);
+ BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, notify_task_,
+ kNetworkNotifyDelayMs);
+ }
}
void SignalNetworkManagerObservers() {
@@ -2677,10 +2716,9 @@ class NetworkLibraryImpl : public NetworkLibrary {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (key == NULL || value == NULL)
return;
- NetworkMap::iterator iter = network_map_.find(path);
- if (iter != network_map_.end()) {
- VLOG(1) << "UpdateNetworkStatus: " << path << "." << key;
- Network* network = iter->second;
+ Network* network = FindNetworkByPath(path);
+ if (network) {
+ VLOG(1) << "UpdateNetworkStatus: " << network->name() << "." << key;
// Note: ParseValue is virtual.
int index = property_index_parser().Get(std::string(key));
if (!network->ParseValue(index, value)) {
@@ -2688,6 +2726,8 @@ class NetworkLibraryImpl : public NetworkLibrary {
<< path << "." << key;
}
NotifyNetworkChanged(network);
+ // Anything observing the manager needs to know about any service change.
+ NotifyNetworkManagerChanged(false); // Not forced.
}
}
@@ -2758,7 +2798,7 @@ class NetworkLibraryImpl : public NetworkLibrary {
<< " : " << plan->GetDataRemainingDesciption();
}
// Now, update any matching cellular network's cached data
- CellularNetwork* cellular = GetCellularNetworkByPath(service_path);
+ CellularNetwork* cellular = FindCellularNetworkByPath(service_path);
if (cellular) {
CellularNetwork::DataLeft data_left;
// If the network needs a new plan, then there's no data.
@@ -2973,13 +3013,13 @@ class NetworkLibraryImpl : public NetworkLibrary {
const std::string& cert,
bool autocon) {
name = n;
- password = p;
+ passphrase = p;
identity = id;
certpath = cert;
auto_connect = autocon;
}
std::string name;
- std::string password;
+ std::string passphrase;
std::string identity;
std::string certpath;
bool auto_connect;
@@ -3061,6 +3101,8 @@ class NetworkLibraryStubImpl : public NetworkLibrary {
virtual const NetworkDevice* FindNetworkDeviceByPath(
const std::string& path) const { return NULL; }
+ virtual Network* FindNetworkByPath(
+ const std::string& path) const { return NULL; }
virtual WifiNetwork* FindWifiNetworkByPath(
const std::string& path) const { return NULL; }
virtual CellularNetwork* FindCellularNetworkByPath(
@@ -3079,11 +3121,11 @@ class NetworkLibraryStubImpl : public NetworkLibrary {
virtual void ConnectToWifiNetwork(const std::string& service_path) {}
virtual void ConnectToWifiNetwork(ConnectionSecurity security,
const std::string& ssid,
- const std::string& password,
+ const std::string& passphrase,
const std::string& identity,
const std::string& certpath,
bool auto_connect) {}
- virtual void ConnectToCellularNetwork(const CellularNetwork* network) {}
+ virtual void ConnectToCellularNetwork(CellularNetwork* network) {}
virtual void SignalCellularPlanPayment() {}
virtual bool HasRecentCellularPlanPayment() { return false; }
virtual void DisconnectFromWirelessNetwork(const WirelessNetwork* network) {}
diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h
index df5c6f1..afc5e0f 100644
--- a/chrome/browser/chromeos/cros/network_library.h
+++ b/chrome/browser/chromeos/cros/network_library.h
@@ -438,18 +438,7 @@ class WifiNetwork : public WirelessNetwork {
const std::string& identity() const { return identity_; }
const std::string& cert_path() const { return cert_path_; }
- void set_encryption(ConnectionSecurity encryption) {
- encryption_ = encryption;
- }
- void set_passphrase(const std::string& passphrase) {
- passphrase_ = passphrase;
- }
- void set_identity(const std::string& identity) {
- identity_ = identity;
- }
- void set_cert_path(const std::string& cert_path) {
- cert_path_ = cert_path;
- }
+ const std::string& GetPassphrase() const;
void SetPassphrase(const std::string& passphrase);
void SetIdentity(const std::string& identity);
@@ -470,9 +459,21 @@ class WifiNetwork : public WirelessNetwork {
virtual bool ParseValue(int index, const Value* value);
private:
+ void set_encryption(ConnectionSecurity encryption) {
+ encryption_ = encryption;
+ }
+ void set_passphrase(const std::string& passphrase) {
+ passphrase_ = passphrase;
+ }
void set_passphrase_required(bool passphrase_required) {
passphrase_required_ = passphrase_required;
}
+ void set_identity(const std::string& identity) {
+ identity_ = identity;
+ }
+ void set_cert_path(const std::string& cert_path) {
+ cert_path_ = cert_path;
+ }
ConnectionSecurity encryption_;
std::string passphrase_;
@@ -480,6 +481,10 @@ class WifiNetwork : public WirelessNetwork {
std::string identity_;
std::string cert_path_;
+ // Internal state (not stored in flimflam).
+ // Passphrase set by user (stored for UI).
+ std::string user_passphrase_;
+
friend class NetworkLibraryImpl;
};
typedef std::vector<WifiNetwork*> WifiNetworkVector;
@@ -696,8 +701,15 @@ class NetworkLibrary {
const std::string& path) const = 0;
// Return a pointer to the network, if it exists, or NULL.
- virtual WifiNetwork* FindWifiNetworkByPath(
- const std::string& path) const = 0;
+ // NOTE: Never store these results, store service paths instead.
+ // The pattern for doing an operation on a Network is:
+ // Network* network = cros->FindNetworkByPath(service_path);
+ // network->SetFoo();
+ // network->Connect();
+ // As long as this is done in sequence on the UI thread it will be safe;
+ // the network list only gets updated on the UI thread.
+ virtual Network* FindNetworkByPath(const std::string& path) const = 0;
+ virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const = 0;
virtual CellularNetwork* FindCellularNetworkByPath(
const std::string& path) const = 0;
@@ -728,24 +740,22 @@ class NetworkLibrary {
// TODO(joth): Add GetCellTowers to retrieve a CellTowerVector.
- // TODO(stevenjb): eliminate Network* version of Connect functions.
- // Instead, always use service_path and improve the error handling.
- // Connect to the specified wireless network with password.
+ // Connect to the specified wireless network.
virtual void ConnectToWifiNetwork(WifiNetwork* network) = 0;
// Same as above but searches for an existing network by name.
virtual void ConnectToWifiNetwork(const std::string& service_path) = 0;
- // Connect to the specified network with security, ssid, and password.
+ // Connect to the specified network with security, ssid, and passphrase.
virtual void ConnectToWifiNetwork(ConnectionSecurity security,
const std::string& ssid,
- const std::string& password,
+ const std::string& passphrase,
const std::string& identity,
const std::string& certpath,
bool auto_connect) = 0;
// Connect to the specified cellular network.
- virtual void ConnectToCellularNetwork(const CellularNetwork* network) = 0;
+ virtual void ConnectToCellularNetwork(CellularNetwork* network) = 0;
// Records information that cellular play payment had happened.
virtual void SignalCellularPlanPayment() = 0;
diff --git a/chrome/browser/chromeos/login/network_screen.h b/chrome/browser/chromeos/login/network_screen.h
index 4c83745..700cf96 100644
--- a/chrome/browser/chromeos/login/network_screen.h
+++ b/chrome/browser/chromeos/login/network_screen.h
@@ -16,7 +16,6 @@
#include "chrome/browser/chromeos/login/message_bubble.h"
#include "chrome/browser/chromeos/login/network_screen_delegate.h"
#include "chrome/browser/chromeos/login/view_screen.h"
-#include "chrome/browser/chromeos/network_list.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
class WizardScreenDelegate;
diff --git a/chrome/browser/chromeos/network_list.cc b/chrome/browser/chromeos/network_list.cc
deleted file mode 100644
index 89cff35..0000000
--- a/chrome/browser/chromeos/network_list.cc
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright (c) 2010 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 "chrome/browser/chromeos/network_list.h"
-
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace chromeos {
-
-////////////////////////////////////////////////////////////////////////////////
-// NetworkList, public:
-
-NetworkList::NetworkList() {
-}
-
-NetworkList::NetworkItem* NetworkList::GetNetworkAt(int index) {
- return index >= 0 && index < static_cast<int>(networks_.size()) ?
- &networks_[index] : NULL;
-}
-
-const NetworkList::NetworkItem* NetworkList::GetNetworkById(
- NetworkType type, const string16& id) {
- return GetNetworkAt(GetNetworkIndexById(type, id));
-}
-
-int NetworkList::GetNetworkIndexById(NetworkType type,
- const string16& id) const {
- if (type == NETWORK_EMPTY)
- return -1;
- std::string network_id = UTF16ToASCII(id);
- for (size_t i = 0; i < networks_.size(); ++i) {
- if (IsSameNetwork(&networks_[i], type, network_id))
- return i;
- }
- return -1;
-}
-
-bool NetworkList::IsNetworkConnected(NetworkType type,
- const string16& id) const {
- return IsInNetworkList(connected_networks_, type, id);
-}
-
-bool NetworkList::IsNetworkConnecting(NetworkType type,
- const string16& id) const {
- return IsInNetworkList(connecting_networks_, type, id);
-}
-
-void NetworkList::OnNetworkManagerChanged(
- chromeos::NetworkLibrary* network_lib) {
- networks_.clear();
- connected_networks_.clear();
- connecting_networks_.clear();
- // Index of the last added network item.
- size_t index = 0;
- if (!network_lib || !CrosLibrary::Get()->EnsureLoaded())
- return;
-
- bool ethernet_connected = network_lib->ethernet_connected();
- bool ethernet_connecting = network_lib->ethernet_connecting();
- if (ethernet_connected || ethernet_connecting) {
- string16 label = l10n_util::GetStringUTF16(
- IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
- networks_.push_back(NetworkItem(NETWORK_ETHERNET,
- label,
- NULL,
- NULL));
- AddNetworkIndexToList(index++, ethernet_connected, ethernet_connecting);
- }
-
- // TODO(nkostylev): Show public WiFi networks first.
- const WifiNetworkVector& wifi = network_lib->wifi_networks();
- for (WifiNetworkVector::const_iterator it = wifi.begin();
- it != wifi.end(); ++it, ++index) {
- networks_.push_back(NetworkItem(NETWORK_WIFI,
- ASCIIToUTF16((*it)->name()),
- *it,
- NULL));
- if (network_lib->wifi_network() &&
- network_lib->wifi_network()->service_path() == (*it)->service_path()) {
- AddNetworkIndexToList(index,
- network_lib->wifi_connected(),
- network_lib->wifi_connecting());
- }
- }
-
- const CellularNetworkVector& cellular = network_lib->cellular_networks();
- for (CellularNetworkVector::const_iterator it = cellular.begin();
- it != cellular.end(); ++it, ++index) {
- networks_.push_back(NetworkItem(NETWORK_CELLULAR,
- ASCIIToUTF16((*it)->name()),
- NULL,
- *it));
- if (network_lib->cellular_network() &&
- network_lib->cellular_network()->service_path() ==
- (*it)->service_path()) {
- AddNetworkIndexToList(index,
- network_lib->cellular_connected(),
- network_lib->cellular_connecting());
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NetworkList, private:
-
-bool NetworkList::IsInNetworkList(const NetworkIndexVector& list,
- NetworkType type,
- const string16& id) const {
- if (type == NETWORK_EMPTY)
- return false;
- std::string network_id = UTF16ToASCII(id);
- for (size_t i = 0; i < list.size(); ++i) {
- if (IsSameNetwork(&networks_[list[i]], type, network_id))
- return true;
- }
- return false;
-}
-
-bool NetworkList::IsSameNetwork(const NetworkList::NetworkItem* network,
- NetworkType type,
- const std::string& id) const {
- if (type != network->network_type)
- return false;
- switch (type) {
- case NETWORK_ETHERNET:
- // Assuming that there's only single Ethernet network.
- return true;
- case NETWORK_WIFI:
- return network->wifi_network && id == network->wifi_network->name();
- break;
- case NETWORK_CELLULAR:
- return network->cellular_network &&
- id == network->cellular_network->name();
- break;
- default:
- return false;
- break;
- }
-}
-
-void NetworkList::AddNetworkIndexToList(size_t index,
- bool connected,
- bool connecting) {
- if (connected) {
- connected_networks_.push_back(index);
- } else if (connecting) {
- connecting_networks_.push_back(index);
- }
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/network_list.h b/chrome/browser/chromeos/network_list.h
deleted file mode 100644
index 47c7426..0000000
--- a/chrome/browser/chromeos/network_list.h
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_
-#define CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_
-#pragma once
-
-#include <string>
-#include <vector>
-
-#include "base/string16.h"
-#include "chrome/browser/chromeos/cros/network_library.h"
-
-namespace chromeos {
-
-// Represents list of currently available networks (Ethernet, Cellular, WiFi).
-// TODO(nkostylev): Refactor network list which is also represented in
-// NetworkMenuButton, InternetPageView.
-class NetworkList {
- public:
- enum NetworkType {
- NETWORK_EMPTY, // Non-initialized network item.
- NETWORK_ETHERNET,
- NETWORK_CELLULAR,
- NETWORK_WIFI,
- };
-
- struct NetworkItem {
- NetworkItem()
- : network_type(NETWORK_EMPTY),
- connected(false) {}
- NetworkItem(NetworkType network_type,
- const string16& label)
- : network_type(network_type),
- label(label) {}
- NetworkItem(NetworkType network_type,
- string16 label,
- WifiNetwork* wifi_network,
- CellularNetwork* cellular_network)
- : network_type(network_type),
- label(label),
- wifi_network(wifi_network),
- cellular_network(cellular_network),
- connected(false) {}
-
- NetworkType network_type;
- string16 label; // string representation of the network (shown in UI).
- WifiNetwork* wifi_network;
- CellularNetwork* cellular_network;
- bool connected;
- };
-
- NetworkList();
- virtual ~NetworkList() {}
-
- // True if network list is empty.
- bool IsEmpty() const {
- return networks_.empty();
- }
-
- // Returns true, if specified network is currently connected.
- bool IsNetworkConnected(NetworkType type, const string16& id) const;
-
- // Returns true, if specified network is currently connected.
- bool IsNetworkConnecting(NetworkType type, const string16& id) const;
-
- // Returns network by it's type and ssid (Wifi) or id (Cellular).
- // If network is not available NULL is returned.
- const NetworkList::NetworkItem* GetNetworkById(NetworkType type,
- const string16& id);
-
- // Returns network index by it's type and ssid (Wifi) or id (Cellular).
- // If network is not available -1 is returned.
- int GetNetworkIndexById(NetworkType type, const string16& id) const;
-
- // Returns number of networks.
- size_t GetNetworkCount() const {
- return networks_.size();
- }
-
- // Returns network by index.
- NetworkList::NetworkItem* GetNetworkAt(int index);
-
- // Callback from NetworkLibrary.
- void OnNetworkManagerChanged(chromeos::NetworkLibrary* network_lib);
-
- private:
- typedef std::vector<NetworkItem> NetworkItemVector;
- typedef std::vector<size_t> NetworkIndexVector;
-
- // Returns true if the specified network is in the list.
- bool IsInNetworkList(const NetworkIndexVector& list,
- NetworkType type,
- const string16& id) const;
-
- // Returns true if network is of the same type and id.
- bool IsSameNetwork(const NetworkList::NetworkItem* network,
- NetworkType type,
- const std::string& id) const;
-
- // Adds network index to the corresponding connected/connecting network list.
- // |index| - network index being processed
- void AddNetworkIndexToList(size_t index, bool connected, bool connecting);
-
- // Cached list of all available networks with their connection states.
- NetworkItemVector networks_;
-
- // Connected networks indexes.
- NetworkIndexVector connected_networks_;
-
- // Connecting networks indexes.
- NetworkIndexVector connecting_networks_;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkList);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_
diff --git a/chrome/browser/chromeos/network_login_observer.cc b/chrome/browser/chromeos/network_login_observer.cc
index 8d8499a..b8cd3d9 100644
--- a/chrome/browser/chromeos/network_login_observer.cc
+++ b/chrome/browser/chromeos/network_login_observer.cc
@@ -58,8 +58,8 @@ void NetworkLoginObserver::RefreshStoredNetworks(
}
}
-void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* obj) {
- const WifiNetworkVector& wifi_networks = obj->wifi_networks();
+void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) {
+ const WifiNetworkVector& wifi_networks = cros->wifi_networks();
NetworkConfigView* view = NULL;
// Check to see if we have any newly failed wifi network.
diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc
index 568109f..4a92ccb 100644
--- a/chrome/browser/chromeos/options/wifi_config_view.cc
+++ b/chrome/browser/chromeos/options/wifi_config_view.cc
@@ -165,7 +165,7 @@ class Phase2AuthComboboxModel : public ui::ComboboxModel {
WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi)
: parent_(parent),
is_8021x_(false),
- wifi_(wifi),
+ service_path_(wifi->service_path()),
ssid_textfield_(NULL),
eap_method_combobox_(NULL),
phase_2_auth_combobox_(NULL),
@@ -177,13 +177,12 @@ WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi)
passphrase_textfield_(NULL),
passphrase_visible_button_(NULL),
error_label_(NULL) {
- Init();
+ Init(wifi);
}
WifiConfigView::WifiConfigView(NetworkConfigView* parent)
: parent_(parent),
is_8021x_(false),
- wifi_(NULL),
ssid_textfield_(NULL),
eap_method_combobox_(NULL),
phase_2_auth_combobox_(NULL),
@@ -195,7 +194,7 @@ WifiConfigView::WifiConfigView(NetworkConfigView* parent)
passphrase_textfield_(NULL),
passphrase_visible_button_(NULL),
error_label_(NULL) {
- Init();
+ Init(NULL);
}
WifiConfigView::~WifiConfigView() {
@@ -204,7 +203,7 @@ WifiConfigView::~WifiConfigView() {
bool WifiConfigView::CanLogin() {
static const size_t kMinWirelessPasswordLen = 5;
- if (!wifi_) {
+ if (service_path_.empty()) {
// Enforce ssid is non empty.
if (GetSSID().empty())
return false;
@@ -241,12 +240,16 @@ void WifiConfigView::UpdateDialogButtons() {
void WifiConfigView::UpdateErrorLabel(bool failed) {
static const int kNoError = -1;
int id = kNoError;
- if (wifi_) {
- // Right now, only displaying bad_passphrase and bad_wepkey errors.
- if (wifi_->error() == ERROR_BAD_PASSPHRASE)
- id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE;
- else if (wifi_->error() == ERROR_BAD_WEPKEY)
- id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_WEPKEY;
+ if (!service_path_.empty()) {
+ NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
+ const WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_);
+ if (wifi) {
+ // Right now, only displaying bad_passphrase and bad_wepkey errors.
+ if (wifi->error() == ERROR_BAD_PASSPHRASE)
+ id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE;
+ else if (wifi->error() == ERROR_BAD_WEPKEY)
+ id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_WEPKEY;
+ }
}
if (id == kNoError && failed) {
// We don't know what the error was. For now assume bad identity or
@@ -354,7 +357,7 @@ bool WifiConfigView::Login() {
identity_string = UTF16ToUTF8(identity_textfield_->text());
}
NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
- if (!wifi_) {
+ if (service_path_.empty()) {
ConnectionSecurity sec = SECURITY_UNKNOWN;
int index = security_combobox_->selected_item();
if (index == SECURITY_INDEX_NONE)
@@ -369,15 +372,18 @@ bool WifiConfigView::Login() {
sec, GetSSID(), GetPassphrase(),
identity_string, certificate_path_, true);
} else {
+ WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_);
+ if (!wifi) {
+ // Flimflam no longer knows about this wifi network (edge case).
+ // TODO(stevenjb): Add a notification (chromium-os13225).
+ LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists.";
+ return true;
+ }
if (is_8021x_) {
// TODO(chocobo): Set 802.1x properties
}
-
- const std::string passphrase = GetPassphrase();
- if (passphrase != wifi_->passphrase())
- wifi_->SetPassphrase(passphrase);
-
- cros->ConnectToWifiNetwork(wifi_);
+ wifi->SetPassphrase(GetPassphrase());
+ cros->ConnectToWifiNetwork(wifi);
// Connection failures are responsible for updating the UI, including
// reopening dialogs.
}
@@ -385,14 +391,9 @@ bool WifiConfigView::Login() {
}
void WifiConfigView::Cancel() {
- // If we have a bad passphrase error, clear the passphrase.
- if (wifi_ && (wifi_->error() == ERROR_BAD_PASSPHRASE ||
- wifi_->error() == ERROR_BAD_WEPKEY)) {
- wifi_->SetPassphrase(std::string());
- }
}
-const std::string WifiConfigView::GetSSID() const {
+std::string WifiConfigView::GetSSID() const {
std::string result;
if (ssid_textfield_ != NULL) {
std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text());
@@ -401,7 +402,7 @@ const std::string WifiConfigView::GetSSID() const {
return result;
}
-const std::string WifiConfigView::GetPassphrase() const {
+std::string WifiConfigView::GetPassphrase() const {
std::string result;
if (passphrase_textfield_ != NULL)
result = UTF16ToUTF8(passphrase_textfield_->text());
@@ -414,7 +415,7 @@ const std::string WifiConfigView::GetPassphrase() const {
// If we are creating the "Join other network..." dialog, we will allow user
// to enter the data. And if they select the 802.1x encryption, we will show
// the 802.1x fields.
-void WifiConfigView::Init() {
+void WifiConfigView::Init(WifiNetwork* wifi) {
views::GridLayout* layout = views::GridLayout::CreatePanel(this);
SetLayoutManager(layout);
@@ -434,21 +435,21 @@ void WifiConfigView::Init() {
layout->StartRow(0, column_view_set_id);
layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID))));
- if (!wifi_) {
+ if (!wifi) {
ssid_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
ssid_textfield_->SetController(this);
ssid_textfield_->SetAccessibleName(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID));
layout->AddView(ssid_textfield_);
} else {
- views::Label* label = new views::Label(ASCIIToWide(wifi_->name()));
+ views::Label* label = new views::Label(ASCIIToWide(wifi->name()));
label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
layout->AddView(label);
}
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
// Security select
- if (!wifi_) {
+ if (!wifi) {
layout->StartRow(0, column_view_set_id);
layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY))));
@@ -468,8 +469,8 @@ void WifiConfigView::Init() {
// in general, but very common. WPA Supplicant doesn't report the
// EAP type because it's unknown until the process begins, and we'd
// need some kind of callback.
- is_8021x_ = wifi_ && wifi_->encrypted() &&
- wifi_->encryption() == SECURITY_8021X;
+ is_8021x_ = wifi && wifi->encrypted() &&
+ wifi->encryption() == SECURITY_8021X;
if (is_8021x_) {
// EAP Method
layout->StartRow(0, column_view_set_id);
@@ -495,9 +496,9 @@ void WifiConfigView::Init() {
layout->StartRow(0, column_view_set_id);
layout->AddView(new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT))));
- if (!wifi_->cert_path().empty()) {
- certificate_path_ = wifi_->cert_path();
- certificate_loaded = wifi_->IsCertificateLoaded();
+ if (!wifi->cert_path().empty()) {
+ certificate_path_ = wifi->cert_path();
+ certificate_loaded = wifi->IsCertificateLoaded();
}
if (certificate_loaded) {
std::wstring label = UTF16ToWide(l10n_util::GetStringUTF16(
@@ -524,8 +525,8 @@ void WifiConfigView::Init() {
identity_textfield_ = new views::Textfield(
views::Textfield::STYLE_DEFAULT);
identity_textfield_->SetController(this);
- if (!wifi_->identity().empty())
- identity_textfield_->SetText(UTF8ToUTF16(wifi_->identity()));
+ if (!wifi->identity().empty())
+ identity_textfield_->SetText(UTF8ToUTF16(wifi->identity()));
layout->AddView(identity_textfield_);
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
@@ -553,10 +554,10 @@ void WifiConfigView::Init() {
passphrase_textfield_ = new views::Textfield(
views::Textfield::STYLE_PASSWORD);
passphrase_textfield_->SetController(this);
- if (wifi_ && !wifi_->passphrase().empty())
- passphrase_textfield_->SetText(UTF8ToUTF16(wifi_->passphrase()));
+ if (wifi && !wifi->GetPassphrase().empty())
+ passphrase_textfield_->SetText(UTF8ToUTF16(wifi->GetPassphrase()));
// Disable passphrase input initially for other network.
- if (!wifi_)
+ if (!wifi)
passphrase_textfield_->SetEnabled(false);
passphrase_textfield_->SetAccessibleName(l10n_util::GetStringUTF16(
label_text_id));
diff --git a/chrome/browser/chromeos/options/wifi_config_view.h b/chrome/browser/chromeos/options/wifi_config_view.h
index 3761e84..3aa52a8 100644
--- a/chrome/browser/chromeos/options/wifi_config_view.h
+++ b/chrome/browser/chromeos/options/wifi_config_view.h
@@ -34,7 +34,8 @@ class WifiConfigView : public views::View,
public views::Combobox::Listener,
public SelectFileDialog::Listener {
public:
- // Wifi login dialog for wifi network |wifi|
+ // Wifi login dialog for wifi network |wifi|. |wifi| must be a non NULL
+ // pointer to a WifiNetwork in NetworkLibrary.
WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi);
// Wifi login dialog for "Joining other network..."
explicit WifiConfigView(NetworkConfigView* parent);
@@ -63,16 +64,16 @@ class WifiConfigView : public views::View,
virtual void Cancel();
// Get the typed in ssid.
- const std::string GetSSID() const;
+ std::string GetSSID() const;
// Get the typed in passphrase.
- const std::string GetPassphrase() const;
+ std::string GetPassphrase() const;
// Returns whether or not we can login.
bool CanLogin();
private:
// Initializes UI.
- void Init();
+ void Init(WifiNetwork* wifi);
// Updates state of the Login button.
void UpdateDialogButtons();
@@ -85,7 +86,7 @@ class WifiConfigView : public views::View,
// Whether or not it is an 802.1x network.
bool is_8021x_;
- WifiNetwork* wifi_;
+ std::string service_path_;
views::Textfield* ssid_textfield_;
views::Combobox* eap_method_combobox_;
diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc
index e42c682..157afb4 100644
--- a/chrome/browser/chromeos/status/network_menu.cc
+++ b/chrome/browser/chromeos/status/network_menu.cc
@@ -215,7 +215,7 @@ bool NetworkMenu::ConnectToNetworkAt(int index,
ShowNetworkConfigView(new NetworkConfigView(wifi));
return true;
} else {
- cros->ConnectToWifiNetwork(service_path);
+ cros->ConnectToWifiNetwork(wifi);
// Connection failures are responsible for updating the UI, including
// reopening dialogs.
return true;
@@ -226,7 +226,7 @@ bool NetworkMenu::ConnectToNetworkAt(int index,
// TODO(stevenjb): Show notification.
}
} else if (flags & FLAG_CELLULAR) {
- const CellularNetwork* cellular = cros->FindCellularNetworkByPath(
+ CellularNetwork* cellular = cros->FindCellularNetworkByPath(
service_path);
if (cellular) {
if ((cellular->activation_state() != ACTIVATION_STATE_ACTIVATED &&
diff --git a/chrome/browser/chromeos/webui/internet_options_handler.cc b/chrome/browser/chromeos/webui/internet_options_handler.cc
index d18bc09..3318bcf 100644
--- a/chrome/browser/chromeos/webui/internet_options_handler.cc
+++ b/chrome/browser/chromeos/webui/internet_options_handler.cc
@@ -605,7 +605,7 @@ void InternetOptionsHandler::PopulateWifiDetails(
dictionary->SetString("certPath", wifi->cert_path());
dictionary->SetString("ident", wifi->identity());
dictionary->SetBoolean("certNeeded", true);
- dictionary->SetString("certPass", wifi->passphrase());
+ dictionary->SetString("certPass", wifi->GetPassphrase());
} else {
dictionary->SetBoolean("certNeeded", false);
}
@@ -702,16 +702,13 @@ void InternetOptionsHandler::LoginCertCallback(const ListValue* args) {
}
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- // If password does not come from the input, use one saved with the
- // network details.
- std::string password;
- if (args->GetSize() != 4 || !args->GetString(3, &password)) {
- const chromeos::WifiNetwork* network =
- cros->FindWifiNetworkByPath(service_path);
- if (network)
- password = network->passphrase();
+ chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path);
+ if (network) {
+ std::string passphrase;
+ if (args->GetSize() == 4 && args->GetString(3, &passphrase))
+ network->SetPassphrase(passphrase);
+ cros->ConnectToWifiNetwork(network);
}
- cros->ConnectToWifiNetwork(service_path);
}
void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) {
@@ -789,7 +786,7 @@ void InternetOptionsHandler::HandleWifiButtonClick(
const std::string& command) {
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- chromeos::WifiNetwork* network = NULL;
+ chromeos::WifiNetwork* wifi = NULL;
if (command == "forget") {
if (!chromeos::UserManager::Get()->current_user_is_owner()) {
LOG(WARNING) << "Non-owner tried to forget a network.";
@@ -799,29 +796,30 @@ void InternetOptionsHandler::HandleWifiButtonClick(
} else if (!use_settings_ui_ && service_path == kOtherNetworksFakePath) {
// Other wifi networks.
CreateModalPopup(new chromeos::NetworkConfigView());
- } else if ((network = cros->FindWifiNetworkByPath(service_path))) {
+ } else if ((wifi = cros->FindWifiNetworkByPath(service_path))) {
if (command == "connect") {
// Connect to wifi here. Open password page if appropriate.
- if (network->IsPassphraseRequired()) {
+ if (wifi->IsPassphraseRequired()) {
if (use_settings_ui_) {
- if (network->encryption() == chromeos::SECURITY_8021X) {
- PopulateDictionaryDetails(network, cros);
+ if (wifi->encryption() == chromeos::SECURITY_8021X) {
+ PopulateDictionaryDetails(wifi, cros);
} else {
DictionaryValue dictionary;
- dictionary.SetString("servicePath", network->service_path());
+ dictionary.SetString("servicePath", wifi->service_path());
web_ui_->CallJavascriptFunction(
"options.InternetOptions.showPasswordEntry", dictionary);
}
} else {
- CreateModalPopup(new chromeos::NetworkConfigView(network));
+ CreateModalPopup(
+ new chromeos::NetworkConfigView(wifi));
}
} else {
- cros->ConnectToWifiNetwork(service_path);
+ cros->ConnectToWifiNetwork(wifi);
}
} else if (command == "disconnect") {
- cros->DisconnectFromWirelessNetwork(network);
+ cros->DisconnectFromWirelessNetwork(wifi);
} else if (command == "options") {
- PopulateDictionaryDetails(network, cros);
+ PopulateDictionaryDetails(wifi, cros);
}
}
}
@@ -831,7 +829,7 @@ void InternetOptionsHandler::HandleCellularButtonClick(
const std::string& command) {
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- const chromeos::CellularNetwork* cellular =
+ chromeos::CellularNetwork* cellular =
cros->FindCellularNetworkByPath(service_path);
if (cellular) {
if (command == "connect") {
diff --git a/chrome/browser/chromeos/webui/mobile_setup_ui.cc b/chrome/browser/chromeos/webui/mobile_setup_ui.cc
index 07c3093..4ec4571 100644
--- a/chrome/browser/chromeos/webui/mobile_setup_ui.cc
+++ b/chrome/browser/chromeos/webui/mobile_setup_ui.cc
@@ -245,24 +245,24 @@ class MobileSetupHandler
// Starts OTASP process.
void StartOTASP();
// Checks if we need to reconnect due to failed connection attempt.
- bool NeedsReconnecting(const chromeos::CellularNetwork* network,
+ bool NeedsReconnecting(chromeos::CellularNetwork* network,
PlanActivationState* new_state,
std::string* error_description);
// Disconnect from network.
- void DisconnectFromNetwork(const chromeos::CellularNetwork* network);
+ void DisconnectFromNetwork(chromeos::CellularNetwork* network);
// Connects to cellular network, resets connection timer.
- bool ConnectToNetwork(const chromeos::CellularNetwork* network, int delay);
+ bool ConnectToNetwork(chromeos::CellularNetwork* network, int delay);
// Forces disconnect / reconnect when we detect portal connectivity issues.
- void ForceReconnect(const chromeos::CellularNetwork* network, int delay);
+ void ForceReconnect(chromeos::CellularNetwork* network, int delay);
// Reports connection timeout.
bool ConnectionTimeout();
// Verify the state of cellular network and modify internal state.
void EvaluateCellularNetwork(chromeos::CellularNetwork* network);
// Check the current cellular network for error conditions.
- bool GotActivationError(const chromeos::CellularNetwork* network,
+ bool GotActivationError(chromeos::CellularNetwork* network,
std::string* error);
// Sends status updates to WebUI page.
- void UpdatePage(const chromeos::CellularNetwork* network,
+ void UpdatePage(chromeos::CellularNetwork* network,
const std::string& error_description);
// Changes internal state.
void ChangeState(chromeos::CellularNetwork* network,
@@ -281,7 +281,7 @@ class MobileSetupHandler
void ReEnableOtherConnections();
// Converts the currently active CellularNetwork device into a JS object.
- static void GetDeviceInfo(const chromeos::CellularNetwork* network,
+ static void GetDeviceInfo(chromeos::CellularNetwork* network,
DictionaryValue* value);
static bool ShouldReportDeviceState(std::string* state, std::string* error);
@@ -620,7 +620,7 @@ void MobileSetupHandler::ReconnectTimerFired() {
}
void MobileSetupHandler::DisconnectFromNetwork(
- const chromeos::CellularNetwork* network) {
+ chromeos::CellularNetwork* network) {
DCHECK(network);
LOG(INFO) << "Disconnecting from: " << network->service_path();
chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
@@ -631,7 +631,7 @@ void MobileSetupHandler::DisconnectFromNetwork(
}
bool MobileSetupHandler::NeedsReconnecting(
- const chromeos::CellularNetwork* network,
+ chromeos::CellularNetwork* network,
PlanActivationState* new_state,
std::string* error_description) {
DCHECK(network);
@@ -655,7 +655,7 @@ bool MobileSetupHandler::NeedsReconnecting(
}
bool MobileSetupHandler::ConnectToNetwork(
- const chromeos::CellularNetwork* network,
+ chromeos::CellularNetwork* network,
int delay) {
if (network && network->connecting_or_connected())
return true;
@@ -686,7 +686,7 @@ bool MobileSetupHandler::ConnectToNetwork(
}
void MobileSetupHandler::ForceReconnect(
- const chromeos::CellularNetwork* network,
+ chromeos::CellularNetwork* network,
int delay) {
DCHECK(network);
UMA_HISTOGRAM_COUNTS("Cellular.ActivationRetry", 1);
@@ -1052,7 +1052,7 @@ void MobileSetupHandler::CompleteActivation(
}
void MobileSetupHandler::UpdatePage(
- const chromeos::CellularNetwork* network,
+ chromeos::CellularNetwork* network,
const std::string& error_description) {
DictionaryValue device_dict;
if (network)
@@ -1218,7 +1218,7 @@ void MobileSetupHandler::DisableOtherNetworks() {
}
bool MobileSetupHandler::GotActivationError(
- const chromeos::CellularNetwork* network, std::string* error) {
+ chromeos::CellularNetwork* network, std::string* error) {
DCHECK(network);
bool got_error = false;
const char* error_code = kErrorDefault;
@@ -1262,7 +1262,7 @@ bool MobileSetupHandler::GotActivationError(
return got_error;
}
-void MobileSetupHandler::GetDeviceInfo(const chromeos::CellularNetwork* network,
+void MobileSetupHandler::GetDeviceInfo(chromeos::CellularNetwork* network,
DictionaryValue* value) {
DCHECK(network);
chromeos::NetworkLibrary* cros =
@@ -1322,7 +1322,7 @@ void MobileSetupHandler::LoadCellularConfig() {
////////////////////////////////////////////////////////////////////////////////
MobileSetupUI::MobileSetupUI(TabContents* contents) : WebUI(contents) {
- const chromeos::CellularNetwork* network = GetCellularNetwork();
+ chromeos::CellularNetwork* network = GetCellularNetwork();
std::string service_path = network ? network->service_path() : std::string();
MobileSetupHandler* handler = new MobileSetupHandler(service_path);
AddMessageHandler((handler)->Attach(this));
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 414c22d..8e63d6e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -588,8 +588,6 @@
'browser/chromeos/native_dialog_window.h',
'browser/chromeos/native_theme_chromeos.cc',
'browser/chromeos/native_theme_chromeos.h',
- 'browser/chromeos/network_list.cc',
- 'browser/chromeos/network_list.h',
'browser/chromeos/network_login_observer.cc',
'browser/chromeos/network_login_observer.h',
'browser/chromeos/network_message_observer.cc',