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

Unified Diff: chrome/browser/policy/configuration_policy_pref_store.h

Issue 6074003: Handle policy refresh internally in ConfigurationPolicyPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 10 years 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/policy/configuration_policy_pref_store.h
diff --git a/chrome/browser/policy/configuration_policy_pref_store.h b/chrome/browser/policy/configuration_policy_pref_store.h
index 6d0ae15a133b69716447e82ed84a4e3e1695e9c4..26ba19046125622f5f4cce6d23fdeb115a0021b8 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.h
+++ b/chrome/browser/policy/configuration_policy_pref_store.h
@@ -10,37 +10,37 @@
#include <string>
#include "base/basictypes.h"
-#include "base/gtest_prod_util.h"
+#include "base/observer_list.h"
#include "base/scoped_ptr.h"
#include "base/values.h"
#include "chrome/browser/policy/configuration_policy_provider.h"
#include "chrome/browser/policy/configuration_policy_store_interface.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
#include "chrome/common/pref_store.h"
class Profile;
namespace policy {
-// An implementation of the |PrefStore| that holds a Dictionary
-// created through applied policy.
+class ConfigurationPolicyPrefKeeper;
+
+// An implementation of PrefStore that bridges policy settings as read from a
+// ConfigurationPolicyProvider to preferences.
class ConfigurationPolicyPrefStore : public PrefStore,
- public ConfigurationPolicyStoreInterface {
+ public NotificationObserver {
public:
- typedef std::set<const char*> ProxyPreferenceSet;
-
// The ConfigurationPolicyPrefStore does not take ownership of the
// passed-in |provider|.
explicit ConfigurationPolicyPrefStore(ConfigurationPolicyProvider* provider);
virtual ~ConfigurationPolicyPrefStore();
// PrefStore methods:
+ virtual void AddObserver(Observer* observer);
+ virtual void RemoveObserver(Observer* observer);
+ virtual bool IsInitializationComplete() const;
virtual ReadResult GetValue(const std::string& key, Value** result) const;
- virtual DictionaryValue* prefs() const;
-
- // ConfigurationPolicyStore methods:
- virtual void Apply(ConfigurationPolicyType setting, Value* value);
-
// Creates a ConfigurationPolicyPrefStore that reads managed platform policy.
static ConfigurationPolicyPrefStore* CreateManagedPlatformPolicyPrefStore();
@@ -57,81 +57,33 @@ class ConfigurationPolicyPrefStore : public PrefStore,
GetChromePolicyDefinitionList();
private:
- // 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;
- ConfigurationPolicyType policy_type;
- const char* preference_path; // A DictionaryValue path, not a file path.
- };
-
- static const PolicyToPreferenceMapEntry kSimplePolicyMap[];
- static const PolicyToPreferenceMapEntry kProxyPolicyMap[];
- static const PolicyToPreferenceMapEntry kDefaultSearchPolicyMap[];
+ // TODO(mnissler): Remove after provider has proper observer interface.
+ // NotificationObserver overrides:
+ void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ // Refreshes policy information, rereading policy from the provider and
+ // sending out change notifications as appropriate.
+ void Refresh();
+
static const ConfigurationPolicyProvider::PolicyDefinitionList
kPolicyDefinitionList;
+ // The policy provider from which policy settings are read.
ConfigurationPolicyProvider* provider_;
- scoped_ptr<DictionaryValue> prefs_;
-
- // Temporary cache that stores values until FinalizeProxyPolicySettings()
- // is called.
- std::map<ConfigurationPolicyType, Value*> proxy_policies_;
-
- bool HasProxyPolicy(ConfigurationPolicyType policy) const;
-
- // Returns the map entry that corresponds to |policy| in the map.
- const PolicyToPreferenceMapEntry* FindPolicyInMap(
- ConfigurationPolicyType policy,
- const PolicyToPreferenceMapEntry* map,
- int size) const;
-
- // Remove the preferences found in the map from |prefs_|. Returns true if
- // any such preferences were found and removed.
- bool RemovePreferencesOfMap(const PolicyToPreferenceMapEntry* map,
- int table_size);
-
- bool ApplyPolicyFromMap(ConfigurationPolicyType policy,
- Value* value,
- const PolicyToPreferenceMapEntry* map,
- int size);
-
- // Processes proxy-specific policies. Returns true if the specified policy
- // is a proxy-related policy. ApplyProxyPolicy assumes the ownership
- // of |value| in the case that the policy is proxy-specific.
- bool ApplyProxyPolicy(ConfigurationPolicyType policy, Value* value);
-
- // Handles sync-related policies. Returns true if the policy was handled.
- // Assumes ownership of |value| in that case.
- bool ApplySyncPolicy(ConfigurationPolicyType policy, Value* value);
-
- // Handles policies that affect AutoFill. Returns true if the policy was
- // handled and assumes ownership of |value| in that case.
- bool ApplyAutoFillPolicy(ConfigurationPolicyType policy, Value* value);
-
- // Make sure that the |path| if present in |prefs_|. If not, set it to
- // a blank string.
- void EnsureStringPrefExists(const std::string& path);
-
- // If the required entries for default search are specified and valid,
- // finalizes the policy-specified configuration by initializing the
- // unspecified map entries. Otherwise wipes all default search related
- // map entries from |prefs_|.
- void FinalizeDefaultSearchPolicySettings();
-
- // If the required entries for the proxy settings are specified and valid,
- // finalizes the policy-specified configuration by initializing the
- // respective values in |prefs_|.
- void FinalizeProxyPolicySettings();
-
- // Returns true if the policy values stored in proxy_* represent a valid
- // proxy configuration.
- bool CheckProxySettings();
-
- // Assumes CheckProxySettings returns true and applies the values stored
- // in proxy_*.
- void ApplyProxySettings();
+
+ // Initialization status as reported by the policy provider the last time we
+ // queried it.
+ bool initialization_complete_;
+
+ // Current policy preferences.
+ scoped_ptr<ConfigurationPolicyPrefKeeper> policy_keeper_;
+
+ // TODO(mnissler): Remove after provider has proper observer interface.
+ NotificationRegistrar registrar_;
+
+ ObserverList<Observer, true> observers_;
DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore);
};

Powered by Google App Engine
This is Rietveld 408576698