Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / app_mode / kiosk_oem_manifest_parser.cc
blobf13d1a8fd9cdd21e946ea8ac93ea6c52d7f05521
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 = JSONFileValueDeserializer::JSON_NO_ERROR;
32 std::string error_msg;
33 scoped_ptr<JSONFileValueDeserializer> deserializer(
34 new JSONFileValueDeserializer(kiosk_oem_file));
35 scoped_ptr<base::Value> value(
36 deserializer->Deserialize(&error_code, &error_msg));
37 base::DictionaryValue* dict = NULL;
38 if (error_code != JSONFileValueDeserializer::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