OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CONFIGURATION_POLICY_PREF_STORE_H_ |
| 6 #define CHROME_BROWSER_CONFIGURATION_POLICY_PREF_STORE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/scoped_ptr.h" |
| 12 #include "base/values.h" |
| 13 #include "chrome/browser/configuration_policy_store.h" |
| 14 #include "chrome/browser/pref_store.h" |
| 15 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 16 |
| 17 class ConfigurationPolicyProvider; |
| 18 |
| 19 // An implementation of the |PrefStore| that holds a Dictionary |
| 20 // created through applied policy. |
| 21 class ConfigurationPolicyPrefStore : public PrefStore, |
| 22 public ConfigurationPolicyStore { |
| 23 public: |
| 24 explicit ConfigurationPolicyPrefStore(ConfigurationPolicyProvider* provider); |
| 25 virtual ~ConfigurationPolicyPrefStore() { } |
| 26 |
| 27 // PrefStore methods: |
| 28 virtual PrefReadError ReadPrefs(); |
| 29 virtual DictionaryValue* prefs() { return prefs_.get(); } |
| 30 |
| 31 private: |
| 32 // For unit tests. |
| 33 FRIEND_TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomePageDefault); |
| 34 FRIEND_TEST(ConfigurationPolicyPrefStoreTest, TestSettingHomePageOverride); |
| 35 FRIEND_TEST(ConfigurationPolicyPrefStoreTest, |
| 36 TestSettingHomepageIsNewTabPageDefault); |
| 37 FRIEND_TEST(ConfigurationPolicyPrefStoreTest, |
| 38 TestSettingHomepageIsNewTabPage); |
| 39 FRIEND_TEST(ConfigurationPolicyPrefStoreTest, |
| 40 TestSettingCookiesEnabledDefault); |
| 41 FRIEND_TEST(ConfigurationPolicyPrefStoreTest, |
| 42 TestSettingCookiesEnabledOverride); |
| 43 |
| 44 // Policies that map to a single preference are handled |
| 45 // by an automated converter. Each one of these policies |
| 46 // has an entry in |simple_policy_map_| with the following type. |
| 47 struct PolicyToPreferenceMapEntry { |
| 48 Value::ValueType value_type; |
| 49 PolicyType policy_type; |
| 50 const wchar_t* preference_path; // A DictionaryValue path, not a file path. |
| 51 }; |
| 52 |
| 53 static const PolicyToPreferenceMapEntry simple_policy_map_[]; |
| 54 |
| 55 ConfigurationPolicyProvider* provider_; |
| 56 scoped_ptr<DictionaryValue> prefs_; |
| 57 |
| 58 // ConfigurationPolicyStore methods: |
| 59 virtual void Apply(PolicyType setting, Value* value); |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore); |
| 62 }; |
| 63 |
| 64 #endif // CHROME_BROWSER_CONFIGURATION_POLICY_PREF_STORE_H_ |
| 65 |
OLD | NEW |