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

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, 4 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 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.
@@ -4961,9 +4983,13 @@
break;
}
case PROPERTY_INDEX_ACTIVE_PROFILE: {
+ std::string prev = active_profile_path_;
DCHECK_EQ(value->GetType(), Value::TYPE_STRING);
value->GetAsString(&active_profile_path_);
VLOG(1) << "Active Profile: " << active_profile_path_;
+ if (active_profile_path_ != prev &&
+ active_profile_path_ != kSharedProfilePath)
+ SwitchToPreferredNetwork();
break;
}
case PROPERTY_INDEX_PROFILES: {
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/resources/options/chromeos/internet_detail.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698