Chromium Code Reviews| Index: chrome/browser/chromeos/cros/network_library.cc |
| =================================================================== |
| --- chrome/browser/chromeos/cros/network_library.cc (revision 95328) |
| +++ 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 SwitchToPreferredNetwork() OVERRIDE; |
| protected: |
| typedef ObserverList<NetworkObserver> NetworkObserverList; |
| @@ -3744,6 +3745,27 @@ |
| CallEnableNetworkDeviceType(TYPE_CELLULAR, enable); |
| } |
| +void NetworkLibraryImplBase::SwitchToPreferredNetwork() { |
| + // 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 (!wifi_enabled() || (active_wifi_ && active_wifi_->preferred())) |
| + return; |
| + for (WifiNetworkVector::const_iterator it = wifi_networks_.begin(); |
| + it != wifi_networks_.end(); ++it) { |
| + WifiNetwork* wifi = *it; |
| + if (wifi->connected() || wifi->connecting()) // Skip connected/connecting. |
| + 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 +4986,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) |
| + SwitchToPreferredNetwork(); |
|
stevenjb
2011/08/03 22:58:26
We should probably only call this when active_prof
Charlie Lee
2011/08/04 20:43:02
What's the format of the user profile? It seems li
stevenjb
2011/08/04 21:01:15
Ah, I see, I didn't add a kUserProfilePath[]. We s
|
| break; |
| } |
| case PROPERTY_INDEX_PROFILES: { |