| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/policy/configuration_policy_provider.h" | 13 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 14 #include "chrome/common/pref_store.h" | 14 #include "chrome/common/pref_store.h" |
| 15 | 15 |
| 16 class PrefValueMap; |
| 17 |
| 16 namespace policy { | 18 namespace policy { |
| 17 | 19 |
| 18 class ConfigurationPolicyPrefKeeper; | |
| 19 | |
| 20 // Constants for the "Proxy Server Mode" defined in the policies. | 20 // Constants for the "Proxy Server Mode" defined in the policies. |
| 21 // Note that these diverge from internal presentation defined in | 21 // Note that these diverge from internal presentation defined in |
| 22 // ProxyPrefs::ProxyMode for legacy reasons. The following four | 22 // ProxyPrefs::ProxyMode for legacy reasons. The following four |
| 23 // PolicyProxyModeType types were not very precise and had overlapping use | 23 // PolicyProxyModeType types were not very precise and had overlapping use |
| 24 // cases. | 24 // cases. |
| 25 enum PolicyProxyModeType { | 25 enum PolicyProxyModeType { |
| 26 // Disable Proxy, connect directly. | 26 // Disable Proxy, connect directly. |
| 27 kPolicyNoProxyServerMode = 0, | 27 kPolicyNoProxyServerMode = 0, |
| 28 // Auto detect proxy or use specific PAC script if given. | 28 // Auto detect proxy or use specific PAC script if given. |
| 29 kPolicyAutoDetectProxyServerMode = 1, | 29 kPolicyAutoDetectProxyServerMode = 1, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 40 class ConfigurationPolicyPrefStore | 40 class ConfigurationPolicyPrefStore |
| 41 : public PrefStore, | 41 : public PrefStore, |
| 42 public ConfigurationPolicyProvider::Observer { | 42 public ConfigurationPolicyProvider::Observer { |
| 43 public: | 43 public: |
| 44 // The ConfigurationPolicyPrefStore does not take ownership of the | 44 // The ConfigurationPolicyPrefStore does not take ownership of the |
| 45 // passed-in |provider|. | 45 // passed-in |provider|. |
| 46 explicit ConfigurationPolicyPrefStore(ConfigurationPolicyProvider* provider); | 46 explicit ConfigurationPolicyPrefStore(ConfigurationPolicyProvider* provider); |
| 47 virtual ~ConfigurationPolicyPrefStore(); | 47 virtual ~ConfigurationPolicyPrefStore(); |
| 48 | 48 |
| 49 // PrefStore methods: | 49 // PrefStore methods: |
| 50 virtual void AddObserver(PrefStore::Observer* observer); | 50 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
| 51 virtual void RemoveObserver(PrefStore::Observer* observer); | 51 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; |
| 52 virtual bool IsInitializationComplete() const; | 52 virtual bool IsInitializationComplete() const OVERRIDE; |
| 53 virtual ReadResult GetValue(const std::string& key, | 53 virtual ReadResult GetValue(const std::string& key, |
| 54 const Value** result) const; | 54 const Value** result) const OVERRIDE; |
| 55 | 55 |
| 56 // ConfigurationPolicyProvider::Observer methods: | 56 // ConfigurationPolicyProvider::Observer methods: |
| 57 virtual void OnUpdatePolicy(); | 57 virtual void OnUpdatePolicy() OVERRIDE; |
| 58 virtual void OnProviderGoingAway(); | 58 virtual void OnProviderGoingAway() OVERRIDE; |
| 59 | 59 |
| 60 // Creates a ConfigurationPolicyPrefStore that reads managed platform policy. | 60 // Creates a ConfigurationPolicyPrefStore that reads managed platform policy. |
| 61 static ConfigurationPolicyPrefStore* CreateManagedPlatformPolicyPrefStore(); | 61 static ConfigurationPolicyPrefStore* CreateManagedPlatformPolicyPrefStore(); |
| 62 | 62 |
| 63 // Creates a ConfigurationPolicyPrefStore that reads managed cloud policy. | 63 // Creates a ConfigurationPolicyPrefStore that reads managed cloud policy. |
| 64 static ConfigurationPolicyPrefStore* CreateManagedCloudPolicyPrefStore(); | 64 static ConfigurationPolicyPrefStore* CreateManagedCloudPolicyPrefStore(); |
| 65 | 65 |
| 66 // Creates a ConfigurationPolicyPrefStore that reads recommended platform | 66 // Creates a ConfigurationPolicyPrefStore that reads recommended platform |
| 67 // policy. | 67 // policy. |
| 68 static ConfigurationPolicyPrefStore* | 68 static ConfigurationPolicyPrefStore* |
| 69 CreateRecommendedPlatformPolicyPrefStore(); | 69 CreateRecommendedPlatformPolicyPrefStore(); |
| 70 | 70 |
| 71 // Creates a ConfigurationPolicyPrefStore that reads recommended cloud policy. | 71 // Creates a ConfigurationPolicyPrefStore that reads recommended cloud policy. |
| 72 static ConfigurationPolicyPrefStore* CreateRecommendedCloudPolicyPrefStore(); | 72 static ConfigurationPolicyPrefStore* CreateRecommendedCloudPolicyPrefStore(); |
| 73 | 73 |
| 74 // Returns true if the given policy is a proxy policy. | 74 // Returns true if the given policy is a proxy policy. |
| 75 static bool IsProxyPolicy(ConfigurationPolicyType policy); | 75 static bool IsProxyPolicy(ConfigurationPolicyType policy); |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 // Refreshes policy information, rereading policy from the provider and | 78 // Refreshes policy information, rereading policy from the provider and |
| 79 // sending out change notifications as appropriate. | 79 // sending out change notifications as appropriate. |
| 80 void Refresh(); | 80 void Refresh(); |
| 81 | 81 |
| 82 // Returns a new PrefValueMap containing the preference values that correspond |
| 83 // to the policies currently provided by |provider_|. |
| 84 PrefValueMap* CreatePreferencesFromPolicies(); |
| 85 |
| 82 // The policy provider from which policy settings are read. | 86 // The policy provider from which policy settings are read. |
| 83 ConfigurationPolicyProvider* provider_; | 87 ConfigurationPolicyProvider* provider_; |
| 84 | 88 |
| 85 // Initialization status as reported by the policy provider the last time we | 89 // Initialization status as reported by the policy provider the last time we |
| 86 // queried it. | 90 // queried it. |
| 87 bool initialization_complete_; | 91 bool initialization_complete_; |
| 88 | 92 |
| 89 // Current policy preferences. | 93 // Current policy preferences. |
| 90 scoped_ptr<ConfigurationPolicyPrefKeeper> policy_keeper_; | 94 scoped_ptr<PrefValueMap> prefs_; |
| 91 | 95 |
| 92 ObserverList<PrefStore::Observer, true> observers_; | 96 ObserverList<PrefStore::Observer, true> observers_; |
| 93 | 97 |
| 94 ConfigurationPolicyObserverRegistrar registrar_; | 98 ConfigurationPolicyObserverRegistrar registrar_; |
| 95 | 99 |
| 96 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore); | 100 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore); |
| 97 }; | 101 }; |
| 98 | 102 |
| 99 } // namespace policy | 103 } // namespace policy |
| 100 | 104 |
| 101 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ | 105 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ |
| OLD | NEW |