aboutsummaryrefslogtreecommitdiffstats
path: root/policy/libpolicy.h
blob: 1a411cf3249a9366f801d9b39f793ac17f7d876f (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
44
45
46
47
48
49
50
// Copyright (c) 2011 The Chromium OS 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 LIBBRILLO_POLICY_LIBPOLICY_H_
#define LIBBRILLO_POLICY_LIBPOLICY_H_

#include <memory>
#include <string>

#include <base/macros.h>

#pragma GCC visibility push(default)

namespace policy {

class DevicePolicy;

// This class holds device settings that are to be enforced across all users.
//
// If there is a policy on disk at creation time, we will load it at verify
// its signature.
class PolicyProvider {
 public:
  PolicyProvider();
  virtual ~PolicyProvider();

  // Constructor for tests only!
  explicit PolicyProvider(std::unique_ptr<DevicePolicy> device_policy);

  // This function will ensure the freshness of the contents that the getters
  // are delivering. Normally contents are cached to prevent unnecessary load.
  virtual bool Reload();

  virtual bool device_policy_is_loaded() const;

  // Returns a value from the device policy cache.
  virtual const DevicePolicy& GetDevicePolicy() const;

 private:
  std::unique_ptr<DevicePolicy> device_policy_;
  bool device_policy_is_loaded_;

  DISALLOW_COPY_AND_ASSIGN(PolicyProvider);
};
}  // namespace policy

#pragma GCC visibility pop

#endif  // LIBBRILLO_POLICY_LIBPOLICY_H_