managed_network_configuration_handler.cc revision 3551c9c881056c480085172ff9840cab31610854
1// Copyright (c) 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 "chromeos/network/managed_network_configuration_handler.h" 6 7#include "base/logging.h" 8#include "base/values.h" 9#include "chromeos/network/network_ui_data.h" 10#include "chromeos/network/onc/onc_utils.h" 11#include "third_party/cros_system_api/dbus/service_constants.h" 12 13namespace chromeos { 14 15ManagedNetworkConfigurationHandler::~ManagedNetworkConfigurationHandler() {} 16 17// static 18scoped_ptr<NetworkUIData> ManagedNetworkConfigurationHandler::GetUIData( 19 const base::DictionaryValue& shill_dictionary) { 20 std::string ui_data_blob; 21 if (shill_dictionary.GetStringWithoutPathExpansion(flimflam::kUIDataProperty, 22 &ui_data_blob) && 23 !ui_data_blob.empty()) { 24 scoped_ptr<base::DictionaryValue> ui_data_dict = 25 onc::ReadDictionaryFromJson(ui_data_blob); 26 if (ui_data_dict) 27 return make_scoped_ptr(new NetworkUIData(*ui_data_dict)); 28 else 29 LOG(ERROR) << "UIData is not a valid JSON dictionary."; 30 } 31 VLOG(2) << "JSON dictionary has no UIData blob: " << shill_dictionary; 32 return scoped_ptr<NetworkUIData>(); 33} 34 35} // namespace chromeos 36