Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/policy/policy_bundle.h

Issue 78823004: Move PolicyBundle into components/policy/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on master Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_POLICY_BUNDLE_H_
6 #define CHROME_BROWSER_POLICY_POLICY_BUNDLE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "components/policy/core/common/policy_map.h"
13 #include "components/policy/core/common/policy_namespace.h"
14
15 namespace policy {
16
17 // Maps policy namespaces to PolicyMaps.
18 class PolicyBundle {
19 public:
20 typedef std::map<PolicyNamespace, PolicyMap*> MapType;
21 typedef MapType::iterator iterator;
22 typedef MapType::const_iterator const_iterator;
23
24 PolicyBundle();
25 virtual ~PolicyBundle();
26
27 // Returns the PolicyMap for namespace |ns|.
28 PolicyMap& Get(const PolicyNamespace& ns);
29 const PolicyMap& Get(const PolicyNamespace& ns) const;
30
31 // Swaps the internal representation of |this| with |other|.
32 void Swap(PolicyBundle* other);
33
34 // |this| becomes a copy of |other|. Any existing PolicyMaps are dropped.
35 void CopyFrom(const PolicyBundle& other);
36
37 // Merges the PolicyMaps of |this| with those of |other| for each namespace
38 // in common. Also adds copies of the (namespace, PolicyMap) pairs in |other|
39 // that don't have an entry in |this|.
40 // Each policy in each PolicyMap is replaced only if the policy from |other|
41 // has a higher priority.
42 // See PolicyMap::MergeFrom for details on merging individual PolicyMaps.
43 void MergeFrom(const PolicyBundle& other);
44
45 // Returns true if |other| has the same keys and value as |this|.
46 bool Equals(const PolicyBundle& other) const;
47
48 // Returns iterators to the beginning and end of the underlying container.
49 iterator begin() { return policy_bundle_.begin(); }
50 iterator end() { return policy_bundle_.end(); }
51
52 // These can be used to iterate over and read the PolicyMaps, but not to
53 // modify them.
54 const_iterator begin() const { return policy_bundle_.begin(); }
55 const_iterator end() const { return policy_bundle_.end(); }
56
57 // Erases all the existing pairs.
58 void Clear();
59
60 private:
61 MapType policy_bundle_;
62
63 // An empty PolicyMap that is returned by const Get() for namespaces that
64 // do not exist in |policy_bundle_|.
65 const PolicyMap kEmpty_;
66
67 DISALLOW_COPY_AND_ASSIGN(PolicyBundle);
68 };
69
70 } // namespace policy
71
72 #endif // CHROME_BROWSER_POLICY_POLICY_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698