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

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

Issue 8804020: Set onc_source UI data parameter when importing ONC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Ken's comments. 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 13 matching lines...) Expand all
24 #include "base/string_number_conversions.h" 24 #include "base/string_number_conversions.h"
25 #include "base/string_tokenizer.h" 25 #include "base/string_tokenizer.h"
26 #include "base/string_util.h" 26 #include "base/string_util.h"
27 #include "base/stringprintf.h" 27 #include "base/stringprintf.h"
28 #include "base/utf_string_conversion_utils.h" 28 #include "base/utf_string_conversion_utils.h"
29 #include "base/utf_string_conversions.h" 29 #include "base/utf_string_conversions.h"
30 #include "base/values.h" 30 #include "base/values.h"
31 #include "chrome/browser/chromeos/cros/cros_library.h" 31 #include "chrome/browser/chromeos/cros/cros_library.h"
32 #include "chrome/browser/chromeos/cros/native_network_constants.h" 32 #include "chrome/browser/chromeos/cros/native_network_constants.h"
33 #include "chrome/browser/chromeos/cros/native_network_parser.h" 33 #include "chrome/browser/chromeos/cros/native_network_parser.h"
34 #include "chrome/browser/chromeos/cros/network_ui_data.h"
35 #include "chrome/browser/chromeos/cros/onc_network_parser.h" 34 #include "chrome/browser/chromeos/cros/onc_network_parser.h"
36 #include "chrome/browser/chromeos/cros_settings.h" 35 #include "chrome/browser/chromeos/cros_settings.h"
37 #include "chrome/browser/chromeos/network_login_observer.h" 36 #include "chrome/browser/chromeos/network_login_observer.h"
38 #include "chrome/common/time_format.h" 37 #include "chrome/common/time_format.h"
39 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
40 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. 39 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN.
41 #include "grit/generated_resources.h" 40 #include "grit/generated_resources.h"
42 #include "net/base/x509_certificate.h" 41 #include "net/base/x509_certificate.h"
43 #include "third_party/cros_system_api/dbus/service_constants.h" 42 #include "third_party/cros_system_api/dbus/service_constants.h"
44 #include "ui/base/l10n/l10n_util.h" 43 #include "ui/base/l10n/l10n_util.h"
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 // virtual DisconnectFromNetwork implemented in derived classes. 1737 // virtual DisconnectFromNetwork implemented in derived classes.
1739 virtual void ForgetNetwork(const std::string& service_path) OVERRIDE; 1738 virtual void ForgetNetwork(const std::string& service_path) OVERRIDE;
1740 virtual void EnableEthernetNetworkDevice(bool enable) OVERRIDE; 1739 virtual void EnableEthernetNetworkDevice(bool enable) OVERRIDE;
1741 virtual void EnableWifiNetworkDevice(bool enable) OVERRIDE; 1740 virtual void EnableWifiNetworkDevice(bool enable) OVERRIDE;
1742 virtual void EnableCellularNetworkDevice(bool enable) OVERRIDE; 1741 virtual void EnableCellularNetworkDevice(bool enable) OVERRIDE;
1743 // virtual EnableOfflineMode implemented in derived classes. 1742 // virtual EnableOfflineMode implemented in derived classes.
1744 // virtual GetIPConfigs implemented in derived classes. 1743 // virtual GetIPConfigs implemented in derived classes.
1745 // virtual SetIPConfig implemented in derived classes. 1744 // virtual SetIPConfig implemented in derived classes.
1746 virtual void SwitchToPreferredNetwork() OVERRIDE; 1745 virtual void SwitchToPreferredNetwork() OVERRIDE;
1747 virtual bool LoadOncNetworks(const std::string& onc_blob, 1746 virtual bool LoadOncNetworks(const std::string& onc_blob,
1748 const std::string& passcode) OVERRIDE; 1747 const std::string& passcode,
1748 NetworkUIData::ONCSource source) OVERRIDE;
1749 virtual bool SetActiveNetwork(ConnectionType type, 1749 virtual bool SetActiveNetwork(ConnectionType type,
1750 const std::string& service_path) OVERRIDE; 1750 const std::string& service_path) OVERRIDE;
1751 1751
1752 protected: 1752 protected:
1753 typedef ObserverList<NetworkObserver> NetworkObserverList; 1753 typedef ObserverList<NetworkObserver> NetworkObserverList;
1754 typedef std::map<std::string, NetworkObserverList*> NetworkObserverMap; 1754 typedef std::map<std::string, NetworkObserverList*> NetworkObserverMap;
1755 1755
1756 typedef ObserverList<NetworkDeviceObserver> NetworkDeviceObserverList; 1756 typedef ObserverList<NetworkDeviceObserver> NetworkDeviceObserverList;
1757 typedef std::map<std::string, NetworkDeviceObserverList*> 1757 typedef std::map<std::string, NetworkDeviceObserverList*>
1758 NetworkDeviceObserverMap; 1758 NetworkDeviceObserverMap;
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 if (!wifi->preferred()) // All preferred networks are sorted in front. 2827 if (!wifi->preferred()) // All preferred networks are sorted in front.
2828 break; 2828 break;
2829 if (wifi->auto_connect()) { 2829 if (wifi->auto_connect()) {
2830 ConnectToWifiNetwork(wifi); 2830 ConnectToWifiNetwork(wifi);
2831 break; 2831 break;
2832 } 2832 }
2833 } 2833 }
2834 } 2834 }
2835 2835
2836 bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob, 2836 bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
2837 const std::string& passcode) { 2837 const std::string& passcode,
2838 NetworkUIData::ONCSource source) {
2838 // TODO(gspencer): Add support for decrypting onc files. crbug.com/19397 2839 // TODO(gspencer): Add support for decrypting onc files. crbug.com/19397
2839 OncNetworkParser parser(onc_blob); 2840 OncNetworkParser parser(onc_blob, source);
2840 2841
2841 for (int i = 0; i < parser.GetCertificatesSize(); i++) { 2842 for (int i = 0; i < parser.GetCertificatesSize(); i++) {
2842 // Insert each of the available certs into the certificate DB. 2843 // Insert each of the available certs into the certificate DB.
2843 if (parser.ParseCertificate(i).get() == NULL) { 2844 if (parser.ParseCertificate(i).get() == NULL) {
2844 DLOG(WARNING) << "Cannot parse certificate in ONC file"; 2845 DLOG(WARNING) << "Cannot parse certificate in ONC file";
2845 return false; 2846 return false;
2846 } 2847 }
2847 } 2848 }
2848 2849
2849 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) { 2850 for (int i = 0; i < parser.GetNetworkConfigsSize(); i++) {
(...skipping 2245 matching lines...) Expand 10 before | Expand all | Expand 10 after
5095 " \"GUID\": \"guid\"," 5096 " \"GUID\": \"guid\","
5096 " \"Type\": \"WiFi\"," 5097 " \"Type\": \"WiFi\","
5097 " \"WiFi\": {" 5098 " \"WiFi\": {"
5098 " \"Security\": \"WEP\"," 5099 " \"Security\": \"WEP\","
5099 " \"SSID\": \"MySSID\"," 5100 " \"SSID\": \"MySSID\","
5100 " }" 5101 " }"
5101 " }" 5102 " }"
5102 " ]," 5103 " ],"
5103 " \"Certificates\": []" 5104 " \"Certificates\": []"
5104 "}"); 5105 "}");
5105 LoadOncNetworks(test_blob, ""); 5106 LoadOncNetworks(test_blob, "", NetworkUIData::ONC_SOURCE_USER_IMPORT);
5106 } 5107 }
5107 5108
5108 //////////////////////////////////////////////////////////////////////////// 5109 ////////////////////////////////////////////////////////////////////////////
5109 // NetworkLibraryImplStub private methods. 5110 // NetworkLibraryImplStub private methods.
5110 5111
5111 void NetworkLibraryImplStub::AddStubNetwork( 5112 void NetworkLibraryImplStub::AddStubNetwork(
5112 Network* network, NetworkProfileType profile_type) { 5113 Network* network, NetworkProfileType profile_type) {
5113 network->priority_order_ = network_priority_order_++; 5114 network->priority_order_ = network_priority_order_++;
5114 network->CalculateUniqueId(); 5115 network->CalculateUniqueId();
5115 if (!network->unique_id().empty()) 5116 if (!network->unique_id().empty())
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
5343 return impl; 5344 return impl;
5344 } 5345 }
5345 5346
5346 ///////////////////////////////////////////////////////////////////////////// 5347 /////////////////////////////////////////////////////////////////////////////
5347 5348
5348 } // namespace chromeos 5349 } // namespace chromeos
5349 5350
5350 // Allows InvokeLater without adding refcounting. This class is a Singleton and 5351 // Allows InvokeLater without adding refcounting. This class is a Singleton and
5351 // won't be deleted until its last InvokeLater is run. 5352 // won't be deleted until its last InvokeLater is run.
5352 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); 5353 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698