summaryrefslogtreecommitdiffstats
path: root/chrome/browser/config_dir_policy_provider.h
blob: 92794388b8fb7302c9fab2fc5ac48f99da0bfc72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CONFIG_DIR_POLICY_PROVIDER_H_
#define CHROME_BROWSER_CONFIG_DIR_POLICY_PROVIDER_H_
#pragma once

#include "base/basictypes.h"
#include "base/file_path.h"
#include "chrome/browser/configuration_policy_provider.h"

class DictionaryValue;

// A policy provider implementation backed by a set of files in a given
// directory. The files should contain JSON-formatted policy settings. They are
// merged together and the result is returned via the
// ConfigurationPolicyProvider interface. The files are consulted in
// lexicographic file name order, so the last value read takes precedence in
// case of preference key collisions.
class ConfigDirPolicyProvider : public ConfigurationPolicyProvider {
 public:
  explicit ConfigDirPolicyProvider(const FilePath& config_dir);
  virtual ~ConfigDirPolicyProvider() { }

  // ConfigurationPolicyProvider implementation.
  virtual bool Provide(ConfigurationPolicyStore* store);

 private:
  // Read and merge the files from the configuration directory.
  DictionaryValue* ReadPolicies();

  // Decodes the value tree and writes the configuration to the given |store|.
  void DecodePolicyValueTree(DictionaryValue* policies,
                             ConfigurationPolicyStore* store);

  // The directory in which we look for configuration files.
  const FilePath config_dir_;

  DISALLOW_COPY_AND_ASSIGN(ConfigDirPolicyProvider);
};

#endif  // CHROME_BROWSER_CONFIG_DIR_POLICY_PROVIDER_H_