policy_namespace.h revision f2477e01787aa58f445919b809d89e252beef54f
11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file.
41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include <string>
9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include <vector>
101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "components/policy/policy_export.h"
121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace policy {
141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID
161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// string depends on the domain; for example, if the PolicyDomain is
171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// "extensions" then the ID identifies the extension that the policies control.
181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)enum POLICY_EXPORT PolicyDomain {
191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // The component ID for chrome policies is always the empty string.
201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  POLICY_DOMAIN_CHROME,
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // The extensions policy domain is a work in progress. Included here for
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // tests.
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  POLICY_DOMAIN_EXTENSIONS,
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Must be the last entry.
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  POLICY_DOMAIN_SIZE,
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Groups a policy domain and a component ID in a single object representing
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// a policy namespace. Objects of this class can be used as keys in std::maps.
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)struct POLICY_EXPORT PolicyNamespace {
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public:
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  PolicyNamespace();
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  PolicyNamespace(PolicyDomain domain, const std::string& component_id);
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  PolicyNamespace(const PolicyNamespace& other);
371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  ~PolicyNamespace();
381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  PolicyNamespace& operator=(const PolicyNamespace& other);
401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool operator<(const PolicyNamespace& other) const;
411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool operator==(const PolicyNamespace& other) const;
421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool operator!=(const PolicyNamespace& other) const;
431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  PolicyDomain domain;
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  std::string component_id;
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
48f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)typedef std::vector<PolicyNamespace> PolicyNamespaceList;
49f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}  // namespace policy
511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif  // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_
53