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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 unique_id_ = name_; | 353 unique_id_ = name_; |
354 } | 354 } |
355 | 355 |
356 bool Network::RequiresUserProfile() const { | 356 bool Network::RequiresUserProfile() const { |
357 return false; | 357 return false; |
358 } | 358 } |
359 | 359 |
360 void Network::CopyCredentialsFromRemembered(Network* remembered) { | 360 void Network::CopyCredentialsFromRemembered(Network* remembered) { |
361 } | 361 } |
362 | 362 |
363 void Network::SetValueProperty(const char* prop, Value* value) { | 363 void Network::SetValueProperty(const char* prop, const base::Value& value) { |
364 DCHECK(prop); | 364 DCHECK(prop); |
365 DCHECK(value); | |
366 if (!EnsureCrosLoaded()) | 365 if (!EnsureCrosLoaded()) |
367 return; | 366 return; |
368 CrosSetNetworkServiceProperty(service_path_, prop, *value); | 367 CrosSetNetworkServiceProperty(service_path_, prop, value); |
369 } | 368 } |
370 | 369 |
371 void Network::ClearProperty(const char* prop) { | 370 void Network::ClearProperty(const char* prop) { |
372 DCHECK(prop); | 371 DCHECK(prop); |
373 if (!EnsureCrosLoaded()) | 372 if (!EnsureCrosLoaded()) |
374 return; | 373 return; |
375 CrosClearNetworkServiceProperty(service_path_, prop); | 374 CrosClearNetworkServiceProperty(service_path_, prop); |
376 } | 375 } |
377 | 376 |
378 void Network::SetStringProperty( | 377 void Network::SetStringProperty( |
379 const char* prop, const std::string& str, std::string* dest) { | 378 const char* prop, const std::string& str, std::string* dest) { |
380 if (dest) | 379 if (dest) |
381 *dest = str; | 380 *dest = str; |
382 scoped_ptr<Value> value(Value::CreateStringValue(str)); | 381 SetValueProperty(prop, base::StringValue(str)); |
383 SetValueProperty(prop, value.get()); | |
384 } | 382 } |
385 | 383 |
386 void Network::SetOrClearStringProperty(const char* prop, | 384 void Network::SetOrClearStringProperty(const char* prop, |
387 const std::string& str, | 385 const std::string& str, |
388 std::string* dest) { | 386 std::string* dest) { |
389 if (str.empty()) { | 387 if (str.empty()) { |
390 ClearProperty(prop); | 388 ClearProperty(prop); |
391 if (dest) | 389 if (dest) |
392 dest->clear(); | 390 dest->clear(); |
393 } else { | 391 } else { |
394 SetStringProperty(prop, str, dest); | 392 SetStringProperty(prop, str, dest); |
395 } | 393 } |
396 } | 394 } |
397 | 395 |
398 void Network::SetBooleanProperty(const char* prop, bool b, bool* dest) { | 396 void Network::SetBooleanProperty(const char* prop, bool b, bool* dest) { |
399 if (dest) | 397 if (dest) |
400 *dest = b; | 398 *dest = b; |
401 scoped_ptr<Value> value(Value::CreateBooleanValue(b)); | 399 SetValueProperty(prop, base::FundamentalValue(b)); |
402 SetValueProperty(prop, value.get()); | |
403 } | 400 } |
404 | 401 |
405 void Network::SetIntegerProperty(const char* prop, int i, int* dest) { | 402 void Network::SetIntegerProperty(const char* prop, int i, int* dest) { |
406 if (dest) | 403 if (dest) |
407 *dest = i; | 404 *dest = i; |
408 scoped_ptr<Value> value(Value::CreateIntegerValue(i)); | 405 SetValueProperty(prop, base::FundamentalValue(i)); |
409 SetValueProperty(prop, value.get()); | |
410 } | 406 } |
411 | 407 |
412 void Network::SetPreferred(bool preferred) { | 408 void Network::SetPreferred(bool preferred) { |
413 if (preferred) { | 409 if (preferred) { |
414 SetIntegerProperty( | 410 SetIntegerProperty( |
415 flimflam::kPriorityProperty, kPriorityPreferred, &priority_); | 411 flimflam::kPriorityProperty, kPriorityPreferred, &priority_); |
416 } else { | 412 } else { |
417 ClearProperty(flimflam::kPriorityProperty); | 413 ClearProperty(flimflam::kPriorityProperty); |
418 priority_ = kPriorityNotSet; | 414 priority_ = kPriorityNotSet; |
419 } | 415 } |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 | 863 |
868 void CellularNetwork::SetApn(const CellularApn& apn) { | 864 void CellularNetwork::SetApn(const CellularApn& apn) { |
869 if (!apn.apn.empty()) { | 865 if (!apn.apn.empty()) { |
870 DictionaryValue value; | 866 DictionaryValue value; |
871 // Only use the fields that are needed for establishing | 867 // Only use the fields that are needed for establishing |
872 // connections, and ignore the rest. | 868 // connections, and ignore the rest. |
873 value.SetString(flimflam::kApnProperty, apn.apn); | 869 value.SetString(flimflam::kApnProperty, apn.apn); |
874 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); | 870 value.SetString(flimflam::kApnNetworkIdProperty, apn.network_id); |
875 value.SetString(flimflam::kApnUsernameProperty, apn.username); | 871 value.SetString(flimflam::kApnUsernameProperty, apn.username); |
876 value.SetString(flimflam::kApnPasswordProperty, apn.password); | 872 value.SetString(flimflam::kApnPasswordProperty, apn.password); |
877 SetValueProperty(flimflam::kCellularApnProperty, &value); | 873 SetValueProperty(flimflam::kCellularApnProperty, value); |
878 } else { | 874 } else { |
879 ClearProperty(flimflam::kCellularApnProperty); | 875 ClearProperty(flimflam::kCellularApnProperty); |
880 } | 876 } |
881 } | 877 } |
882 | 878 |
883 bool CellularNetwork::SupportsActivation() const { | 879 bool CellularNetwork::SupportsActivation() const { |
884 return SupportsDataPlan(); | 880 return SupportsDataPlan(); |
885 } | 881 } |
886 | 882 |
887 bool CellularNetwork::NeedsActivation() const { | 883 bool CellularNetwork::NeedsActivation() const { |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 NetworkLibrary* impl; | 1354 NetworkLibrary* impl; |
1359 if (stub) | 1355 if (stub) |
1360 impl = new NetworkLibraryImplStub(); | 1356 impl = new NetworkLibraryImplStub(); |
1361 else | 1357 else |
1362 impl = new NetworkLibraryImplCros(); | 1358 impl = new NetworkLibraryImplCros(); |
1363 impl->Init(); | 1359 impl->Init(); |
1364 return impl; | 1360 return impl; |
1365 } | 1361 } |
1366 | 1362 |
1367 } // namespace chromeos | 1363 } // namespace chromeos |
OLD | NEW |