blob: 1b9a5a81502aa4c9448d52a0a411d454ce3baa87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/configuration_policy_provider.h"
#include "base/values.h"
#include "chrome/browser/configuration_policy_store.h"
namespace {
struct PolicyValueTreeMappingEntry {
ConfigurationPolicyStore::PolicyType policy_type;
Value::ValueType value_type;
const wchar_t* const name;
};
const PolicyValueTreeMappingEntry kPolicyValueTreeMapping[] = {
{ ConfigurationPolicyStore::kPolicyHomePage,
Value::TYPE_STRING, L"homepage" },
{ ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage,
Value::TYPE_BOOLEAN, L"homepage_is_newtabpage" },
{ ConfigurationPolicyStore::kPolicyCookiesEnabled,
Value::TYPE_BOOLEAN, L"cookies_enabled" }
};
}
void DecodePolicyValueTree(DictionaryValue* policies,
ConfigurationPolicyStore* store) {
for (size_t i = 0; i < arraysize(kPolicyValueTreeMapping); ++i) {
const PolicyValueTreeMappingEntry& entry(kPolicyValueTreeMapping[i]);
Value* value;
if (policies->Get(entry.name, &value) && value->IsType(entry.value_type))
store->Apply(entry.policy_type, value->DeepCopy());
}
// TODO (mnissler) Handle preference overrides once |ConfigurationPolicyStore|
// supports it.
}
|