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

Side by Side Diff: components/policy/core/common/policy_map.h

Issue 1350913006: Revert of Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 10 matching lines...) Expand all
21 class POLICY_EXPORT PolicyMap { 21 class POLICY_EXPORT PolicyMap {
22 public: 22 public:
23 // Each policy maps to an Entry which keeps the policy value as well as other 23 // Each policy maps to an Entry which keeps the policy value as well as other
24 // relevant data about the policy. 24 // relevant data about the policy.
25 struct POLICY_EXPORT Entry { 25 struct POLICY_EXPORT Entry {
26 PolicyLevel level; 26 PolicyLevel level;
27 PolicyScope scope; 27 PolicyScope scope;
28 base::Value* value; 28 base::Value* value;
29 ExternalDataFetcher* external_data_fetcher; 29 ExternalDataFetcher* external_data_fetcher;
30 30
31 // For debugging and displaying only. Set by provider delivering the policy.
32 PolicySource source;
33
34 Entry(); 31 Entry();
35 32
36 // Deletes all members owned by |this|. 33 // Deletes all members owned by |this|.
37 void DeleteOwnedMembers(); 34 void DeleteOwnedMembers();
38 35
39 // Returns a copy of |this|. 36 // Returns a copy of |this|.
40 scoped_ptr<Entry> DeepCopy() const; 37 scoped_ptr<Entry> DeepCopy() const;
41 38
42 // Returns true if |this| has higher priority than |other|. 39 // Returns true if |this| has higher priority than |other|.
43 bool has_higher_priority_than(const Entry& other) const; 40 bool has_higher_priority_than(const Entry& other) const;
(...skipping 15 matching lines...) Expand all
59 // Returns a weak reference to the value currently stored for key |policy|, 56 // Returns a weak reference to the value currently stored for key |policy|,
60 // or NULL if not found. Ownership is retained by the PolicyMap. 57 // or NULL if not found. Ownership is retained by the PolicyMap.
61 // This is equivalent to Get(policy)->value, when it doesn't return NULL. 58 // This is equivalent to Get(policy)->value, when it doesn't return NULL.
62 const base::Value* GetValue(const std::string& policy) const; 59 const base::Value* GetValue(const std::string& policy) const;
63 60
64 // Takes ownership of |value| and |external_data_fetcher|. Overwrites any 61 // Takes ownership of |value| and |external_data_fetcher|. Overwrites any
65 // existing information stored in the map for the key |policy|. 62 // existing information stored in the map for the key |policy|.
66 void Set(const std::string& policy, 63 void Set(const std::string& policy,
67 PolicyLevel level, 64 PolicyLevel level,
68 PolicyScope scope, 65 PolicyScope scope,
69 PolicySource source,
70 base::Value* value, 66 base::Value* value,
71 ExternalDataFetcher* external_data_fetcher); 67 ExternalDataFetcher* external_data_fetcher);
72 68
73 // Erase the given |policy|, if it exists in this map. 69 // Erase the given |policy|, if it exists in this map.
74 void Erase(const std::string& policy); 70 void Erase(const std::string& policy);
75 71
76 // Swaps the internal representation of |this| with |other|. 72 // Swaps the internal representation of |this| with |other|.
77 void Swap(PolicyMap* other); 73 void Swap(PolicyMap* other);
78 74
79 // |this| becomes a copy of |other|. Any existing policies are dropped. 75 // |this| becomes a copy of |other|. Any existing policies are dropped.
80 void CopyFrom(const PolicyMap& other); 76 void CopyFrom(const PolicyMap& other);
81 77
82 // Returns a copy of |this|. 78 // Returns a copy of |this|.
83 scoped_ptr<PolicyMap> DeepCopy() const; 79 scoped_ptr<PolicyMap> DeepCopy() const;
84 80
85 // Merges policies from |other| into |this|. Existing policies are only 81 // Merges policies from |other| into |this|. Existing policies are only
86 // overridden by those in |other| if they have a higher priority, as defined 82 // overridden by those in |other| if they have a higher priority, as defined
87 // by Entry::has_higher_priority_than(). If a policy is contained in both 83 // by Entry::has_higher_priority_than(). If a policy is contained in both
88 // maps with the same priority, the current value in |this| is preserved. 84 // maps with the same priority, the current value in |this| is preserved.
89 void MergeFrom(const PolicyMap& other); 85 void MergeFrom(const PolicyMap& other);
90 86
91 // Loads the values in |policies| into this PolicyMap. All policies loaded 87 // Loads the values in |policies| into this PolicyMap. All policies loaded
92 // will have |level|, |scope| and |source| in their entries. Existing entries 88 // will have |level| and |scope| in their entries. Existing entries are
93 // are replaced. 89 // replaced.
94 void LoadFrom(const base::DictionaryValue* policies, 90 void LoadFrom(const base::DictionaryValue* policies,
95 PolicyLevel level, 91 PolicyLevel level,
96 PolicyScope scope, 92 PolicyScope scope);
97 PolicySource source);
98 93
99 // Compares this value map against |other| and stores all key names that have 94 // Compares this value map against |other| and stores all key names that have
100 // different values or reference different external data in |differing_keys|. 95 // different values or reference different external data in |differing_keys|.
101 // This includes keys that are present only in one of the maps. 96 // This includes keys that are present only in one of the maps.
102 // |differing_keys| is not cleared before the keys are added. 97 // |differing_keys| is not cleared before the keys are added.
103 void GetDifferingKeys(const PolicyMap& other, 98 void GetDifferingKeys(const PolicyMap& other,
104 std::set<std::string>* differing_keys) const; 99 std::set<std::string>* differing_keys) const;
105 100
106 // Removes all policies that don't have the specified |level|. This is a 101 // Removes all policies that don't have the specified |level|. This is a
107 // temporary helper method, until mandatory and recommended levels are served 102 // temporary helper method, until mandatory and recommended levels are served
(...skipping 15 matching lines...) Expand all
123 const PolicyMapType::value_type& b); 118 const PolicyMapType::value_type& b);
124 119
125 PolicyMapType map_; 120 PolicyMapType map_;
126 121
127 DISALLOW_COPY_AND_ASSIGN(PolicyMap); 122 DISALLOW_COPY_AND_ASSIGN(PolicyMap);
128 }; 123 };
129 124
130 } // namespace policy 125 } // namespace policy
131 126
132 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_ 127 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_win_unittest.cc ('k') | components/policy/core/common/policy_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698