Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4421)

Unified Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 7566015: Only show prefer network checkbox for networks stored on user profile. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/cros/network_library.cc
===================================================================
--- chrome/browser/chromeos/cros/network_library.cc (revision 94953)
+++ chrome/browser/chromeos/cros/network_library.cc (working copy)
@@ -2676,6 +2676,7 @@
// virtual EnableOfflineMode implemented in derived classes.
// virtual GetIPConfigs implemented in derived classes.
// virtual SetIPConfig implemented in derived classes.
+ virtual void SwitchToPreferredNetworkIfAppropriate() OVERRIDE;
protected:
typedef ObserverList<NetworkObserver> NetworkObserverList;
@@ -3744,6 +3745,29 @@
CallEnableNetworkDeviceType(TYPE_CELLULAR, enable);
}
+void NetworkLibraryImplBase::SwitchToPreferredNetworkIfAppropriate() {
+ // If current network (if any) is not preferred, check network service list to
+ // see if the first not connected network is preferred and set to autoconnect.
+ // If so, connect to it.
+ if (active_wifi_ == NULL || active_wifi_->preferred())
stevenjb 2011/08/03 21:37:52 This assumes that flimflam would always auto-conne
Charlie Lee 2011/08/03 22:22:59 Good advice. Thanks. On 2011/08/03 21:37:52, Stev
+ return;
+ if (wifi_networks_.empty())
stevenjb 2011/08/03 21:37:52 nit: Extra check here isn't really necessary.
Charlie Lee 2011/08/03 22:22:59 Done.
+ return;
+ for (WifiNetworkVector::const_iterator it = wifi_networks_.begin();
+ it != wifi_networks_.end(); ++it) {
+ WifiNetwork* wifi = *it;
+ if (wifi->connected()) // Skip connected networks.
stevenjb 2011/08/03 21:37:52 || connecting() (I don't think we can currently be
Charlie Lee 2011/08/03 22:22:59 Done.
+ continue;
+ if (!wifi->preferred()) // All preferred networks are sorted in front.
+ break;
+ if (wifi->auto_connect()) {
+ ConnectToWifiNetwork(wifi);
+ break;
+ }
+ }
+}
+
+
////////////////////////////////////////////////////////////////////////////
// Network list management functions.
@@ -4964,6 +4988,8 @@
DCHECK_EQ(value->GetType(), Value::TYPE_STRING);
value->GetAsString(&active_profile_path_);
VLOG(1) << "Active Profile: " << active_profile_path_;
+ if (active_profile_path_ != kSharedProfilePath)
stevenjb 2011/08/03 21:37:52 We should check on == kUserProfilePath; there has
+ SwitchToPreferredNetworkIfAppropriate();
break;
}
case PROPERTY_INDEX_PROFILES: {

Powered by Google App Engine
This is Rietveld 408576698