Add GetSystemNSSKeySlot, merge GetPrivateNSSKeySlot/GetPublicNSSKeySlot to GetPersist...
[chromium-blink-merge.git] / chromeos / app_mode / kiosk_oem_manifest_parser.cc
blob77d79fb0f73d1cdb40944d2f682fe3998e9a4748
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.
5 #include "chromeos/app_mode/kiosk_oem_manifest_parser.h"
7 #include "base/json/json_file_value_serializer.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/values.h"
11 namespace chromeos {
13 namespace {
15 const char kEnterpriseManaged[] = "enterprise_managed";
16 const char kAllowReset[] = "can_exit_enrollment";
17 const char kDeviceRequisition[] = "device_requisition";
18 const char kKeyboardDrivenOobe[] = "keyboard_driven_oobe";
20 } // namespace
22 KioskOemManifestParser::Manifest::Manifest()
23 : enterprise_managed(false),
24 can_exit_enrollment(true),
25 keyboard_driven_oobe(false) {
28 bool 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;
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;
55 return true;
58 } // namespace chromeos