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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 const std::string& user_passphrase) OVERRIDE; 2669 const std::string& user_passphrase) OVERRIDE;
2670 2670
2671 // virtual DisconnectFromNetwork implemented in derived classes. 2671 // virtual DisconnectFromNetwork implemented in derived classes.
2672 virtual void ForgetNetwork(const std::string& service_path) OVERRIDE; 2672 virtual void ForgetNetwork(const std::string& service_path) OVERRIDE;
2673 virtual void EnableEthernetNetworkDevice(bool enable) OVERRIDE; 2673 virtual void EnableEthernetNetworkDevice(bool enable) OVERRIDE;
2674 virtual void EnableWifiNetworkDevice(bool enable) OVERRIDE; 2674 virtual void EnableWifiNetworkDevice(bool enable) OVERRIDE;
2675 virtual void EnableCellularNetworkDevice(bool enable) OVERRIDE; 2675 virtual void EnableCellularNetworkDevice(bool enable) OVERRIDE;
2676 // virtual EnableOfflineMode implemented in derived classes. 2676 // virtual EnableOfflineMode implemented in derived classes.
2677 // virtual GetIPConfigs implemented in derived classes. 2677 // virtual GetIPConfigs implemented in derived classes.
2678 // virtual SetIPConfig implemented in derived classes. 2678 // virtual SetIPConfig implemented in derived classes.
2679 virtual void SwitchToPreferredNetwork() OVERRIDE;
2679 2680
2680 protected: 2681 protected:
2681 typedef ObserverList<NetworkObserver> NetworkObserverList; 2682 typedef ObserverList<NetworkObserver> NetworkObserverList;
2682 typedef std::map<std::string, NetworkObserverList*> NetworkObserverMap; 2683 typedef std::map<std::string, NetworkObserverList*> NetworkObserverMap;
2683 2684
2684 typedef ObserverList<NetworkDeviceObserver> NetworkDeviceObserverList; 2685 typedef ObserverList<NetworkDeviceObserver> NetworkDeviceObserverList;
2685 typedef std::map<std::string, NetworkDeviceObserverList*> 2686 typedef std::map<std::string, NetworkDeviceObserverList*>
2686 NetworkDeviceObserverMap; 2687 NetworkDeviceObserverMap;
2687 2688
2688 typedef std::map<std::string, Network*> NetworkMap; 2689 typedef std::map<std::string, Network*> NetworkMap;
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 return; 3738 return;
3738 CallEnableNetworkDeviceType(TYPE_WIFI, enable); 3739 CallEnableNetworkDeviceType(TYPE_WIFI, enable);
3739 } 3740 }
3740 3741
3741 void NetworkLibraryImplBase::EnableCellularNetworkDevice(bool enable) { 3742 void NetworkLibraryImplBase::EnableCellularNetworkDevice(bool enable) {
3742 if (is_locked_) 3743 if (is_locked_)
3743 return; 3744 return;
3744 CallEnableNetworkDeviceType(TYPE_CELLULAR, enable); 3745 CallEnableNetworkDeviceType(TYPE_CELLULAR, enable);
3745 } 3746 }
3746 3747
3748 void NetworkLibraryImplBase::SwitchToPreferredNetwork() {
3749 // If current network (if any) is not preferred, check network service list to
3750 // see if the first not connected network is preferred and set to autoconnect.
3751 // If so, connect to it.
3752 if (!wifi_enabled() || (active_wifi_ && active_wifi_->preferred()))
3753 return;
3754 for (WifiNetworkVector::const_iterator it = wifi_networks_.begin();
3755 it != wifi_networks_.end(); ++it) {
3756 WifiNetwork* wifi = *it;
3757 if (wifi->connected() || wifi->connecting()) // Skip connected/connecting.
3758 continue;
3759 if (!wifi->preferred()) // All preferred networks are sorted in front.
3760 break;
3761 if (wifi->auto_connect()) {
3762 ConnectToWifiNetwork(wifi);
3763 break;
3764 }
3765 }
3766 }
3767
3768
3747 //////////////////////////////////////////////////////////////////////////// 3769 ////////////////////////////////////////////////////////////////////////////
3748 // Network list management functions. 3770 // Network list management functions.
3749 3771
3750 // Note: sometimes flimflam still returns networks when the device type is 3772 // Note: sometimes flimflam still returns networks when the device type is
3751 // disabled. Always check the appropriate enabled() state before adding 3773 // disabled. Always check the appropriate enabled() state before adding
3752 // networks to a list or setting an active network so that we do not show them 3774 // networks to a list or setting an active network so that we do not show them
3753 // in the UI. 3775 // in the UI.
3754 3776
3755 // This relies on services being requested from flimflam in priority order, 3777 // This relies on services being requested from flimflam in priority order,
3756 // and the updates getting processed and received in order. 3778 // and the updates getting processed and received in order.
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4954 case PROPERTY_INDEX_DEFAULT_TECHNOLOGY: 4976 case PROPERTY_INDEX_DEFAULT_TECHNOLOGY:
4955 // Currently we ignore DefaultTechnology. 4977 // Currently we ignore DefaultTechnology.
4956 break; 4978 break;
4957 case PROPERTY_INDEX_OFFLINE_MODE: { 4979 case PROPERTY_INDEX_OFFLINE_MODE: {
4958 DCHECK_EQ(value->GetType(), Value::TYPE_BOOLEAN); 4980 DCHECK_EQ(value->GetType(), Value::TYPE_BOOLEAN);
4959 value->GetAsBoolean(&offline_mode_); 4981 value->GetAsBoolean(&offline_mode_);
4960 NotifyNetworkManagerChanged(false); // Not forced. 4982 NotifyNetworkManagerChanged(false); // Not forced.
4961 break; 4983 break;
4962 } 4984 }
4963 case PROPERTY_INDEX_ACTIVE_PROFILE: { 4985 case PROPERTY_INDEX_ACTIVE_PROFILE: {
4986 std::string prev = active_profile_path_;
4964 DCHECK_EQ(value->GetType(), Value::TYPE_STRING); 4987 DCHECK_EQ(value->GetType(), Value::TYPE_STRING);
4965 value->GetAsString(&active_profile_path_); 4988 value->GetAsString(&active_profile_path_);
4966 VLOG(1) << "Active Profile: " << active_profile_path_; 4989 VLOG(1) << "Active Profile: " << active_profile_path_;
4990 if (active_profile_path_ != prev &&
4991 active_profile_path_ != kSharedProfilePath)
4992 SwitchToPreferredNetwork();
4967 break; 4993 break;
4968 } 4994 }
4969 case PROPERTY_INDEX_PROFILES: { 4995 case PROPERTY_INDEX_PROFILES: {
4970 DCHECK_EQ(value->GetType(), Value::TYPE_LIST); 4996 DCHECK_EQ(value->GetType(), Value::TYPE_LIST);
4971 const ListValue* vlist = static_cast<const ListValue*>(value); 4997 const ListValue* vlist = static_cast<const ListValue*>(value);
4972 UpdateRememberedNetworks(vlist); 4998 UpdateRememberedNetworks(vlist);
4973 RequestRememberedNetworksUpdate(); 4999 RequestRememberedNetworksUpdate();
4974 break; 5000 break;
4975 } 5001 }
4976 case PROPERTY_INDEX_SERVICES: { 5002 case PROPERTY_INDEX_SERVICES: {
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
5847 return network_library; 5873 return network_library;
5848 } 5874 }
5849 5875
5850 ///////////////////////////////////////////////////////////////////////////// 5876 /////////////////////////////////////////////////////////////////////////////
5851 5877
5852 } // namespace chromeos 5878 } // namespace chromeos
5853 5879
5854 // Allows InvokeLater without adding refcounting. This class is a Singleton and 5880 // Allows InvokeLater without adding refcounting. This class is a Singleton and
5855 // won't be deleted until it's last InvokeLater is run. 5881 // won't be deleted until it's last InvokeLater is run.
5856 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); 5882 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase);
OLDNEW
« 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