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