Ignore title parameter for navigator.registerProtocolHandler
[chromium-blink-merge.git] / components / policy / core / common / config_dir_policy_loader.h
blob054844b3e49d18f7ecdeaf8eb59b671bf3e8a7c1
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.
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CONFIG_DIR_POLICY_LOADER_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_CONFIG_DIR_POLICY_LOADER_H_
8 #include "base/files/file_path.h"
9 #include "base/files/file_path_watcher.h"
10 #include "components/policy/core/common/async_policy_loader.h"
11 #include "components/policy/core/common/policy_types.h"
12 #include "components/policy/policy_export.h"
14 namespace base {
15 class Value;
18 namespace policy {
20 // A policy loader implementation backed by a set of files in a given
21 // directory. The files should contain JSON-formatted policy settings. They are
22 // merged together and the result is returned in a PolicyBundle.
23 // The files are consulted in lexicographic file name order, so the
24 // last value read takes precedence in case of policy key collisions.
25 class POLICY_EXPORT ConfigDirPolicyLoader : public AsyncPolicyLoader {
26 public:
27 ConfigDirPolicyLoader(scoped_refptr<base::SequencedTaskRunner> task_runner,
28 const base::FilePath& config_dir,
29 PolicyScope scope);
30 virtual ~ConfigDirPolicyLoader();
32 // AsyncPolicyLoader implementation.
33 virtual void InitOnBackgroundThread() OVERRIDE;
34 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE;
35 virtual base::Time LastModificationTime() OVERRIDE;
37 private:
38 // Loads the policy files at |path| into the |bundle|, with the given |level|.
39 void LoadFromPath(const base::FilePath& path,
40 PolicyLevel level,
41 PolicyBundle* bundle);
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);
48 // Callback for the FilePathWatchers.
49 void OnFileUpdated(const base::FilePath& path, bool error);
51 // The directory containing the policy files.
52 base::FilePath config_dir_;
54 // Policies loaded by this provider will have this scope.
55 PolicyScope scope_;
57 // Watchers for events on the mandatory and recommended subdirectories of
58 // |config_dir_|.
59 base::FilePathWatcher mandatory_watcher_;
60 base::FilePathWatcher recommended_watcher_;
62 DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyLoader);
65 } // namespace policy
67 #endif // COMPONENTS_POLICY_CORE_COMMON_CONFIG_DIR_POLICY_LOADER_H_