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

Side by Side Diff: chrome/browser/policy/configuration_policy_pref_store.h

Issue 109743002: Move policy code into components/policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar fixes Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
13 #include "base/prefs/pref_store.h"
14 #include "base/values.h"
15 #include "chrome/browser/policy/policy_service.h"
16 #include "components/policy/core/common/policy_map.h"
17 #include "components/policy/core/common/policy_types.h"
18
19 class PrefValueMap;
20
21 namespace policy {
22
23 class ConfigurationPolicyHandlerList;
24
25 // An implementation of PrefStore that bridges policy settings as read from the
26 // PolicyService to preferences. Converts POLICY_DOMAIN_CHROME policies a given
27 // PolicyLevel to their corresponding preferences.
28 class ConfigurationPolicyPrefStore
29 : public PrefStore,
30 public PolicyService::Observer {
31 public:
32 // Does not take ownership of |service| nor |handler_list|, which must outlive
33 // the store. Only policies of the given |level| will be mapped.
34 ConfigurationPolicyPrefStore(
35 PolicyService* service,
36 const ConfigurationPolicyHandlerList* handler_list,
37 PolicyLevel level);
38
39 // PrefStore methods:
40 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE;
41 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE;
42 virtual bool HasObservers() const OVERRIDE;
43 virtual bool IsInitializationComplete() const OVERRIDE;
44 virtual bool GetValue(const std::string& key,
45 const Value** result) const OVERRIDE;
46
47 // PolicyService::Observer methods:
48 virtual void OnPolicyUpdated(const PolicyNamespace& ns,
49 const PolicyMap& previous,
50 const PolicyMap& current) OVERRIDE;
51 virtual void OnPolicyServiceInitialized(PolicyDomain domain) OVERRIDE;
52
53 private:
54 virtual ~ConfigurationPolicyPrefStore();
55
56 // Refreshes policy information, rereading policy from the policy service and
57 // sending out change notifications as appropriate.
58 void Refresh();
59
60 // Returns a new PrefValueMap containing the preference values that correspond
61 // to the policies currently provided by the policy service.
62 PrefValueMap* CreatePreferencesFromPolicies();
63
64 // The PolicyService from which policy settings are read.
65 PolicyService* policy_service_;
66
67 // The policy handlers used to convert policies into their corresponding
68 // preferences.
69 const ConfigurationPolicyHandlerList* handler_list_;
70
71 // The policy level that this PrefStore uses.
72 PolicyLevel level_;
73
74 // Current policy preferences.
75 scoped_ptr<PrefValueMap> prefs_;
76
77 ObserverList<PrefStore::Observer, true> observers_;
78
79 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore);
80 };
81
82 } // namespace policy
83
84 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698