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 647b3a8f751d8dbf114e0a54e264ba515e6d8b37..daceafbcb21c28e5e23e35f1b12076ca0bd9edfe 100644 |
--- a/chrome/browser/chromeos/cros/cros_network_functions.cc |
+++ b/chrome/browser/chromeos/cros/cros_network_functions.cc |
@@ -8,11 +8,17 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/values.h" |
#include "chrome/browser/chromeos/cros/gvalue_util.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/flimflam_profile_client.h" |
+#include "dbus/object_path.h" |
namespace chromeos { |
namespace { |
+// Does nothing. Used as a callback. |
+void DoNothing(DBusMethodCallStatus call_status) {} |
+ |
// Callback used by OnRequestNetworkProperties. |
typedef base::Callback<void(const char* path, |
const base::DictionaryValue* properties) |
@@ -37,8 +43,23 @@ void OnRequestNetworkProperties(void* object, |
callback->Run(path, properties_dictionary); |
} |
+// A callback used to implement CrosRequest*Properties functions. |
+void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, |
+ const char* path, |
+ DBusMethodCallStatus call_status, |
+ const base::DictionaryValue& value) { |
+ callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); |
+} |
+ |
+// A bool to remember whether we are using non-Libcros implementation or not. |
+bool g_non_libcros_network_functions_enabled = false; |
+ |
} // namespace |
+void EnableNonLibcrosNetworkFunctions(bool enabled) { |
+ g_non_libcros_network_functions_enabled = enabled; |
+} |
+ |
bool CrosActivateCellularModem(const char* service_path, const char* carrier) { |
return chromeos::ActivateCellularModem(service_path, carrier); |
} |
@@ -79,7 +100,13 @@ void CrosSetNetworkManagerProperty(const char* property, |
void CrosDeleteServiceFromProfile(const char* profile_path, |
const char* service_path) { |
- chromeos::DeleteServiceFromProfile(profile_path, service_path); |
+ if (!g_non_libcros_network_functions_enabled) { |
+ // Use Libcros. |
+ chromeos::DeleteServiceFromProfile(profile_path, service_path); |
+ return; |
stevenjb
2012/04/12 17:34:36
I don't think this is a good place for early-exit
hashimoto
2012/04/13 05:27:22
I thought new (non libcros) implementations may be
|
+ } |
+ DBusThreadManager::Get()->GetFlimflamProfileClient()->DeleteEntry( |
+ dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); |
} |
void CrosRequestCellularDataPlanUpdate(const char* modem_service_path) { |
@@ -170,23 +197,42 @@ void CrosRequestNetworkDeviceProperties( |
void CrosRequestNetworkProfileProperties( |
const char* profile_path, |
const NetworkPropertiesCallback& callback) { |
- // The newly allocated callback will be deleted in OnRequestNetworkProperties. |
- chromeos::RequestNetworkProfileProperties( |
- profile_path, |
- &OnRequestNetworkProperties, |
- new OnRequestNetworkPropertiesCallback(callback)); |
+ if (!g_non_libcros_network_functions_enabled) { |
+ // Use Libcros. |
stevenjb
2012/04/12 17:34:36
unnecessary comment here and elsewhere
hashimoto
2012/04/13 05:27:22
Done.
|
+ // The newly allocated callback will be deleted in |
+ // OnRequestNetworkProperties. |
+ chromeos::RequestNetworkProfileProperties( |
+ profile_path, |
+ &OnRequestNetworkProperties, |
+ new OnRequestNetworkPropertiesCallback(callback)); |
+ return; |
+ } |
+ DBusThreadManager::Get()->GetFlimflamProfileClient()->GetProperties( |
+ dbus::ObjectPath(profile_path), |
+ base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); |
} |
void CrosRequestNetworkProfileEntryProperties( |
const char* profile_path, |
const char* profile_entry_path, |
const NetworkPropertiesCallback& callback) { |
- // The newly allocated callback will be deleted in OnRequestNetworkProperties. |
- chromeos::RequestNetworkProfileEntryProperties( |
- profile_path, |
+ if (!g_non_libcros_network_functions_enabled) { |
+ // Use Libcros. |
+ // The newly allocated callback will be deleted in |
+ // OnRequestNetworkProperties. |
+ chromeos::RequestNetworkProfileEntryProperties( |
+ profile_path, |
+ profile_entry_path, |
+ &OnRequestNetworkProperties, |
+ new OnRequestNetworkPropertiesCallback(callback)); |
+ return; |
+ } |
+ DBusThreadManager::Get()->GetFlimflamProfileClient()->GetEntry( |
+ dbus::ObjectPath(profile_path), |
profile_entry_path, |
- &OnRequestNetworkProperties, |
- new OnRequestNetworkPropertiesCallback(callback)); |
+ base::Bind(&RunCallbackWithDictionaryValue, |
+ callback, |
+ profile_entry_path)); |
} |
void CrosRequestHiddenWifiNetworkProperties( |