summaryrefslogtreecommitdiffstats
path: root/chrome/browser/configuration_policy_pref_store.h
diff options
context:
space:
mode:
authordanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 15:03:32 +0000
committerdanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 15:03:32 +0000
commitc0858b00d9c2009c489ee8d90eb46460a8acc82d (patch)
tree4816a658e5200edc5c2d8b5fb465b8a8474a3b58 /chrome/browser/configuration_policy_pref_store.h
parentd661e6ed98b7139f898f7edd33f7d1e2b946c9c6 (diff)
downloadchromium_src-c0858b00d9c2009c489ee8d90eb46460a8acc82d.zip
chromium_src-c0858b00d9c2009c489ee8d90eb46460a8acc82d.tar.gz
chromium_src-c0858b00d9c2009c489ee8d90eb46460a8acc82d.tar.bz2
Implementation of managed policy abstraction on top of a preference store. This is preparation work for implementing platform-specific policy.
BUG=none TEST=--gtest_filter=ConfigurationPolicyPrefStoreTest* Review URL: http://codereview.chromium.org/1692011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/configuration_policy_pref_store.h')
-rw-r--r--chrome/browser/configuration_policy_pref_store.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/chrome/browser/configuration_policy_pref_store.h b/chrome/browser/configuration_policy_pref_store.h
new file mode 100644
index 0000000..8335070
--- /dev/null
+++ b/chrome/browser/configuration_policy_pref_store.h
@@ -0,0 +1,65 @@
+// 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.
+
+#ifndef CHROME_BROWSER_CONFIGURATION_POLICY_PREF_STORE_H_
+#define CHROME_BROWSER_CONFIGURATION_POLICY_PREF_STORE_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
+#include "base/values.h"
+#include "chrome/browser/configuration_policy_store.h"
+#include "chrome/browser/pref_store.h"
+#include "testing/gtest/include/gtest/gtest_prod.h"
+
+class ConfigurationPolicyProvider;
+
+// An implementation of the |PrefStore| that holds a Dictionary
+// created through applied policy.
+class ConfigurationPolicyPrefStore : public PrefStore,
+ public ConfigurationPolicyStore {
+ public:
+ explicit ConfigurationPolicyPrefStore(ConfigurationPolicyProvider* provider);
+ virtual ~ConfigurationPolicyPrefStore() { }
+
+ // PrefStore methods:
+ virtual PrefReadError ReadPrefs();
+ virtual DictionaryValue* prefs() { return prefs_.get(); }
+
+ private:
+ // For unit tests.
+ FRIEND_TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomePageDefault);
+ FRIEND_TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomePageOverride);
+ FRIEND_TEST(ConfigurationPolicyPrefStoreTest,
+ TestSettingHomepageIsNewTabPageDefault);
+ FRIEND_TEST(ConfigurationPolicyPrefStoreTest,
+ TestSettingHomepageIsNewTabPage);
+ FRIEND_TEST(ConfigurationPolicyPrefStoreTest,
+ TestSettingCookiesEnabledDefault);
+ FRIEND_TEST(ConfigurationPolicyPrefStoreTest,
+ TestSettingCookiesEnabledOverride);
+
+ // Policies that map to a single preference are handled
+ // by an automated converter. Each one of these policies
+ // has an entry in |simple_policy_map_| with the following type.
+ struct PolicyToPreferenceMapEntry {
+ Value::ValueType value_type;
+ PolicyType policy_type;
+ const wchar_t* preference_path; // A DictionaryValue path, not a file path.
+ };
+
+ static const PolicyToPreferenceMapEntry simple_policy_map_[];
+
+ ConfigurationPolicyProvider* provider_;
+ scoped_ptr<DictionaryValue> prefs_;
+
+ // ConfigurationPolicyStore methods:
+ virtual void Apply(PolicyType setting, Value* value);
+
+ DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore);
+};
+
+#endif // CHROME_BROWSER_CONFIGURATION_POLICY_PREF_STORE_H_
+