Chromium Code Reviews| 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" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chromeos/network/network_profile_handler.h" | |
| 15 #include "chromeos/network/network_state.h" | 16 #include "chromeos/network/network_state.h" |
| 16 #include "chromeos/network/network_util.h" | 17 #include "chromeos/network/network_util.h" |
| 17 #include "chromeos/network/onc/onc_signature.h" | 18 #include "chromeos/network/onc/onc_signature.h" |
| 18 #include "chromeos/network/onc/onc_translation_tables.h" | 19 #include "chromeos/network/onc/onc_translation_tables.h" |
| 19 #include "chromeos/network/shill_property_util.h" | 20 #include "chromeos/network/shill_property_util.h" |
| 20 #include "components/onc/onc_constants.h" | 21 #include "components/onc/onc_constants.h" |
| 21 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 22 | 23 |
| 23 namespace chromeos { | 24 namespace chromeos { |
| 24 namespace onc { | 25 namespace onc { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 } | 409 } |
| 409 onc_object_->SetStringWithoutPathExpansion( | 410 onc_object_->SetStringWithoutPathExpansion( |
| 410 ::onc::network_config::kConnectionState, onc_state); | 411 ::onc::network_config::kConnectionState, onc_state); |
| 411 // Only set 'RestrictedConnectivity' if true. | 412 // Only set 'RestrictedConnectivity' if true. |
| 412 if (state == shill::kStatePortal) { | 413 if (state == shill::kStatePortal) { |
| 413 onc_object_->SetBooleanWithoutPathExpansion( | 414 onc_object_->SetBooleanWithoutPathExpansion( |
| 414 ::onc::network_config::kRestrictedConnectivity, true); | 415 ::onc::network_config::kRestrictedConnectivity, true); |
| 415 } | 416 } |
| 416 } | 417 } |
| 417 | 418 |
| 419 std::string profile_path; | |
| 420 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kProfileProperty, | |
|
pneubeck (no reviews)
2014/09/09 19:35:32
If we use the same field for 'policy sources', thi
stevenjb
2014/09/10 00:00:55
I think the right thing to do is to pass ONCSource
| |
| 421 &profile_path)) { | |
| 422 std::string source; | |
| 423 if (profile_path == NetworkProfileHandler::GetSharedProfilePath()) | |
| 424 source = ::onc::network_config::kSourceDevice; | |
| 425 else if (!profile_path.empty()) | |
| 426 source = ::onc::network_config::kSourceUser; | |
| 427 else | |
| 428 source = ::onc::network_config::kSourceNone; | |
| 429 onc_object_->SetStringWithoutPathExpansion( | |
| 430 ::onc::network_config::kSource, source); | |
| 431 } | |
| 432 | |
| 418 // Use a human-readable aa:bb format for any hardware MAC address. Note: | 433 // Use a human-readable aa:bb format for any hardware MAC address. Note: |
| 419 // this property is provided by the caller but is not part of the Shill | 434 // this property is provided by the caller but is not part of the Shill |
| 420 // Service properties (it is copied from the Device properties). | 435 // Service properties (it is copied from the Device properties). |
| 421 std::string address; | 436 std::string address; |
| 422 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kAddressProperty, | 437 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kAddressProperty, |
| 423 &address)) { | 438 &address)) { |
| 424 onc_object_->SetStringWithoutPathExpansion( | 439 onc_object_->SetStringWithoutPathExpansion( |
| 425 ::onc::network_config::kMacAddress, | 440 ::onc::network_config::kMacAddress, |
| 426 network_util::FormattedMacAddress(address)); | 441 network_util::FormattedMacAddress(address)); |
| 427 } | 442 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 const base::DictionaryValue& shill_dictionary, | 647 const base::DictionaryValue& shill_dictionary, |
| 633 const OncValueSignature* onc_signature) { | 648 const OncValueSignature* onc_signature) { |
| 634 CHECK(onc_signature != NULL); | 649 CHECK(onc_signature != NULL); |
| 635 | 650 |
| 636 ShillToONCTranslator translator(shill_dictionary, *onc_signature); | 651 ShillToONCTranslator translator(shill_dictionary, *onc_signature); |
| 637 return translator.CreateTranslatedONCObject(); | 652 return translator.CreateTranslatedONCObject(); |
| 638 } | 653 } |
| 639 | 654 |
| 640 } // namespace onc | 655 } // namespace onc |
| 641 } // namespace chromeos | 656 } // namespace chromeos |
| OLD | NEW |