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

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

Issue 10510006: Add ManagedModePolicyProvider and extension API to get and set policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 6 months 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_MANAGED_MODE_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_POLICY_MANAGED_MODE_POLICY_PROVIDER_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/policy/configuration_policy_provider.h"
11 #include "chrome/browser/profiles/profile_keyed_service.h"
12 #include "chrome/common/persistent_pref_store.h"
13
14 class Profile;
15
16 namespace policy {
17
18 // This class sets policies that are defined by a local user via "Managed Mode".
19 // It offers methods to set and read policies, and persists them on disk in
20 // JSON format.
21 class ManagedModePolicyProvider
22 : public ProfileKeyedService,
23 public ConfigurationPolicyProvider,
24 public PrefStore::Observer {
25 public:
26 explicit ManagedModePolicyProvider(Profile* profile);
27 virtual ~ManagedModePolicyProvider();
28
29 // Returns the stored value for a policy with the given |key|, or NULL if no
30 // such policy is defined.
31 const base::Value* GetPolicy(const std::string& key) const;
32 // Sets the policy with the given |key| to a copy of the given |value|.
33 void SetPolicy(const std::string& key, const base::Value* value);
34
35 // ConfigurationPolicyProvider implementation:
36 virtual void RefreshPolicies() OVERRIDE;
37 virtual bool IsInitializationComplete() const OVERRIDE;
38
39 // PrefStore::Observer implementation:
40 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE;
41 virtual void OnInitializationCompleted(bool success) OVERRIDE;
42
43 private:
44 base::DictionaryValue* GetCachedPolicy() const;
45 void UpdatePolicyFromCache();
46
47 // Used for persisting policies. This PrefStore is not hooked up to the
48 // PrefService like others.
49 scoped_refptr<PersistentPrefStore> store_;
50 };
51
52 } // namespace policy
53
54 #endif // CHROME_BROWSER_POLICY_MANAGED_MODE_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698