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 3// found in the LICENSE file. 4 5#include "chromeos/app_mode/kiosk_oem_manifest_parser.h" 6 7#include "base/json/json_file_value_serializer.h" 8#include "base/strings/stringprintf.h" 9#include "base/values.h" 10 11namespace chromeos { 12 13namespace { 14 15const char kEnterpriseManaged[] = "enterprise_managed"; 16const char kAllowReset[] = "can_exit_enrollment"; 17const char kDeviceRequisition[] = "device_requisition"; 18const char kKeyboardDrivenOobe[] = "keyboard_driven_oobe"; 19 20} // namespace 21 22KioskOemManifestParser::Manifest::Manifest() 23 : enterprise_managed(false), 24 can_exit_enrollment(true), 25 keyboard_driven_oobe(false) { 26} 27 28bool KioskOemManifestParser::Load( 29 const base::FilePath& kiosk_oem_file, 30 KioskOemManifestParser::Manifest* manifest) { 31 int error_code = JSONFileValueSerializer::JSON_NO_ERROR; 32 std::string error_msg; 33 scoped_ptr<JSONFileValueSerializer> serializer( 34 new JSONFileValueSerializer(kiosk_oem_file)); 35 scoped_ptr<base::Value> value( 36 serializer->Deserialize(&error_code, &error_msg)); 37 base::DictionaryValue* dict = NULL; 38 if (error_code != JSONFileValueSerializer::JSON_NO_ERROR || 39 !value.get() || 40 !value->GetAsDictionary(&dict)) { 41 return false; 42 } 43 44 dict->GetString(kDeviceRequisition, 45 &manifest->device_requisition); 46 dict->GetBoolean(kKeyboardDrivenOobe, 47 &manifest->keyboard_driven_oobe); 48 if (!dict->GetBoolean(kEnterpriseManaged, 49 &manifest->enterprise_managed) || 50 !dict->GetBoolean(kAllowReset, 51 &manifest->can_exit_enrollment)) { 52 return false; 53 } 54 55 return true; 56} 57 58} // namespace chromeos 59