| Index: chrome/browser/configuration_policy_provider.cc
|
| diff --git a/chrome/browser/configuration_policy_provider.cc b/chrome/browser/configuration_policy_provider.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1b9a5a81502aa4c9448d52a0a411d454ce3baa87
|
| --- /dev/null
|
| +++ b/chrome/browser/configuration_policy_provider.cc
|
| @@ -0,0 +1,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.
|
| +}
|
|
|