1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/options/network_property_ui_data.h"
7 #include "base/values.h"
11 NetworkPropertyUIData::NetworkPropertyUIData()
12 : onc_source_(onc::ONC_SOURCE_NONE
) {
15 NetworkPropertyUIData::NetworkPropertyUIData(onc::ONCSource onc_source
)
16 : onc_source_(onc_source
) {
19 NetworkPropertyUIData::~NetworkPropertyUIData() {
22 void NetworkPropertyUIData::ParseOncProperty(onc::ONCSource onc_source
,
23 const base::DictionaryValue
* onc
,
24 const std::string
& property_key
) {
25 default_value_
.reset();
26 onc_source_
= onc_source
;
28 if (!onc
|| !IsManaged())
31 size_t pos
= property_key
.find_last_of('.');
32 std::string recommended_property_key
;
33 std::string
property_basename(property_key
);
34 if (pos
!= std::string::npos
) {
35 recommended_property_key
= property_key
.substr(0, pos
+ 1);
36 property_basename
= property_key
.substr(pos
+ 1);
38 recommended_property_key
+= "Recommended";
40 const base::ListValue
* recommended_keys
= NULL
;
41 if (onc
->GetList(recommended_property_key
, &recommended_keys
)) {
42 base::StringValue
basename_value(property_basename
);
43 if (recommended_keys
->Find(basename_value
) != recommended_keys
->end()) {
44 onc_source_
= onc::ONC_SOURCE_NONE
;
45 const base::Value
* default_value
= NULL
;
46 if (onc
->Get(property_key
, &default_value
))
47 default_value_
.reset(default_value
->DeepCopy());
52 } // namespace chromeos