policy_namespace.h revision f2477e01787aa58f445919b809d89e252beef54f
1// Copyright 2013 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 COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
6#define COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
7
8#include <string>
9#include <vector>
10
11#include "components/policy/policy_export.h"
12
13namespace policy {
14
15// Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID
16// string depends on the domain; for example, if the PolicyDomain is
17// "extensions" then the ID identifies the extension that the policies control.
18enum POLICY_EXPORT PolicyDomain {
19  // The component ID for chrome policies is always the empty string.
20  POLICY_DOMAIN_CHROME,
21
22  // The extensions policy domain is a work in progress. Included here for
23  // tests.
24  POLICY_DOMAIN_EXTENSIONS,
25
26  // Must be the last entry.
27  POLICY_DOMAIN_SIZE,
28};
29
30// Groups a policy domain and a component ID in a single object representing
31// a policy namespace. Objects of this class can be used as keys in std::maps.
32struct POLICY_EXPORT PolicyNamespace {
33 public:
34  PolicyNamespace();
35  PolicyNamespace(PolicyDomain domain, const std::string& component_id);
36  PolicyNamespace(const PolicyNamespace& other);
37  ~PolicyNamespace();
38
39  PolicyNamespace& operator=(const PolicyNamespace& other);
40  bool operator<(const PolicyNamespace& other) const;
41  bool operator==(const PolicyNamespace& other) const;
42  bool operator!=(const PolicyNamespace& other) const;
43
44  PolicyDomain domain;
45  std::string component_id;
46};
47
48typedef std::vector<PolicyNamespace> PolicyNamespaceList;
49
50}  // namespace policy
51
52#endif  // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
53