| OLD | NEW |
| (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 policy key collisions. |
| 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_ |
| OLD | NEW |