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

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

Issue 10443108: Implement the ConfigDirPolicyProvider based on the AsyncPolicyLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments, added FilePathWatchers 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_CONFIG_DIR_POLICY_LOADER_H_
6 #define CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_LOADER_H_
7 #pragma once
8
9 #include "base/file_path.h"
10 #include "base/files/file_path_watcher.h"
11 #include "chrome/browser/policy/async_policy_loader.h"
12 #include "chrome/browser/policy/policy_constants.h"
13
14 namespace base {
15 class Value;
16 }
17
18 namespace policy {
19
20 struct PolicyDefinitionList;
21
22 // A policy loader implementation backed by a set of files in a given
23 // directory. The files should contain JSON-formatted policy settings. They are
24 // merged together and the result is returned in a PolicyBundle.
25 // The files are consulted in lexicographic file name order, so the
26 // last value read takes precedence in case of preference key collisions.
Mattias Nissler (ping if slow) 2012/06/05 12:00:16 nit: s/preference key/policy key/
Joao da Silva 2012/06/05 14:51:40 Done.
27 class ConfigDirPolicyLoader : public AsyncPolicyLoader {
28 public:
29 ConfigDirPolicyLoader(const FilePath& config_dir, PolicyScope scope);
30 virtual ~ConfigDirPolicyLoader();
31
32 // AsyncPolicyLoader implementation.
33 virtual void InitOnFile() OVERRIDE;
34 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE;
35 virtual base::Time LastModificationTime() OVERRIDE;
36
37 private:
38 // Loads the policy files at |path| into the |bundle|, with the given |level|.
39 void LoadFromPath(const FilePath& path,
40 PolicyLevel level,
41 PolicyBundle* bundle);
42
43 // Merges the 3rd party |policies| into the |bundle|, with the given |level|.
44 void Merge3rdPartyPolicy(const base::Value* policies,
45 PolicyLevel level,
46 PolicyBundle* bundle);
47
48 // Callback for the FilePathWatchers.
49 void OnFileUpdated(const FilePath& path, bool error);
50
51 // The directory containing the policy files.
52 FilePath config_dir_;
53
54 // Policies loaded by this provider will have this scope.
55 PolicyScope scope_;
56
57 // Watchers for events on the mandatory and recommended subdirectories of
58 // |config_dir_|.
59 base::files::FilePathWatcher mandatory_watcher_;
60 base::files::FilePathWatcher recommended_watcher_;
61
62 DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyLoader);
63 };
64
65 } // namespace policy
66
67 #endif // CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.cc ('k') | chrome/browser/policy/config_dir_policy_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698