| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/policy/file_based_policy_provider.h" | 10 #include "chrome/browser/policy/file_based_policy_provider.h" |
| 11 | 11 |
| 12 class FilePath; | 12 class FilePath; |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class Value; | 15 class Value; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace policy { | 18 namespace policy { |
| 19 | 19 |
| 20 class PolicyBundle; | 20 class PolicyBundle; |
| 21 | 21 |
| 22 // Policy provider backed by JSON files in a configuration directory. | 22 // Policy provider backed by JSON files in a configuration directory. |
| 23 class ConfigDirPolicyProvider : public FileBasedPolicyProvider { | 23 class ConfigDirPolicyProvider : public FileBasedPolicyProvider { |
| 24 public: | 24 public: |
| 25 ConfigDirPolicyProvider(const PolicyDefinitionList* policy_list, | 25 ConfigDirPolicyProvider(const PolicyDefinitionList* policy_list, |
| 26 PolicyLevel level, | |
| 27 PolicyScope scope, | 26 PolicyScope scope, |
| 28 const FilePath& config_dir); | 27 const FilePath& config_dir); |
| 29 | 28 |
| 30 private: | 29 private: |
| 31 DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyProvider); | 30 DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyProvider); |
| 32 }; | 31 }; |
| 33 | 32 |
| 34 // A provider delegate implementation backed by a set of files in a given | 33 // A provider delegate implementation backed by a set of files in a given |
| 35 // directory. The files should contain JSON-formatted policy settings. They are | 34 // directory. The files should contain JSON-formatted policy settings. They are |
| 36 // merged together and the result is returned via the ProviderDelegate | 35 // merged together and the result is returned via the ProviderDelegate |
| 37 // interface. The files are consulted in lexicographic file name order, so the | 36 // interface. The files are consulted in lexicographic file name order, so the |
| 38 // last value read takes precedence in case of preference key collisions. | 37 // last value read takes precedence in case of preference key collisions. |
| 39 class ConfigDirPolicyProviderDelegate | 38 class ConfigDirPolicyProviderDelegate |
| 40 : public FileBasedPolicyProvider::ProviderDelegate { | 39 : public FileBasedPolicyProvider::ProviderDelegate { |
| 41 public: | 40 public: |
| 42 ConfigDirPolicyProviderDelegate(const FilePath& config_dir, | 41 ConfigDirPolicyProviderDelegate(const FilePath& config_dir, |
| 43 PolicyLevel level, | |
| 44 PolicyScope scope); | 42 PolicyScope scope); |
| 45 | 43 |
| 46 // FileBasedPolicyProvider::ProviderDelegate implementation. | 44 // FileBasedPolicyProvider::ProviderDelegate implementation. |
| 47 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; | 45 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE; |
| 48 virtual base::Time GetLastModification() OVERRIDE; | 46 virtual base::Time GetLastModification() OVERRIDE; |
| 49 | 47 |
| 50 private: | 48 private: |
| 51 // Merges the 3rd party |policies| into the |bundle|. | 49 // Loads the policy files at |path| into the |bundle|, with the given |level|. |
| 52 void Merge3rdPartyPolicy(PolicyBundle* bundle, | 50 void LoadFromPath(const FilePath& path, |
| 53 const base::Value* policies); | 51 PolicyLevel level, |
| 52 PolicyBundle* bundle); |
| 54 | 53 |
| 55 // Policies loaded by this provider will have these attributes. | 54 // Merges the 3rd party |policies| into the |bundle|, with the given |level|. |
| 56 PolicyLevel level_; | 55 void Merge3rdPartyPolicy(const base::Value* policies, |
| 56 PolicyLevel level, |
| 57 PolicyBundle* bundle); |
| 58 |
| 59 // Policies loaded by this provider will have this scope. |
| 57 PolicyScope scope_; | 60 PolicyScope scope_; |
| 58 | 61 |
| 59 DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyProviderDelegate); | 62 DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyProviderDelegate); |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 } // namespace policy | 65 } // namespace policy |
| 63 | 66 |
| 64 #endif // CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_PROVIDER_H_ | 67 #endif // CHROME_BROWSER_POLICY_CONFIG_DIR_POLICY_PROVIDER_H_ |
| OLD | NEW |