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. 4 5#include "chrome/browser/chromeos/options/network_property_ui_data.h" 6 7#include "base/logging.h" 8#include "base/values.h" 9#include "chromeos/network/onc/onc_utils.h" 10 11namespace chromeos { 12 13NetworkPropertyUIData::NetworkPropertyUIData() 14 : onc_source_(::onc::ONC_SOURCE_NONE) { 15} 16 17NetworkPropertyUIData::NetworkPropertyUIData(::onc::ONCSource onc_source) 18 : onc_source_(onc_source) { 19} 20 21NetworkPropertyUIData::~NetworkPropertyUIData() { 22} 23 24void NetworkPropertyUIData::ParseOncProperty(::onc::ONCSource onc_source, 25 const base::DictionaryValue* onc, 26 const std::string& property_key) { 27 default_value_.reset(); 28 onc_source_ = onc_source; 29 30 if (!onc || !IsManaged()) 31 return; 32 33 if (!onc::IsRecommendedValue(onc, property_key)) 34 return; 35 36 // Set onc_source_ to NONE to indicate that the value is not enforced. 37 onc_source_ = ::onc::ONC_SOURCE_NONE; 38 39 const base::Value* default_value = NULL; 40 if (!onc->Get(property_key, &default_value)) { 41 // No default entry indicates that the property can be modified by the user, 42 // but has no default value, e.g. Username or Passphrase. (The default 43 // behavior for a property with no entry is non user modifiable). 44 return; 45 } 46 47 // Set the recommended (default) value. 48 default_value_.reset(default_value->DeepCopy()); 49} 50 51} // namespace chromeos 52