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

Side by Side Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 8947002: Revert 114515 - broke CrOS tests: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 <dbus/dbus-glib.h> 7 #include <dbus/dbus-glib.h>
8 #include <dbus/dbus-gtype-specialized.h> 8 #include <dbus/dbus-gtype-specialized.h>
9 #include <glib-object.h> 9 #include <glib-object.h>
10 10
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 // virtual DisconnectFromNetwork implemented in derived classes. 1738 // virtual DisconnectFromNetwork implemented in derived classes.
1739 virtual void ForgetNetwork(const std::string& service_path) OVERRIDE; 1739 virtual void ForgetNetwork(const std::string& service_path) OVERRIDE;
1740 virtual void EnableEthernetNetworkDevice(bool enable) OVERRIDE; 1740 virtual void EnableEthernetNetworkDevice(bool enable) OVERRIDE;
1741 virtual void EnableWifiNetworkDevice(bool enable) OVERRIDE; 1741 virtual void EnableWifiNetworkDevice(bool enable) OVERRIDE;
1742 virtual void EnableCellularNetworkDevice(bool enable) OVERRIDE; 1742 virtual void EnableCellularNetworkDevice(bool enable) OVERRIDE;
1743 // virtual EnableOfflineMode implemented in derived classes. 1743 // virtual EnableOfflineMode implemented in derived classes.
1744 // virtual GetIPConfigs implemented in derived classes. 1744 // virtual GetIPConfigs implemented in derived classes.
1745 // virtual SetIPConfig implemented in derived classes. 1745 // virtual SetIPConfig implemented in derived classes.
1746 virtual void SwitchToPreferredNetwork() OVERRIDE; 1746 virtual void SwitchToPreferredNetwork() OVERRIDE;
1747 virtual bool LoadOncNetworks(const std::string& onc_blob, 1747 virtual bool LoadOncNetworks(const std::string& onc_blob,
1748 const std::string& passcode, 1748 const std::string& passcode) OVERRIDE;
1749 std::string* error) OVERRIDE;
1750 virtual bool SetActiveNetwork(ConnectionType type, 1749 virtual bool SetActiveNetwork(ConnectionType type,
1751 const std::string& service_path) OVERRIDE; 1750 const std::string& service_path) OVERRIDE;
1752 1751
1753 protected: 1752 protected:
1754 typedef ObserverList<NetworkObserver> NetworkObserverList; 1753 typedef ObserverList<NetworkObserver> NetworkObserverList;
1755 typedef std::map<std::string, NetworkObserverList*> NetworkObserverMap; 1754 typedef std::map<std::string, NetworkObserverList*> NetworkObserverMap;
1756 1755
1757 typedef ObserverList<NetworkDeviceObserver> NetworkDeviceObserverList; 1756 typedef ObserverList<NetworkDeviceObserver> NetworkDeviceObserverList;
1758 typedef std::map<std::string, NetworkDeviceObserverList*> 1757 typedef std::map<std::string, NetworkDeviceObserverList*>
1759 NetworkDeviceObserverMap; 1758 NetworkDeviceObserverMap;
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 if (!wifi->preferred()) // All preferred networks are sorted in front. 2827 if (!wifi->preferred()) // All preferred networks are sorted in front.
2829 break; 2828 break;
2830 if (wifi->auto_connect()) { 2829 if (wifi->auto_connect()) {
2831 ConnectToWifiNetwork(wifi); 2830 ConnectToWifiNetwork(wifi);
2832 break; 2831 break;
2833 } 2832 }
2834 } 2833 }
2835 } 2834 }
2836 2835
2837 bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob, 2836 bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
2838 const std::string& passcode, 2837 const std::string& passcode) {
2839 std::string* error) {
2840 // TODO(gspencer): Add support for decrypting onc files. crbug.com/19397 2838 // TODO(gspencer): Add support for decrypting onc files. crbug.com/19397
2841 OncNetworkParser parser(onc_blob); 2839 OncNetworkParser parser(onc_blob);
2842 2840
2843 if (!parser.parse_error().empty()) {
2844 if (error)
2845 *error = parser.parse_error();
2846 return false;
2847 }
2848
2849 for (int i = 0; i < parser.GetCertificatesSize(); i++) { 2841 for (int i = 0; i < parser.GetCertificatesSize(); i++) {
2850 // Insert each of the available certs into the certificate DB. 2842 // Insert each of the available certs into the certificate DB.
2851 if (parser.ParseCertificate(i).get() == NULL) { 2843 if (parser.ParseCertificate(i).get() == NULL) {
2852 DLOG(WARNING) << "Cannot parse certificate in ONC file"; 2844 DLOG(WARNING) << "Cannot parse certificate in ONC file";
2853 if (error)
2854 *error = parser.parse_error();
2855 return false; 2845 return false;
2856 } 2846 }
2857 } 2847 }
2858 2848
2859 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) { 2849 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) {
2860 // Parse Open Network Configuration blob into a temporary Network object. 2850 // Parse Open Network Configuration blob into a temporary Network object.
2861 scoped_ptr<Network> network(parser.ParseNetwork(i)); 2851 scoped_ptr<Network> network(parser.ParseNetwork(i));
2862 if (!network.get()) { 2852 if (!network.get()) {
2863 DLOG(WARNING) << "Cannot parse network in ONC file"; 2853 DLOG(WARNING) << "Cannot parse network in ONC file";
2864 if (error)
2865 *error = parser.parse_error();
2866 return false; 2854 return false;
2867 } 2855 }
2868 2856
2869 DictionaryValue dict; 2857 DictionaryValue dict;
2870 for (Network::PropertyMap::const_iterator props = 2858 for (Network::PropertyMap::const_iterator props =
2871 network->property_map_.begin(); 2859 network->property_map_.begin();
2872 props != network->property_map_.end(); ++props) { 2860 props != network->property_map_.end(); ++props) {
2873 std::string key = 2861 std::string key =
2874 NativeNetworkParser::property_mapper()->GetKey(props->first); 2862 NativeNetworkParser::property_mapper()->GetKey(props->first);
2875 if (!key.empty()) 2863 if (!key.empty())
2876 dict.SetWithoutPathExpansion(key, props->second->DeepCopy()); 2864 dict.SetWithoutPathExpansion(key, props->second->DeepCopy());
2877 else 2865 else
2878 VLOG(2) << "Property " << props->first << " will not be sent"; 2866 VLOG(2) << "Property " << props->first << " will not be sent";
2879 } 2867 }
2880 2868
2881 CallConfigureService(network->unique_id(), &dict); 2869 CallConfigureService(network->unique_id(), &dict);
2882 } 2870 }
2883 2871 return (parser.GetNetworkConfigsSize() != 0 ||
2884 if (parser.GetNetworkConfigsSize() != 0 || 2872 parser.GetCertificatesSize() != 0);
2885 parser.GetCertificatesSize() != 0) {
2886 if (error)
2887 *error = l10n_util::GetStringUTF8(
2888 IDS_NETWORK_CONFIG_ERROR_NETWORK_IMPORT);
2889 return false;
2890 }
2891 return true;
2892 } 2873 }
2893 2874
2894 //////////////////////////////////////////////////////////////////////////// 2875 ////////////////////////////////////////////////////////////////////////////
2895 // Testing functions. 2876 // Testing functions.
2896 2877
2897 bool NetworkLibraryImplBase::SetActiveNetwork( 2878 bool NetworkLibraryImplBase::SetActiveNetwork(
2898 ConnectionType type, const std::string& service_path) { 2879 ConnectionType type, const std::string& service_path) {
2899 Network* network = NULL; 2880 Network* network = NULL;
2900 if (!service_path.empty()) 2881 if (!service_path.empty())
2901 network = FindNetworkByPath(service_path); 2882 network = FindNetworkByPath(service_path);
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after
5114 " \"GUID\": \"guid\"," 5095 " \"GUID\": \"guid\","
5115 " \"Type\": \"WiFi\"," 5096 " \"Type\": \"WiFi\","
5116 " \"WiFi\": {" 5097 " \"WiFi\": {"
5117 " \"Security\": \"WEP\"," 5098 " \"Security\": \"WEP\","
5118 " \"SSID\": \"MySSID\"," 5099 " \"SSID\": \"MySSID\","
5119 " }" 5100 " }"
5120 " }" 5101 " }"
5121 " ]," 5102 " ],"
5122 " \"Certificates\": []" 5103 " \"Certificates\": []"
5123 "}"); 5104 "}");
5124 LoadOncNetworks(test_blob, "", NULL); 5105 LoadOncNetworks(test_blob, "");
5125 } 5106 }
5126 5107
5127 //////////////////////////////////////////////////////////////////////////// 5108 ////////////////////////////////////////////////////////////////////////////
5128 // NetworkLibraryImplStub private methods. 5109 // NetworkLibraryImplStub private methods.
5129 5110
5130 void NetworkLibraryImplStub::AddStubNetwork( 5111 void NetworkLibraryImplStub::AddStubNetwork(
5131 Network* network, NetworkProfileType profile_type) { 5112 Network* network, NetworkProfileType profile_type) {
5132 network->priority_order_ = network_priority_order_++; 5113 network->priority_order_ = network_priority_order_++;
5133 network->CalculateUniqueId(); 5114 network->CalculateUniqueId();
5134 if (!network->unique_id().empty()) 5115 if (!network->unique_id().empty())
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
5362 return impl; 5343 return impl;
5363 } 5344 }
5364 5345
5365 ///////////////////////////////////////////////////////////////////////////// 5346 /////////////////////////////////////////////////////////////////////////////
5366 5347
5367 } // namespace chromeos 5348 } // namespace chromeos
5368 5349
5369 // Allows InvokeLater without adding refcounting. This class is a Singleton and 5350 // Allows InvokeLater without adding refcounting. This class is a Singleton and
5370 // won't be deleted until its last InvokeLater is run. 5351 // won't be deleted until its last InvokeLater is run.
5371 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); 5352 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase);
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/cros/onc_network_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698