| 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 "base/i18n/icu_encoding_detection.h" | 7 #include "base/i18n/icu_encoding_detection.h" |
| 8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/json/json_writer.h" // for debug output only. | 10 #include "base/json/json_writer.h" // for debug output only. |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 unique_id_ = name_; | 352 unique_id_ = name_; |
| 353 } | 353 } |
| 354 | 354 |
| 355 bool Network::RequiresUserProfile() const { | 355 bool Network::RequiresUserProfile() const { |
| 356 return false; | 356 return false; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void Network::CopyCredentialsFromRemembered(Network* remembered) { | 359 void Network::CopyCredentialsFromRemembered(Network* remembered) { |
| 360 } | 360 } |
| 361 | 361 |
| 362 void Network::SetValueProperty(const char* prop, Value* value) { | 362 void Network::SetValueProperty(const char* prop, const base::Value& value) { |
| 363 DCHECK(prop); | 363 DCHECK(prop); |
| 364 DCHECK(value); | |
| 365 if (!EnsureCrosLoaded()) | 364 if (!EnsureCrosLoaded()) |
| 366 return; | 365 return; |
| 367 CrosSetNetworkServiceProperty(service_path_, prop, *value); | 366 CrosSetNetworkServiceProperty(service_path_, prop, value); |
| 368 } | 367 } |
| 369 | 368 |
| 370 void Network::ClearProperty(const char* prop) { | 369 void Network::ClearProperty(const char* prop) { |
| 371 DCHECK(prop); | 370 DCHECK(prop); |
| 372 if (!EnsureCrosLoaded()) | 371 if (!EnsureCrosLoaded()) |
| 373 return; | 372 return; |
| 374 CrosClearNetworkServiceProperty(service_path_, prop); | 373 CrosClearNetworkServiceProperty(service_path_, prop); |
| 375 } | 374 } |
| 376 | 375 |
| 377 void Network::SetStringProperty( | 376 void Network::SetStringProperty( |
| 378 const char* prop, const std::string& str, std::string* dest) { | 377 const char* prop, const std::string& str, std::string* dest) { |
| 379 if (dest) | 378 if (dest) |
| 380 *dest = str; | 379 *dest = str; |
| 381 scoped_ptr<Value> value(Value::CreateStringValue(str)); | 380 SetValueProperty(prop, base::StringValue(str)); |
| 382 SetValueProperty(prop, value.get()); | |
| 383 } | 381 } |
| 384 | 382 |
| 385 void Network::SetOrClearStringProperty(const char* prop, | 383 void Network::SetOrClearStringProperty(const char* prop, |
| 386 const std::string& str, | 384 const std::string& str, |
| 387 std::string* dest) { | 385 std::string* dest) { |
| 388 if (str.empty()) { | 386 if (str.empty()) { |
| 389 ClearProperty(prop); | 387 ClearProperty(prop); |
| 390 if (dest) | 388 if (dest) |
| 391 dest->clear(); | 389 dest->clear(); |
| 392 } else { | 390 } else { |
| 393 SetStringProperty(prop, str, dest); | 391 SetStringProperty(prop, str, dest); |
| 394 } | 392 } |
| 395 } | 393 } |
| 396 | 394 |
| 397 void Network::SetBooleanProperty(const char* prop, bool b, bool* dest) { | 395 void Network::SetBooleanProperty(const char* prop, bool b, bool* dest) { |
| 398 if (dest) | 396 if (dest) |
| 399 *dest = b; | 397 *dest = b; |
| 400 scoped_ptr<Value> value(Value::CreateBooleanValue(b)); | 398 SetValueProperty(prop, base::FundamentalValue(b)); |
| 401 SetValueProperty(prop, value.get()); | |
| 402 } | 399 } |
| 403 | 400 |
| 404 void Network::SetIntegerProperty(const char* prop, int i, int* dest) { | 401 void Network::SetIntegerProperty(const char* prop, int i, int* dest) { |
| 405 if (dest) | 402 if (dest) |
| 406 *dest = i; | 403 *dest = i; |
| 407 scoped_ptr<Value> value(Value::CreateIntegerValue(i)); | 404 SetValueProperty(prop, base::FundamentalValue(i)); |
| 408 SetValueProperty(prop, value.get()); | |
| 409 } | 405 } |
| 410 | 406 |
| 411 void Network::SetPreferred(bool preferred) { | 407 void Network::SetPreferred(bool preferred) { |
| 412 if (preferred) { | 408 if (preferred) { |
| 413 SetIntegerProperty( | 409 SetIntegerProperty( |
| 414 flimflam::kPriorityProperty, kPriorityPreferred, &priority_); | 410 flimflam::kPriorityProperty, kPriorityPreferred, &priority_); |
| 415 } else { | 411 } else { |
| 416 ClearProperty(flimflam::kPriorityProperty); | 412 ClearProperty(flimflam::kPriorityProperty); |
| 417 priority_ = kPriorityNotSet; | 413 priority_ = kPriorityNotSet; |
| 418 } | 414 } |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 | 873 |
| 878 void CellularNetwork::SetApn(const CellularApn& apn) { | 874 void CellularNetwork::SetApn(const CellularApn& apn) { |
| 879 if (!apn.apn.empty()) { | 875 if (!apn.apn.empty()) { |
| 880 DictionaryValue value; | 876 DictionaryValue value; |
| 881 // Only use the fields that are needed for establishing | 877 // Only use the fields that are needed for establishing |
| 882 // connections, and ignore the rest. | 878 // connections, and ignore the rest. |
| 883 value.SetString(flimflam::kApnProperty, apn.apn); | 879 value.SetString(flimflam::kApnProperty, apn.apn); |
| 884 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); | 880 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); |
| 885 value.SetString(flimflam::kApnUsernameProperty, apn.username); | 881 value.SetString(flimflam::kApnUsernameProperty, apn.username); |
| 886 value.SetString(flimflam::kApnPasswordProperty, apn.password); | 882 value.SetString(flimflam::kApnPasswordProperty, apn.password); |
| 887 SetValueProperty(flimflam::kCellularApnProperty, &value); | 883 SetValueProperty(flimflam::kCellularApnProperty, value); |
| 888 } else { | 884 } else { |
| 889 ClearProperty(flimflam::kCellularApnProperty); | 885 ClearProperty(flimflam::kCellularApnProperty); |
| 890 } | 886 } |
| 891 } | 887 } |
| 892 | 888 |
| 893 bool CellularNetwork::SupportsActivation() const { | 889 bool CellularNetwork::SupportsActivation() const { |
| 894 return SupportsDataPlan(); | 890 return SupportsDataPlan(); |
| 895 } | 891 } |
| 896 | 892 |
| 897 bool CellularNetwork::NeedsActivation() const { | 893 bool CellularNetwork::NeedsActivation() const { |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 NetworkLibrary* impl; | 1363 NetworkLibrary* impl; |
| 1368 if (stub) | 1364 if (stub) |
| 1369 impl = new NetworkLibraryImplStub(); | 1365 impl = new NetworkLibraryImplStub(); |
| 1370 else | 1366 else |
| 1371 impl = new NetworkLibraryImplCros(); | 1367 impl = new NetworkLibraryImplCros(); |
| 1372 impl->Init(); | 1368 impl->Init(); |
| 1373 return impl; | 1369 return impl; |
| 1374 } | 1370 } |
| 1375 | 1371 |
| 1376 } // namespace chromeos | 1372 } // namespace chromeos |
| OLD | NEW |