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

Unified Diff: chrome/browser/chromeos/cros/cros_network_functions.cc

Issue 10164026: Reimplement RequestHiddenWifiNetworkProperties and RequestVirtualNetworkProperties without Libcros (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and review fix Created 8 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/cros_network_functions_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/cros_network_functions.cc
diff --git a/chrome/browser/chromeos/cros/cros_network_functions.cc b/chrome/browser/chromeos/cros/cros_network_functions.cc
index 1a43a3e3bcf80cb148a64a8760ca282250f2dd52..c61525bec6979276fad9e526fc4ee20aaa6970ee 100644
--- a/chrome/browser/chromeos/cros/cros_network_functions.cc
+++ b/chrome/browser/chromeos/cros/cros_network_functions.cc
@@ -211,6 +211,18 @@ void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback,
callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL);
}
+// Used as a callback for FlimflamManagerClient::GetService
+void OnGetService(const NetworkPropertiesCallback& callback,
+ DBusMethodCallStatus call_status,
+ const dbus::ObjectPath& service_path) {
+ if (call_status == DBUS_METHOD_CALL_SUCCESS) {
+ DBusThreadManager::Get()->GetFlimflamServiceClient()->GetProperties(
+ service_path, base::Bind(&RunCallbackWithDictionaryValue,
+ callback,
+ service_path.value()));
+ }
+}
+
// Used as a callback for chromeos::ConfigureService.
void OnConfigureService(void* object,
const char* service_path,
@@ -465,12 +477,34 @@ void CrosRequestHiddenWifiNetworkProperties(
const std::string& ssid,
const std::string& security,
const NetworkPropertiesCallback& callback) {
- // The newly allocated callback will be deleted in OnRequestNetworkProperties.
- chromeos::RequestHiddenWifiNetworkProperties(
- ssid.c_str(),
- security.c_str(),
- &OnRequestNetworkProperties,
- new OnRequestNetworkPropertiesCallback(callback));
+ if (g_libcros_network_functions_enabled) {
+ // The newly allocated callback will be deleted in
+ // OnRequestNetworkProperties.
+ chromeos::RequestHiddenWifiNetworkProperties(
+ ssid.c_str(),
+ security.c_str(),
+ &OnRequestNetworkProperties,
+ new OnRequestNetworkPropertiesCallback(callback));
+ } else {
+ base::DictionaryValue properties;
+ properties.SetWithoutPathExpansion(
+ flimflam::kModeProperty,
+ base::Value::CreateStringValue(flimflam::kModeManaged));
+ properties.SetWithoutPathExpansion(
+ flimflam::kTypeProperty,
+ base::Value::CreateStringValue(flimflam::kTypeWifi));
+ properties.SetWithoutPathExpansion(
+ flimflam::kSSIDProperty,
+ base::Value::CreateStringValue(ssid));
+ properties.SetWithoutPathExpansion(
+ flimflam::kSecurityProperty,
+ base::Value::CreateStringValue(security));
+ // flimflam.Manger.GetService() will apply the property changes in
+ // |properties| and return a new or existing service to OnGetService().
+ // OnGetService will then call GetProperties which will then call callback.
+ DBusThreadManager::Get()->GetFlimflamManagerClient()->GetService(
+ properties, base::Bind(&OnGetService, callback));
+ }
}
void CrosRequestVirtualNetworkProperties(
@@ -478,13 +512,40 @@ void CrosRequestVirtualNetworkProperties(
const std::string& server_hostname,
const std::string& provider_type,
const NetworkPropertiesCallback& callback) {
- // The newly allocated callback will be deleted in OnRequestNetworkProperties.
- chromeos::RequestVirtualNetworkProperties(
- service_name.c_str(),
- server_hostname.c_str(),
- provider_type.c_str(),
- &OnRequestNetworkProperties,
- new OnRequestNetworkPropertiesCallback(callback));
+ if (g_libcros_network_functions_enabled) {
+ // The newly allocated callback will be deleted in
+ // OnRequestNetworkProperties.
+ chromeos::RequestVirtualNetworkProperties(
+ service_name.c_str(),
+ server_hostname.c_str(),
+ provider_type.c_str(),
+ &OnRequestNetworkProperties,
+ new OnRequestNetworkPropertiesCallback(callback));
+ } else {
+ base::DictionaryValue properties;
+ properties.SetWithoutPathExpansion(
+ flimflam::kTypeProperty,
+ base::Value::CreateStringValue(flimflam::kTypeVPN));
+ properties.SetWithoutPathExpansion(
+ flimflam::kProviderNameProperty,
+ base::Value::CreateStringValue(service_name));
+ properties.SetWithoutPathExpansion(
+ flimflam::kProviderHostProperty,
+ base::Value::CreateStringValue(server_hostname));
+ properties.SetWithoutPathExpansion(
+ flimflam::kProviderTypeProperty,
+ base::Value::CreateStringValue(provider_type));
+ // The actual value of Domain does not matter, so just use service_name.
+ properties.SetWithoutPathExpansion(
+ flimflam::kVPNDomainProperty,
+ base::Value::CreateStringValue(service_name));
+
+ // flimflam.Manger.GetService() will apply the property changes in
+ // |properties| and pass a new or existing service to OnGetService().
+ // OnGetService will then call GetProperties which will then call callback.
+ DBusThreadManager::Get()->GetFlimflamManagerClient()->GetService(
+ properties, base::Bind(&OnGetService, callback));
+ }
}
void CrosRequestNetworkServiceDisconnect(const std::string& service_path) {
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/cros_network_functions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698