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: { |