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

Unified Diff: chrome/browser/configuration_policy_pref_store.cc

Issue 1692011: Implementation of managed policy: Policy Abstraction (Closed)
Patch Set: check no changes 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
Index: chrome/browser/configuration_policy_pref_store.cc
diff --git a/chrome/browser/configuration_policy_pref_store.cc b/chrome/browser/configuration_policy_pref_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c883b707ce1b78f474ca083e93dc39cc4d0d2108
--- /dev/null
+++ b/chrome/browser/configuration_policy_pref_store.cc
@@ -0,0 +1,46 @@
+// 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_pref_store.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/browser/configuration_policy_provider.h"
+#include "chrome/common/pref_names.h"
+
+const ConfigurationPolicyPrefStore::PolicyToPreferenceMapEntry
+ConfigurationPolicyPrefStore::simple_policy_map_[] = {
+ { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage },
+ { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage,
+ prefs::kHomePageIsNewTabPage },
+ { Value::TYPE_INTEGER, kPolicyCookiesEnabled, prefs::kCookieBehavior }
+};
+
+ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore(
+ ConfigurationPolicyProvider* provider)
+ : provider_(provider),
+ prefs_(new DictionaryValue()) {
+}
+
+PrefStore::PrefReadError ConfigurationPolicyPrefStore::ReadPrefs() {
+ return provider_->Provide(this) ? PrefStore::PREF_READ_ERROR_NONE :
+ PrefStore::PREF_READ_ERROR_OTHER;
+}
+
+void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) {
+ const PolicyToPreferenceMapEntry* end =
+ simple_policy_map_ + arraysize(simple_policy_map_);
+ for (const PolicyToPreferenceMapEntry* current = simple_policy_map_;
+ current != end; ++current) {
+ if (current->policy_type == policy) {
+ DCHECK(current->value_type == value->GetType());
+ prefs_->Set(current->preference_path, value);
+ return;
+ }
+ }
+
+ // Other policy implementations go here.
+ NOTIMPLEMENTED();
+}
+
« no previous file with comments | « chrome/browser/configuration_policy_pref_store.h ('k') | chrome/browser/configuration_policy_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698