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 "chromeos/network/onc/onc_translator.h" | 5 #include "chromeos/network/onc/onc_translator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 if (Tokenize(shill_nameservers, ",", &onc_nameserver_vector) > 0) { | 459 if (Tokenize(shill_nameservers, ",", &onc_nameserver_vector) > 0) { |
460 scoped_ptr<base::ListValue> onc_nameservers(new base::ListValue); | 460 scoped_ptr<base::ListValue> onc_nameservers(new base::ListValue); |
461 for (std::vector<std::string>::iterator iter = | 461 for (std::vector<std::string>::iterator iter = |
462 onc_nameserver_vector.begin(); | 462 onc_nameserver_vector.begin(); |
463 iter != onc_nameserver_vector.end(); ++iter) { | 463 iter != onc_nameserver_vector.end(); ++iter) { |
464 onc_nameservers->AppendString(*iter); | 464 onc_nameservers->AppendString(*iter); |
465 } | 465 } |
466 onc_object_->SetWithoutPathExpansion(::onc::ipconfig::kNameServers, | 466 onc_object_->SetWithoutPathExpansion(::onc::ipconfig::kNameServers, |
467 onc_nameservers.release()); | 467 onc_nameservers.release()); |
468 } | 468 } |
| 469 // Static and Saved IPConfig in Shill are always of type IPv4. Set this type |
| 470 // in ONC, but not if the object would be empty except the type. |
| 471 if (!onc_object_->empty()) { |
| 472 onc_object_->SetStringWithoutPathExpansion(::onc::ipconfig::kType, |
| 473 ::onc::ipconfig::kIPv4); |
| 474 } |
469 } | 475 } |
470 | 476 |
471 void ShillToONCTranslator::TranslateSavedIPConfig() { | 477 void ShillToONCTranslator::TranslateSavedIPConfig() { |
472 TranslateSavedOrStaticIPConfig(shill::kSavedIPNameServersProperty); | 478 TranslateSavedOrStaticIPConfig(shill::kSavedIPNameServersProperty); |
473 } | 479 } |
474 | 480 |
475 void ShillToONCTranslator::TranslateStaticIPConfig() { | 481 void ShillToONCTranslator::TranslateStaticIPConfig() { |
476 TranslateSavedOrStaticIPConfig(shill::kStaticIPNameServersProperty); | 482 TranslateSavedOrStaticIPConfig(shill::kStaticIPNameServersProperty); |
477 } | 483 } |
478 | 484 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 const base::DictionaryValue& shill_dictionary, | 627 const base::DictionaryValue& shill_dictionary, |
622 const OncValueSignature* onc_signature) { | 628 const OncValueSignature* onc_signature) { |
623 CHECK(onc_signature != NULL); | 629 CHECK(onc_signature != NULL); |
624 | 630 |
625 ShillToONCTranslator translator(shill_dictionary, *onc_signature); | 631 ShillToONCTranslator translator(shill_dictionary, *onc_signature); |
626 return translator.CreateTranslatedONCObject(); | 632 return translator.CreateTranslatedONCObject(); |
627 } | 633 } |
628 | 634 |
629 } // namespace onc | 635 } // namespace onc |
630 } // namespace chromeos | 636 } // namespace chromeos |
OLD | NEW |