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

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 SwitchToPreferredNetworkIfAppropriate() 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::SwitchToPreferredNetworkIfAppropriate() {
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 (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
3753 return;
3754 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.
3755 return;
3756 for (WifiNetworkVector::const_iterator it = wifi_networks_.begin();
3757 it != wifi_networks_.end(); ++it) {
3758 WifiNetwork* wifi = *it;
3759 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.
3760 continue;
3761 if (!wifi->preferred()) // All preferred networks are sorted in front.
3762 break;
3763 if (wifi->auto_connect()) {
3764 ConnectToWifiNetwork(wifi);
3765 break;
3766 }
3767 }
3768 }
3769
3770
3747 //////////////////////////////////////////////////////////////////////////// 3771 ////////////////////////////////////////////////////////////////////////////
3748 // Network list management functions. 3772 // Network list management functions.
3749 3773
3750 // Note: sometimes flimflam still returns networks when the device type is 3774 // Note: sometimes flimflam still returns networks when the device type is
3751 // disabled. Always check the appropriate enabled() state before adding 3775 // 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 3776 // networks to a list or setting an active network so that we do not show them
3753 // in the UI. 3777 // in the UI.
3754 3778
3755 // This relies on services being requested from flimflam in priority order, 3779 // This relies on services being requested from flimflam in priority order,
3756 // and the updates getting processed and received in order. 3780 // and the updates getting processed and received in order.
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4957 case PROPERTY_INDEX_OFFLINE_MODE: { 4981 case PROPERTY_INDEX_OFFLINE_MODE: {
4958 DCHECK_EQ(value->GetType(), Value::TYPE_BOOLEAN); 4982 DCHECK_EQ(value->GetType(), Value::TYPE_BOOLEAN);
4959 value->GetAsBoolean(&offline_mode_); 4983 value->GetAsBoolean(&offline_mode_);
4960 NotifyNetworkManagerChanged(false); // Not forced. 4984 NotifyNetworkManagerChanged(false); // Not forced.
4961 break; 4985 break;
4962 } 4986 }
4963 case PROPERTY_INDEX_ACTIVE_PROFILE: { 4987 case PROPERTY_INDEX_ACTIVE_PROFILE: {
4964 DCHECK_EQ(value->GetType(), Value::TYPE_STRING); 4988 DCHECK_EQ(value->GetType(), Value::TYPE_STRING);
4965 value->GetAsString(&active_profile_path_); 4989 value->GetAsString(&active_profile_path_);
4966 VLOG(1) << "Active Profile: " << active_profile_path_; 4990 VLOG(1) << "Active Profile: " << active_profile_path_;
4991 if (active_profile_path_ != kSharedProfilePath)
stevenjb 2011/08/03 21:37:52 We should check on == kUserProfilePath; there has
4992 SwitchToPreferredNetworkIfAppropriate();
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

Powered by Google App Engine
This is Rietveld 408576698