| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cros_network_functions.h" | 5 #include "chrome/browser/chromeos/cros/cros_network_functions.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/cros/gvalue_util.h" | 10 #include "chrome/browser/chromeos/cros/gvalue_util.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 159 } |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 SMSMonitor monitor_; | 162 SMSMonitor monitor_; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 // Does nothing. Used as a callback. | 165 // Does nothing. Used as a callback. |
| 166 void DoNothing(DBusMethodCallStatus call_status) {} | 166 void DoNothing(DBusMethodCallStatus call_status) {} |
| 167 | 167 |
| 168 // Callback used by OnRequestNetworkProperties. | 168 // Callback used by OnRequestNetworkProperties. |
| 169 typedef base::Callback<void(const char* path, | 169 typedef base::Callback<void(const std::string& path, |
| 170 const base::DictionaryValue* properties) | 170 const base::DictionaryValue* properties) |
| 171 > OnRequestNetworkPropertiesCallback; | 171 > OnRequestNetworkPropertiesCallback; |
| 172 | 172 |
| 173 // Handles responses for RequestNetwork*Properties functions. | 173 // Handles responses for RequestNetwork*Properties functions. |
| 174 void OnRequestNetworkProperties(void* object, | 174 void OnRequestNetworkProperties(void* object, |
| 175 const char* path, | 175 const char* path, |
| 176 GHashTable* properties) { | 176 GHashTable* properties) { |
| 177 OnRequestNetworkPropertiesCallback* callback = | 177 OnRequestNetworkPropertiesCallback* callback = |
| 178 static_cast<OnRequestNetworkPropertiesCallback*>(object); | 178 static_cast<OnRequestNetworkPropertiesCallback*>(object); |
| 179 DictionaryValue* properties_dictionary = NULL; | 179 DictionaryValue* properties_dictionary = NULL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 197 if (key == NULL || gvalue == NULL || path == NULL || object == NULL) | 197 if (key == NULL || gvalue == NULL || path == NULL || object == NULL) |
| 198 return; | 198 return; |
| 199 NetworkPropertiesWatcherCallback* callback = | 199 NetworkPropertiesWatcherCallback* callback = |
| 200 static_cast<NetworkPropertiesWatcherCallback*>(object); | 200 static_cast<NetworkPropertiesWatcherCallback*>(object); |
| 201 scoped_ptr<Value> value(ConvertGValueToValue(gvalue)); | 201 scoped_ptr<Value> value(ConvertGValueToValue(gvalue)); |
| 202 callback->Run(path, key, *value); | 202 callback->Run(path, key, *value); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // A callback used to implement CrosRequest*Properties functions. | 205 // A callback used to implement CrosRequest*Properties functions. |
| 206 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, | 206 void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback, |
| 207 const char* path, | 207 const std::string& path, |
| 208 DBusMethodCallStatus call_status, | 208 DBusMethodCallStatus call_status, |
| 209 const base::DictionaryValue& value) { | 209 const base::DictionaryValue& value) { |
| 210 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); | 210 callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // A bool to remember whether we are using Libcros network functions or not. | 213 // A bool to remember whether we are using Libcros network functions or not. |
| 214 bool g_libcros_network_functions_enabled = true; | 214 bool g_libcros_network_functions_enabled = true; |
| 215 | 215 |
| 216 } // namespace | 216 } // namespace |
| 217 | 217 |
| 218 void SetLibcrosNetworkFunctionsEnabled(bool enabled) { | 218 void SetLibcrosNetworkFunctionsEnabled(bool enabled) { |
| 219 g_libcros_network_functions_enabled = enabled; | 219 g_libcros_network_functions_enabled = enabled; |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool CrosActivateCellularModem(const char* service_path, const char* carrier) { | 222 bool CrosActivateCellularModem(const std::string& service_path, |
| 223 return chromeos::ActivateCellularModem(service_path, carrier); | 223 const std::string& carrier) { |
| 224 return chromeos::ActivateCellularModem(service_path.c_str(), carrier.c_str()); |
| 224 } | 225 } |
| 225 | 226 |
| 226 void CrosSetNetworkServiceProperty(const char* service_path, | 227 void CrosSetNetworkServiceProperty(const std::string& service_path, |
| 227 const char* property, | 228 const std::string& property, |
| 228 const base::Value& value) { | 229 const base::Value& value) { |
| 229 if (g_libcros_network_functions_enabled) { | 230 if (g_libcros_network_functions_enabled) { |
| 230 ScopedGValue gvalue(ConvertValueToGValue(value)); | 231 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 231 chromeos::SetNetworkServicePropertyGValue(service_path, property, | 232 chromeos::SetNetworkServicePropertyGValue(service_path.c_str(), |
| 233 property.c_str(), |
| 232 gvalue.get()); | 234 gvalue.get()); |
| 233 } else { | 235 } else { |
| 234 DBusThreadManager::Get()->GetFlimflamServiceClient()->SetProperty( | 236 DBusThreadManager::Get()->GetFlimflamServiceClient()->SetProperty( |
| 235 dbus::ObjectPath(service_path), property, value, | 237 dbus::ObjectPath(service_path), property, value, |
| 236 base::Bind(&DoNothing)); | 238 base::Bind(&DoNothing)); |
| 237 } | 239 } |
| 238 } | 240 } |
| 239 | 241 |
| 240 void CrosClearNetworkServiceProperty(const char* service_path, | 242 void CrosClearNetworkServiceProperty(const std::string& service_path, |
| 241 const char* property) { | 243 const std::string& property) { |
| 242 if (g_libcros_network_functions_enabled) { | 244 if (g_libcros_network_functions_enabled) { |
| 243 chromeos::ClearNetworkServiceProperty(service_path, property); | 245 chromeos::ClearNetworkServiceProperty(service_path.c_str(), |
| 246 property.c_str()); |
| 244 } else { | 247 } else { |
| 245 DBusThreadManager::Get()->GetFlimflamServiceClient()->ClearProperty( | 248 DBusThreadManager::Get()->GetFlimflamServiceClient()->ClearProperty( |
| 246 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing)); | 249 dbus::ObjectPath(service_path), property, base::Bind(&DoNothing)); |
| 247 } | 250 } |
| 248 } | 251 } |
| 249 | 252 |
| 250 void CrosSetNetworkDeviceProperty(const char* device_path, | 253 void CrosSetNetworkDeviceProperty(const std::string& device_path, |
| 251 const char* property, | 254 const std::string& property, |
| 252 const base::Value& value) { | 255 const base::Value& value) { |
| 253 if (g_libcros_network_functions_enabled) { | 256 if (g_libcros_network_functions_enabled) { |
| 254 ScopedGValue gvalue(ConvertValueToGValue(value)); | 257 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 255 chromeos::SetNetworkDevicePropertyGValue(device_path, property, | 258 chromeos::SetNetworkDevicePropertyGValue(device_path.c_str(), |
| 259 property.c_str(), |
| 256 gvalue.get()); | 260 gvalue.get()); |
| 257 } else { | 261 } else { |
| 258 DBusThreadManager::Get()->GetFlimflamDeviceClient()->SetProperty( | 262 DBusThreadManager::Get()->GetFlimflamDeviceClient()->SetProperty( |
| 259 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing)); | 263 dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing)); |
| 260 } | 264 } |
| 261 } | 265 } |
| 262 | 266 |
| 263 void CrosSetNetworkIPConfigProperty(const char* ipconfig_path, | 267 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path, |
| 264 const char* property, | 268 const std::string& property, |
| 265 const base::Value& value) { | 269 const base::Value& value) { |
| 266 ScopedGValue gvalue(ConvertValueToGValue(value)); | 270 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 267 chromeos::SetNetworkIPConfigPropertyGValue(ipconfig_path, property, | 271 chromeos::SetNetworkIPConfigPropertyGValue(ipconfig_path.c_str(), |
| 272 property.c_str(), |
| 268 gvalue.get()); | 273 gvalue.get()); |
| 269 } | 274 } |
| 270 | 275 |
| 271 void CrosSetNetworkManagerProperty(const char* property, | 276 void CrosSetNetworkManagerProperty(const std::string& property, |
| 272 const base::Value& value) { | 277 const base::Value& value) { |
| 273 if (g_libcros_network_functions_enabled) { | 278 if (g_libcros_network_functions_enabled) { |
| 274 ScopedGValue gvalue(ConvertValueToGValue(value)); | 279 ScopedGValue gvalue(ConvertValueToGValue(value)); |
| 275 chromeos::SetNetworkManagerPropertyGValue(property, gvalue.get()); | 280 chromeos::SetNetworkManagerPropertyGValue(property.c_str(), gvalue.get()); |
| 276 } else { | 281 } else { |
| 277 DBusThreadManager::Get()->GetFlimflamManagerClient()->SetProperty( | 282 DBusThreadManager::Get()->GetFlimflamManagerClient()->SetProperty( |
| 278 property, value, base::Bind(&DoNothing)); | 283 property, value, base::Bind(&DoNothing)); |
| 279 } | 284 } |
| 280 } | 285 } |
| 281 | 286 |
| 282 void CrosDeleteServiceFromProfile(const char* profile_path, | 287 void CrosDeleteServiceFromProfile(const std::string& profile_path, |
| 283 const char* service_path) { | 288 const std::string& service_path) { |
| 284 if (g_libcros_network_functions_enabled) { | 289 if (g_libcros_network_functions_enabled) { |
| 285 chromeos::DeleteServiceFromProfile(profile_path, service_path); | 290 chromeos::DeleteServiceFromProfile(profile_path.c_str(), |
| 291 service_path.c_str()); |
| 286 } else { | 292 } else { |
| 287 DBusThreadManager::Get()->GetFlimflamProfileClient()->DeleteEntry( | 293 DBusThreadManager::Get()->GetFlimflamProfileClient()->DeleteEntry( |
| 288 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); | 294 dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing)); |
| 289 } | 295 } |
| 290 } | 296 } |
| 291 | 297 |
| 292 void CrosRequestCellularDataPlanUpdate(const char* modem_service_path) { | 298 void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) { |
| 293 if (g_libcros_network_functions_enabled) { | 299 if (g_libcros_network_functions_enabled) { |
| 294 chromeos::RequestCellularDataPlanUpdate(modem_service_path); | 300 chromeos::RequestCellularDataPlanUpdate(modem_service_path.c_str()); |
| 295 } else { | 301 } else { |
| 296 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( | 302 DBusThreadManager::Get()->GetCashewClient()->RequestDataPlansUpdate( |
| 297 modem_service_path); | 303 modem_service_path); |
| 298 } | 304 } |
| 299 } | 305 } |
| 300 | 306 |
| 301 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( | 307 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties( |
| 302 const NetworkPropertiesWatcherCallback& callback) { | 308 const NetworkPropertiesWatcherCallback& callback) { |
| 303 if (g_libcros_network_functions_enabled) | 309 if (g_libcros_network_functions_enabled) |
| 304 return new CrosNetworkManagerPropertiesWatcher(callback); | 310 return new CrosNetworkManagerPropertiesWatcher(callback); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 328 MonitorDataPlanCallback callback, void* object) { | 334 MonitorDataPlanCallback callback, void* object) { |
| 329 return new CrosDataPlanUpdateWatcher(callback, object); | 335 return new CrosDataPlanUpdateWatcher(callback, object); |
| 330 } | 336 } |
| 331 | 337 |
| 332 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, | 338 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, |
| 333 MonitorSMSCallback callback, | 339 MonitorSMSCallback callback, |
| 334 void* object) { | 340 void* object) { |
| 335 return new CrosSMSWatcher(modem_device_path, callback, object); | 341 return new CrosSMSWatcher(modem_device_path, callback, object); |
| 336 } | 342 } |
| 337 | 343 |
| 338 void CrosRequestNetworkServiceConnect(const char* service_path, | 344 void CrosRequestNetworkServiceConnect(const std::string& service_path, |
| 339 NetworkActionCallback callback, | 345 NetworkActionCallback callback, |
| 340 void* object) { | 346 void* object) { |
| 341 chromeos::RequestNetworkServiceConnect(service_path, callback, object); | 347 chromeos::RequestNetworkServiceConnect(service_path.c_str(), callback, |
| 348 object); |
| 342 } | 349 } |
| 343 | 350 |
| 344 void CrosRequestNetworkManagerProperties( | 351 void CrosRequestNetworkManagerProperties( |
| 345 const NetworkPropertiesCallback& callback) { | 352 const NetworkPropertiesCallback& callback) { |
| 346 if (g_libcros_network_functions_enabled) { | 353 if (g_libcros_network_functions_enabled) { |
| 347 // The newly allocated callback will be deleted in | 354 // The newly allocated callback will be deleted in |
| 348 // OnRequestNetworkProperties. | 355 // OnRequestNetworkProperties. |
| 349 chromeos::RequestNetworkManagerProperties( | 356 chromeos::RequestNetworkManagerProperties( |
| 350 &OnRequestNetworkProperties, | 357 &OnRequestNetworkProperties, |
| 351 new OnRequestNetworkPropertiesCallback(callback)); | 358 new OnRequestNetworkPropertiesCallback(callback)); |
| 352 } else { | 359 } else { |
| 353 DBusThreadManager::Get()->GetFlimflamManagerClient()->GetProperties( | 360 DBusThreadManager::Get()->GetFlimflamManagerClient()->GetProperties( |
| 354 base::Bind(&RunCallbackWithDictionaryValue, | 361 base::Bind(&RunCallbackWithDictionaryValue, |
| 355 callback, | 362 callback, |
| 356 flimflam::kFlimflamServicePath)); | 363 flimflam::kFlimflamServicePath)); |
| 357 } | 364 } |
| 358 } | 365 } |
| 359 | 366 |
| 360 void CrosRequestNetworkServiceProperties( | 367 void CrosRequestNetworkServiceProperties( |
| 361 const char* service_path, | 368 const std::string& service_path, |
| 362 const NetworkPropertiesCallback& callback) { | 369 const NetworkPropertiesCallback& callback) { |
| 363 if (g_libcros_network_functions_enabled) { | 370 if (g_libcros_network_functions_enabled) { |
| 364 // The newly allocated callback will be deleted in | 371 // The newly allocated callback will be deleted in |
| 365 // OnRequestNetworkProperties. | 372 // OnRequestNetworkProperties. |
| 366 chromeos::RequestNetworkServiceProperties( | 373 chromeos::RequestNetworkServiceProperties( |
| 367 service_path, | 374 service_path.c_str(), |
| 368 &OnRequestNetworkProperties, | 375 &OnRequestNetworkProperties, |
| 369 new OnRequestNetworkPropertiesCallback(callback)); | 376 new OnRequestNetworkPropertiesCallback(callback)); |
| 370 } else { | 377 } else { |
| 371 DBusThreadManager::Get()->GetFlimflamServiceClient()->GetProperties( | 378 DBusThreadManager::Get()->GetFlimflamServiceClient()->GetProperties( |
| 372 dbus::ObjectPath(service_path), | 379 dbus::ObjectPath(service_path), |
| 373 base::Bind(&RunCallbackWithDictionaryValue, callback, service_path)); | 380 base::Bind(&RunCallbackWithDictionaryValue, callback, service_path)); |
| 374 } | 381 } |
| 375 } | 382 } |
| 376 | 383 |
| 377 void CrosRequestNetworkDeviceProperties( | 384 void CrosRequestNetworkDeviceProperties( |
| 378 const char* device_path, | 385 const std::string& device_path, |
| 379 const NetworkPropertiesCallback& callback) { | 386 const NetworkPropertiesCallback& callback) { |
| 380 if (g_libcros_network_functions_enabled) { | 387 if (g_libcros_network_functions_enabled) { |
| 381 // The newly allocated callback will be deleted in | 388 // The newly allocated callback will be deleted in |
| 382 // OnRequestNetworkProperties. | 389 // OnRequestNetworkProperties. |
| 383 chromeos::RequestNetworkDeviceProperties( | 390 chromeos::RequestNetworkDeviceProperties( |
| 384 device_path, | 391 device_path.c_str(), |
| 385 &OnRequestNetworkProperties, | 392 &OnRequestNetworkProperties, |
| 386 new OnRequestNetworkPropertiesCallback(callback)); | 393 new OnRequestNetworkPropertiesCallback(callback)); |
| 387 } else { | 394 } else { |
| 388 DBusThreadManager::Get()->GetFlimflamDeviceClient()->GetProperties( | 395 DBusThreadManager::Get()->GetFlimflamDeviceClient()->GetProperties( |
| 389 dbus::ObjectPath(device_path), | 396 dbus::ObjectPath(device_path), |
| 390 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); | 397 base::Bind(&RunCallbackWithDictionaryValue, callback, device_path)); |
| 391 } | 398 } |
| 392 } | 399 } |
| 393 | 400 |
| 394 void CrosRequestNetworkProfileProperties( | 401 void CrosRequestNetworkProfileProperties( |
| 395 const char* profile_path, | 402 const std::string& profile_path, |
| 396 const NetworkPropertiesCallback& callback) { | 403 const NetworkPropertiesCallback& callback) { |
| 397 if (g_libcros_network_functions_enabled) { | 404 if (g_libcros_network_functions_enabled) { |
| 398 // The newly allocated callback will be deleted in | 405 // The newly allocated callback will be deleted in |
| 399 // OnRequestNetworkProperties. | 406 // OnRequestNetworkProperties. |
| 400 chromeos::RequestNetworkProfileProperties( | 407 chromeos::RequestNetworkProfileProperties( |
| 401 profile_path, | 408 profile_path.c_str(), |
| 402 &OnRequestNetworkProperties, | 409 &OnRequestNetworkProperties, |
| 403 new OnRequestNetworkPropertiesCallback(callback)); | 410 new OnRequestNetworkPropertiesCallback(callback)); |
| 404 } else { | 411 } else { |
| 405 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetProperties( | 412 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetProperties( |
| 406 dbus::ObjectPath(profile_path), | 413 dbus::ObjectPath(profile_path), |
| 407 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); | 414 base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path)); |
| 408 } | 415 } |
| 409 } | 416 } |
| 410 | 417 |
| 411 void CrosRequestNetworkProfileEntryProperties( | 418 void CrosRequestNetworkProfileEntryProperties( |
| 412 const char* profile_path, | 419 const std::string& profile_path, |
| 413 const char* profile_entry_path, | 420 const std::string& profile_entry_path, |
| 414 const NetworkPropertiesCallback& callback) { | 421 const NetworkPropertiesCallback& callback) { |
| 415 if (g_libcros_network_functions_enabled) { | 422 if (g_libcros_network_functions_enabled) { |
| 416 // The newly allocated callback will be deleted in | 423 // The newly allocated callback will be deleted in |
| 417 // OnRequestNetworkProperties. | 424 // OnRequestNetworkProperties. |
| 418 chromeos::RequestNetworkProfileEntryProperties( | 425 chromeos::RequestNetworkProfileEntryProperties( |
| 419 profile_path, | 426 profile_path.c_str(), |
| 420 profile_entry_path, | 427 profile_entry_path.c_str(), |
| 421 &OnRequestNetworkProperties, | 428 &OnRequestNetworkProperties, |
| 422 new OnRequestNetworkPropertiesCallback(callback)); | 429 new OnRequestNetworkPropertiesCallback(callback)); |
| 423 } else { | 430 } else { |
| 424 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetEntry( | 431 DBusThreadManager::Get()->GetFlimflamProfileClient()->GetEntry( |
| 425 dbus::ObjectPath(profile_path), | 432 dbus::ObjectPath(profile_path), |
| 426 profile_entry_path, | 433 profile_entry_path, |
| 427 base::Bind(&RunCallbackWithDictionaryValue, | 434 base::Bind(&RunCallbackWithDictionaryValue, |
| 428 callback, | 435 callback, |
| 429 profile_entry_path)); | 436 profile_entry_path)); |
| 430 } | 437 } |
| 431 } | 438 } |
| 432 | 439 |
| 433 void CrosRequestHiddenWifiNetworkProperties( | 440 void CrosRequestHiddenWifiNetworkProperties( |
| 434 const char* ssid, | 441 const std::string& ssid, |
| 435 const char* security, | 442 const std::string& security, |
| 436 const NetworkPropertiesCallback& callback) { | 443 const NetworkPropertiesCallback& callback) { |
| 437 // The newly allocated callback will be deleted in OnRequestNetworkProperties. | 444 // The newly allocated callback will be deleted in OnRequestNetworkProperties. |
| 438 chromeos::RequestHiddenWifiNetworkProperties( | 445 chromeos::RequestHiddenWifiNetworkProperties( |
| 439 ssid, | 446 ssid.c_str(), |
| 440 security, | 447 security.c_str(), |
| 441 &OnRequestNetworkProperties, | 448 &OnRequestNetworkProperties, |
| 442 new OnRequestNetworkPropertiesCallback(callback)); | 449 new OnRequestNetworkPropertiesCallback(callback)); |
| 443 } | 450 } |
| 444 | 451 |
| 445 void CrosRequestVirtualNetworkProperties( | 452 void CrosRequestVirtualNetworkProperties( |
| 446 const char* service_name, | 453 const std::string& service_name, |
| 447 const char* server_hostname, | 454 const std::string& server_hostname, |
| 448 const char* provider_type, | 455 const std::string& provider_type, |
| 449 const NetworkPropertiesCallback& callback) { | 456 const NetworkPropertiesCallback& callback) { |
| 450 // The newly allocated callback will be deleted in OnRequestNetworkProperties. | 457 // The newly allocated callback will be deleted in OnRequestNetworkProperties. |
| 451 chromeos::RequestVirtualNetworkProperties( | 458 chromeos::RequestVirtualNetworkProperties( |
| 452 service_name, | 459 service_name.c_str(), |
| 453 server_hostname, | 460 server_hostname.c_str(), |
| 454 provider_type, | 461 provider_type.c_str(), |
| 455 &OnRequestNetworkProperties, | 462 &OnRequestNetworkProperties, |
| 456 new OnRequestNetworkPropertiesCallback(callback)); | 463 new OnRequestNetworkPropertiesCallback(callback)); |
| 457 } | 464 } |
| 458 | 465 |
| 459 void CrosRequestNetworkServiceDisconnect(const char* service_path) { | 466 void CrosRequestNetworkServiceDisconnect(const std::string& service_path) { |
| 460 if (g_libcros_network_functions_enabled) { | 467 if (g_libcros_network_functions_enabled) { |
| 461 chromeos::RequestNetworkServiceDisconnect(service_path); | 468 chromeos::RequestNetworkServiceDisconnect(service_path.c_str()); |
| 462 } else { | 469 } else { |
| 463 DBusThreadManager::Get()->GetFlimflamServiceClient()->Disconnect( | 470 DBusThreadManager::Get()->GetFlimflamServiceClient()->Disconnect( |
| 464 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); | 471 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); |
| 465 } | 472 } |
| 466 } | 473 } |
| 467 | 474 |
| 468 void CrosRequestRemoveNetworkService(const char* service_path) { | 475 void CrosRequestRemoveNetworkService(const std::string& service_path) { |
| 469 if (g_libcros_network_functions_enabled) { | 476 if (g_libcros_network_functions_enabled) { |
| 470 chromeos::RequestRemoveNetworkService(service_path); | 477 chromeos::RequestRemoveNetworkService(service_path.c_str()); |
| 471 } else { | 478 } else { |
| 472 DBusThreadManager::Get()->GetFlimflamServiceClient()->Remove( | 479 DBusThreadManager::Get()->GetFlimflamServiceClient()->Remove( |
| 473 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); | 480 dbus::ObjectPath(service_path), base::Bind(&DoNothing)); |
| 474 } | 481 } |
| 475 } | 482 } |
| 476 | 483 |
| 477 void CrosRequestNetworkScan(const char* network_type) { | 484 void CrosRequestNetworkScan(const std::string& network_type) { |
| 478 if (g_libcros_network_functions_enabled) { | 485 if (g_libcros_network_functions_enabled) { |
| 479 chromeos::RequestNetworkScan(network_type); | 486 chromeos::RequestNetworkScan(network_type.c_str()); |
| 480 } else { | 487 } else { |
| 481 DBusThreadManager::Get()->GetFlimflamManagerClient()->RequestScan( | 488 DBusThreadManager::Get()->GetFlimflamManagerClient()->RequestScan( |
| 482 network_type, base::Bind(&DoNothing)); | 489 network_type, base::Bind(&DoNothing)); |
| 483 } | 490 } |
| 484 } | 491 } |
| 485 | 492 |
| 486 void CrosRequestNetworkDeviceEnable(const char* network_type, bool enable) { | 493 void CrosRequestNetworkDeviceEnable(const std::string& network_type, |
| 494 bool enable) { |
| 487 if (g_libcros_network_functions_enabled) { | 495 if (g_libcros_network_functions_enabled) { |
| 488 chromeos::RequestNetworkDeviceEnable(network_type, enable); | 496 chromeos::RequestNetworkDeviceEnable(network_type.c_str(), enable); |
| 489 } else { | 497 } else { |
| 490 if (enable) { | 498 if (enable) { |
| 491 DBusThreadManager::Get()->GetFlimflamManagerClient()->EnableTechnology( | 499 DBusThreadManager::Get()->GetFlimflamManagerClient()->EnableTechnology( |
| 492 network_type, base::Bind(&DoNothing)); | 500 network_type, base::Bind(&DoNothing)); |
| 493 } else { | 501 } else { |
| 494 DBusThreadManager::Get()->GetFlimflamManagerClient()->DisableTechnology( | 502 DBusThreadManager::Get()->GetFlimflamManagerClient()->DisableTechnology( |
| 495 network_type, base::Bind(&DoNothing)); | 503 network_type, base::Bind(&DoNothing)); |
| 496 } | 504 } |
| 497 } | 505 } |
| 498 } | 506 } |
| 499 | 507 |
| 500 void CrosRequestRequirePin(const char* device_path, | 508 void CrosRequestRequirePin(const std::string& device_path, |
| 501 const char* pin, | 509 const std::string& pin, |
| 502 bool enable, | 510 bool enable, |
| 503 NetworkActionCallback callback, | 511 NetworkActionCallback callback, |
| 504 void* object) { | 512 void* object) { |
| 505 chromeos::RequestRequirePin(device_path, pin, enable, callback, object); | 513 chromeos::RequestRequirePin(device_path.c_str(), pin.c_str(), enable, |
| 514 callback, object); |
| 506 } | 515 } |
| 507 | 516 |
| 508 void CrosRequestEnterPin(const char* device_path, | 517 void CrosRequestEnterPin(const std::string& device_path, |
| 509 const char* pin, | 518 const std::string& pin, |
| 510 NetworkActionCallback callback, | 519 NetworkActionCallback callback, |
| 511 void* object) { | 520 void* object) { |
| 512 chromeos::RequestEnterPin(device_path, pin, callback, object); | 521 chromeos::RequestEnterPin(device_path.c_str(), pin.c_str(), callback, object); |
| 513 } | 522 } |
| 514 | 523 |
| 515 void CrosRequestUnblockPin(const char* device_path, | 524 void CrosRequestUnblockPin(const std::string& device_path, |
| 516 const char* unblock_code, | 525 const std::string& unblock_code, |
| 517 const char* pin, | 526 const std::string& pin, |
| 518 NetworkActionCallback callback, | 527 NetworkActionCallback callback, |
| 519 void* object) { | 528 void* object) { |
| 520 chromeos::RequestUnblockPin(device_path, unblock_code, pin, callback, object); | 529 chromeos::RequestUnblockPin(device_path.c_str(), unblock_code.c_str(), |
| 530 pin.c_str(), callback, object); |
| 521 } | 531 } |
| 522 | 532 |
| 523 void CrosRequestChangePin(const char* device_path, | 533 void CrosRequestChangePin(const std::string& device_path, |
| 524 const char* old_pin, | 534 const std::string& old_pin, |
| 525 const char* new_pin, | 535 const std::string& new_pin, |
| 526 NetworkActionCallback callback, | 536 NetworkActionCallback callback, |
| 527 void* object) { | 537 void* object) { |
| 528 chromeos::RequestChangePin(device_path, old_pin, new_pin, callback, object); | 538 chromeos::RequestChangePin(device_path.c_str(), old_pin.c_str(), |
| 539 new_pin.c_str(), callback, object); |
| 529 } | 540 } |
| 530 | 541 |
| 531 void CrosProposeScan(const char* device_path) { | 542 void CrosProposeScan(const std::string& device_path) { |
| 532 chromeos::ProposeScan(device_path); | 543 chromeos::ProposeScan(device_path.c_str()); |
| 533 } | 544 } |
| 534 | 545 |
| 535 void CrosRequestCellularRegister(const char* device_path, | 546 void CrosRequestCellularRegister(const std::string& device_path, |
| 536 const char* network_id, | 547 const std::string& network_id, |
| 537 chromeos::NetworkActionCallback callback, | 548 chromeos::NetworkActionCallback callback, |
| 538 void* object) { | 549 void* object) { |
| 539 chromeos::RequestCellularRegister(device_path, network_id, callback, object); | 550 chromeos::RequestCellularRegister(device_path.c_str(), network_id.c_str(), |
| 551 callback, object); |
| 540 } | 552 } |
| 541 | 553 |
| 542 bool CrosSetOfflineMode(bool offline) { | 554 bool CrosSetOfflineMode(bool offline) { |
| 543 return chromeos::SetOfflineMode(offline); | 555 return chromeos::SetOfflineMode(offline); |
| 544 } | 556 } |
| 545 | 557 |
| 546 IPConfigStatus* CrosListIPConfigs(const char* device_path) { | 558 IPConfigStatus* CrosListIPConfigs(const std::string& device_path) { |
| 547 return chromeos::ListIPConfigs(device_path); | 559 return chromeos::ListIPConfigs(device_path.c_str()); |
| 548 } | 560 } |
| 549 | 561 |
| 550 bool CrosAddIPConfig(const char* device_path, IPConfigType type) { | 562 bool CrosAddIPConfig(const std::string& device_path, IPConfigType type) { |
| 551 return chromeos::AddIPConfig(device_path, type); | 563 return chromeos::AddIPConfig(device_path.c_str(), type); |
| 552 } | 564 } |
| 553 | 565 |
| 554 bool CrosRemoveIPConfig(IPConfig* config) { | 566 bool CrosRemoveIPConfig(IPConfig* config) { |
| 555 return chromeos::RemoveIPConfig(config); | 567 return chromeos::RemoveIPConfig(config); |
| 556 } | 568 } |
| 557 | 569 |
| 558 void CrosFreeIPConfigStatus(IPConfigStatus* status) { | 570 void CrosFreeIPConfigStatus(IPConfigStatus* status) { |
| 559 chromeos::FreeIPConfigStatus(status); | 571 chromeos::FreeIPConfigStatus(status); |
| 560 } | 572 } |
| 561 | 573 |
| 562 DeviceNetworkList* CrosGetDeviceNetworkList() { | 574 DeviceNetworkList* CrosGetDeviceNetworkList() { |
| 563 return chromeos::GetDeviceNetworkList(); | 575 return chromeos::GetDeviceNetworkList(); |
| 564 } | 576 } |
| 565 | 577 |
| 566 void CrosFreeDeviceNetworkList(DeviceNetworkList* network_list) { | 578 void CrosFreeDeviceNetworkList(DeviceNetworkList* network_list) { |
| 567 chromeos::FreeDeviceNetworkList(network_list); | 579 chromeos::FreeDeviceNetworkList(network_list); |
| 568 } | 580 } |
| 569 | 581 |
| 570 void CrosConfigureService(const char* identifier, | 582 void CrosConfigureService(const std::string& identifier, |
| 571 const base::DictionaryValue& properties, | 583 const base::DictionaryValue& properties, |
| 572 NetworkActionCallback callback, | 584 NetworkActionCallback callback, |
| 573 void* object) { | 585 void* object) { |
| 574 ScopedGHashTable ghash( | 586 ScopedGHashTable ghash( |
| 575 ConvertDictionaryValueToStringValueGHashTable(properties)); | 587 ConvertDictionaryValueToStringValueGHashTable(properties)); |
| 576 chromeos::ConfigureService(identifier, ghash.get(), callback, object); | 588 chromeos::ConfigureService(identifier.c_str(), ghash.get(), callback, object); |
| 577 } | 589 } |
| 578 | 590 |
| 579 } // namespace chromeos | 591 } // namespace chromeos |
| OLD | NEW |