Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Unified Diff: chrome/browser/configuration_policy_provider.cc

Issue 2027010: Preference provider implementation backed by JSON files in a directory. (Closed)
Patch Set: A few more fixes. Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/configuration_policy_provider.h ('k') | chrome/browser/mock_configuration_policy_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+}
« no previous file with comments | « chrome/browser/configuration_policy_provider.h ('k') | chrome/browser/mock_configuration_policy_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698