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/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 | 8 |
9 #include "base/i18n/icu_encoding_detection.h" | 9 #include "base/i18n/icu_encoding_detection.h" |
10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 | 304 |
305 void Network::CopyCredentialsFromRemembered(Network* remembered) { | 305 void Network::CopyCredentialsFromRemembered(Network* remembered) { |
306 } | 306 } |
307 | 307 |
308 void Network::SetValueProperty(const char* prop, Value* value) { | 308 void Network::SetValueProperty(const char* prop, Value* value) { |
309 DCHECK(prop); | 309 DCHECK(prop); |
310 DCHECK(value); | 310 DCHECK(value); |
311 if (!EnsureCrosLoaded()) | 311 if (!EnsureCrosLoaded()) |
312 return; | 312 return; |
313 CrosSetNetworkServiceProperty(service_path_.c_str(), prop, *value); | 313 CrosSetNetworkServiceProperty(service_path_, prop, *value); |
314 } | 314 } |
315 | 315 |
316 void Network::ClearProperty(const char* prop) { | 316 void Network::ClearProperty(const char* prop) { |
317 DCHECK(prop); | 317 DCHECK(prop); |
318 if (!EnsureCrosLoaded()) | 318 if (!EnsureCrosLoaded()) |
319 return; | 319 return; |
320 CrosClearNetworkServiceProperty(service_path_.c_str(), prop); | 320 CrosClearNetworkServiceProperty(service_path_, prop); |
321 } | 321 } |
322 | 322 |
323 void Network::SetStringProperty( | 323 void Network::SetStringProperty( |
324 const char* prop, const std::string& str, std::string* dest) { | 324 const char* prop, const std::string& str, std::string* dest) { |
325 if (dest) | 325 if (dest) |
326 *dest = str; | 326 *dest = str; |
327 scoped_ptr<Value> value(Value::CreateStringValue(str)); | 327 scoped_ptr<Value> value(Value::CreateStringValue(str)); |
328 SetValueProperty(prop, value.get()); | 328 SetValueProperty(prop, value.get()); |
329 } | 329 } |
330 | 330 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 SetOrClearStringProperty( | 478 SetOrClearStringProperty( |
479 flimflam::kProxyConfigProperty, proxy_config, &proxy_config_); | 479 flimflam::kProxyConfigProperty, proxy_config, &proxy_config_); |
480 } | 480 } |
481 | 481 |
482 void Network::InitIPAddress() { | 482 void Network::InitIPAddress() { |
483 ip_address_.clear(); | 483 ip_address_.clear(); |
484 if (!EnsureCrosLoaded()) | 484 if (!EnsureCrosLoaded()) |
485 return; | 485 return; |
486 // If connected, get ip config. | 486 // If connected, get ip config. |
487 if (connected() && !device_path_.empty()) { | 487 if (connected() && !device_path_.empty()) { |
488 IPConfigStatus* ipconfig_status = CrosListIPConfigs(device_path_.c_str()); | 488 IPConfigStatus* ipconfig_status = CrosListIPConfigs(device_path_); |
489 if (ipconfig_status) { | 489 if (ipconfig_status) { |
490 for (int i = 0; i < ipconfig_status->size; ++i) { | 490 for (int i = 0; i < ipconfig_status->size; ++i) { |
491 IPConfig ipconfig = ipconfig_status->ips[i]; | 491 IPConfig ipconfig = ipconfig_status->ips[i]; |
492 if (strlen(ipconfig.address) > 0) { | 492 if (strlen(ipconfig.address) > 0) { |
493 ip_address_ = ipconfig.address; | 493 ip_address_ = ipconfig.address; |
494 break; | 494 break; |
495 } | 495 } |
496 } | 496 } |
497 CrosFreeIPConfigStatus(ipconfig_status); | 497 CrosFreeIPConfigStatus(ipconfig_status); |
498 } | 498 } |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 using_post_(false), | 1004 using_post_(false), |
1005 data_left_(DATA_UNKNOWN) { | 1005 data_left_(DATA_UNKNOWN) { |
1006 } | 1006 } |
1007 | 1007 |
1008 CellularNetwork::~CellularNetwork() { | 1008 CellularNetwork::~CellularNetwork() { |
1009 } | 1009 } |
1010 | 1010 |
1011 bool CellularNetwork::StartActivation() { | 1011 bool CellularNetwork::StartActivation() { |
1012 if (!EnsureCrosLoaded()) | 1012 if (!EnsureCrosLoaded()) |
1013 return false; | 1013 return false; |
1014 if (!CrosActivateCellularModem(service_path().c_str(), "")) | 1014 if (!CrosActivateCellularModem(service_path(), "")) |
1015 return false; | 1015 return false; |
1016 // Don't wait for flimflam to tell us that we are really activating since | 1016 // Don't wait for flimflam to tell us that we are really activating since |
1017 // other notifications in the message loop might cause us to think that | 1017 // other notifications in the message loop might cause us to think that |
1018 // the process hasn't started yet. | 1018 // the process hasn't started yet. |
1019 activation_state_ = ACTIVATION_STATE_ACTIVATING; | 1019 activation_state_ = ACTIVATION_STATE_ACTIVATING; |
1020 return true; | 1020 return true; |
1021 } | 1021 } |
1022 | 1022 |
1023 void CellularNetwork::RefreshDataPlansIfNeeded() const { | 1023 void CellularNetwork::RefreshDataPlansIfNeeded() const { |
1024 if (!EnsureCrosLoaded()) | 1024 if (!EnsureCrosLoaded()) |
1025 return; | 1025 return; |
1026 if (connected() && activated()) | 1026 if (connected() && activated()) |
1027 CrosRequestCellularDataPlanUpdate(service_path().c_str()); | 1027 CrosRequestCellularDataPlanUpdate(service_path()); |
1028 } | 1028 } |
1029 | 1029 |
1030 void CellularNetwork::SetApn(const CellularApn& apn) { | 1030 void CellularNetwork::SetApn(const CellularApn& apn) { |
1031 if (!apn.apn.empty()) { | 1031 if (!apn.apn.empty()) { |
1032 DictionaryValue value; | 1032 DictionaryValue value; |
1033 // Only use the fields that are needed for establishing | 1033 // Only use the fields that are needed for establishing |
1034 // connections, and ignore the rest. | 1034 // connections, and ignore the rest. |
1035 value.SetString(flimflam::kApnProperty, apn.apn); | 1035 value.SetString(flimflam::kApnProperty, apn.apn); |
1036 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); | 1036 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); |
1037 value.SetString(flimflam::kApnUsernameProperty, apn.username); | 1037 value.SetString(flimflam::kApnUsernameProperty, apn.username); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 NetworkLibrary* impl; | 1472 NetworkLibrary* impl; |
1473 if (stub) | 1473 if (stub) |
1474 impl = new NetworkLibraryImplStub(); | 1474 impl = new NetworkLibraryImplStub(); |
1475 else | 1475 else |
1476 impl = new NetworkLibraryImplCros(); | 1476 impl = new NetworkLibraryImplCros(); |
1477 impl->Init(); | 1477 impl->Init(); |
1478 return impl; | 1478 return impl; |
1479 } | 1479 } |
1480 | 1480 |
1481 } // namespace chromeos | 1481 } // namespace chromeos |
OLD | NEW |