| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // An implementation of PrefStore that bridges policy settings as read from the | 23 // An implementation of PrefStore that bridges policy settings as read from the |
| 24 // PolicyService to preferences. Converts POLICY_DOMAIN_CHROME policies a given | 24 // PolicyService to preferences. Converts POLICY_DOMAIN_CHROME policies a given |
| 25 // PolicyLevel to their corresponding preferences. | 25 // PolicyLevel to their corresponding preferences. |
| 26 class ConfigurationPolicyPrefStore | 26 class ConfigurationPolicyPrefStore |
| 27 : public PrefStore, | 27 : public PrefStore, |
| 28 public PolicyService::Observer { | 28 public PolicyService::Observer { |
| 29 public: | 29 public: |
| 30 // Does not take ownership of |service|. Only policies of the given |level| | 30 // Does not take ownership of |service|. Only policies of the given |level| |
| 31 // will be mapped. | 31 // will be mapped. |
| 32 ConfigurationPolicyPrefStore(PolicyService* service, PolicyLevel level); | 32 ConfigurationPolicyPrefStore(PolicyService* service, PolicyLevel level); |
| 33 virtual ~ConfigurationPolicyPrefStore(); | |
| 34 | 33 |
| 35 // PrefStore methods: | 34 // PrefStore methods: |
| 36 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; | 35 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
| 37 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; | 36 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; |
| 38 virtual size_t NumberOfObservers() const OVERRIDE; | 37 virtual size_t NumberOfObservers() const OVERRIDE; |
| 39 virtual bool IsInitializationComplete() const OVERRIDE; | 38 virtual bool IsInitializationComplete() const OVERRIDE; |
| 40 virtual ReadResult GetValue(const std::string& key, | 39 virtual ReadResult GetValue(const std::string& key, |
| 41 const Value** result) const OVERRIDE; | 40 const Value** result) const OVERRIDE; |
| 42 | 41 |
| 43 // PolicyService::Observer methods: | 42 // PolicyService::Observer methods: |
| 44 virtual void OnPolicyUpdated(PolicyDomain domain, | 43 virtual void OnPolicyUpdated(PolicyDomain domain, |
| 45 const std::string& component_id, | 44 const std::string& component_id, |
| 46 const PolicyMap& previous, | 45 const PolicyMap& previous, |
| 47 const PolicyMap& current) OVERRIDE; | 46 const PolicyMap& current) OVERRIDE; |
| 48 virtual void OnPolicyServiceInitialized() OVERRIDE; | 47 virtual void OnPolicyServiceInitialized() OVERRIDE; |
| 49 | 48 |
| 50 // Creates a ConfigurationPolicyPrefStore that only provides policies that | 49 // Creates a ConfigurationPolicyPrefStore that only provides policies that |
| 51 // have POLICY_LEVEL_MANDATORY level. | 50 // have POLICY_LEVEL_MANDATORY level. |
| 52 static ConfigurationPolicyPrefStore* CreateMandatoryPolicyPrefStore(); | 51 static ConfigurationPolicyPrefStore* CreateMandatoryPolicyPrefStore(); |
| 53 | 52 |
| 54 // Creates a ConfigurationPolicyPrefStore that only provides policies that | 53 // Creates a ConfigurationPolicyPrefStore that only provides policies that |
| 55 // have POLICY_LEVEL_RECOMMENDED level. | 54 // have POLICY_LEVEL_RECOMMENDED level. |
| 56 static ConfigurationPolicyPrefStore* CreateRecommendedPolicyPrefStore(); | 55 static ConfigurationPolicyPrefStore* CreateRecommendedPolicyPrefStore(); |
| 57 | 56 |
| 58 private: | 57 private: |
| 58 virtual ~ConfigurationPolicyPrefStore(); |
| 59 |
| 59 // Refreshes policy information, rereading policy from the policy service and | 60 // Refreshes policy information, rereading policy from the policy service and |
| 60 // sending out change notifications as appropriate. | 61 // sending out change notifications as appropriate. |
| 61 void Refresh(); | 62 void Refresh(); |
| 62 | 63 |
| 63 // Returns a new PrefValueMap containing the preference values that correspond | 64 // Returns a new PrefValueMap containing the preference values that correspond |
| 64 // to the policies currently provided by the policy service. | 65 // to the policies currently provided by the policy service. |
| 65 PrefValueMap* CreatePreferencesFromPolicies(); | 66 PrefValueMap* CreatePreferencesFromPolicies(); |
| 66 | 67 |
| 67 // The PolicyService from which policy settings are read. | 68 // The PolicyService from which policy settings are read. |
| 68 PolicyService* policy_service_; | 69 PolicyService* policy_service_; |
| 69 | 70 |
| 70 // The policy level that this PrefStore uses. | 71 // The policy level that this PrefStore uses. |
| 71 PolicyLevel level_; | 72 PolicyLevel level_; |
| 72 | 73 |
| 73 // Current policy preferences. | 74 // Current policy preferences. |
| 74 scoped_ptr<PrefValueMap> prefs_; | 75 scoped_ptr<PrefValueMap> prefs_; |
| 75 | 76 |
| 76 ObserverList<PrefStore::Observer, true> observers_; | 77 ObserverList<PrefStore::Observer, true> observers_; |
| 77 | 78 |
| 78 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore); | 79 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 } // namespace policy | 82 } // namespace policy |
| 82 | 83 |
| 83 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ | 84 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ |
| OLD | NEW |