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

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

Issue 1304843004: 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
31 Entry(); 34 Entry();
32 35
33 // Deletes all members owned by |this|. 36 // Deletes all members owned by |this|.
34 void DeleteOwnedMembers(); 37 void DeleteOwnedMembers();
35 38
36 // Returns a copy of |this|. 39 // Returns a copy of |this|.
37 scoped_ptr<Entry> DeepCopy() const; 40 scoped_ptr<Entry> DeepCopy() const;
38 41
39 // Returns true if |this| has higher priority than |other|. 42 // Returns true if |this| has higher priority than |other|.
40 bool has_higher_priority_than(const Entry& other) const; 43 bool has_higher_priority_than(const Entry& other) const;
(...skipping 10 matching lines...) Expand all
51 54
52 // Returns a weak reference to the entry currently stored for key |policy|, 55 // Returns a weak reference to the entry currently stored for key |policy|,
53 // or NULL if not found. Ownership is retained by the PolicyMap. 56 // or NULL if not found. Ownership is retained by the PolicyMap.
54 const Entry* Get(const std::string& policy) const; 57 const Entry* Get(const std::string& policy) const;
55 58
56 // Returns a weak reference to the value currently stored for key |policy|, 59 // Returns a weak reference to the value currently stored for key |policy|,
57 // or NULL if not found. Ownership is retained by the PolicyMap. 60 // or NULL if not found. Ownership is retained by the PolicyMap.
58 // This is equivalent to Get(policy)->value, when it doesn't return NULL. 61 // This is equivalent to Get(policy)->value, when it doesn't return NULL.
59 const base::Value* GetValue(const std::string& policy) const; 62 const base::Value* GetValue(const std::string& policy) const;
60 63
61 // Takes ownership of |value| and |external_data_fetcher|. Overwrites any 64 // Sets the source of every Entry with unknown source to the passed |source|.
bartfab (slow) 2015/09/14 14:42:27 Nit: s/passed/given/ ("passed" is used with scoped
fhorschig 2015/09/16 13:52:05 Done.
62 // existing information stored in the map for the key |policy|. 65 void ApplySourceToEntries(PolicySource source);
66
67 // Calls |SetWithSource| with default source.
bartfab (slow) 2015/09/14 14:42:27 Nit 1: The most common style is to use |pipes| for
fhorschig 2015/09/16 13:52:05 1 & 2 Done. Nit 3: This change is certainly useful
63 void Set(const std::string& policy, 68 void Set(const std::string& policy,
bartfab (slow) 2015/09/14 14:42:27 Would it not be possible to make the code that cal
fhorschig 2015/09/16 13:52:05 It is possible. Let me just update these 531 refer
bartfab (slow) 2015/09/16 15:58:40 Thanks. This looks much better now.
fhorschig 2015/09/17 11:20:41 Thank you :D
64 PolicyLevel level, 69 PolicyLevel level,
65 PolicyScope scope, 70 PolicyScope scope,
66 base::Value* value, 71 base::Value* value,
67 ExternalDataFetcher* external_data_fetcher); 72 ExternalDataFetcher* external_data_fetcher);
68 73
74 // Takes ownership of |value| and |external_data_fetcher|. Overwrites any
75 // existing information stored in the map for the key |policy|.
76 void SetWithSource(const std::string& policy,
77 PolicyLevel level,
78 PolicyScope scope,
79 base::Value* value,
80 ExternalDataFetcher* external_data_fetcher,
81 PolicySource source);
82
69 // Erase the given |policy|, if it exists in this map. 83 // Erase the given |policy|, if it exists in this map.
70 void Erase(const std::string& policy); 84 void Erase(const std::string& policy);
71 85
72 // Swaps the internal representation of |this| with |other|. 86 // Swaps the internal representation of |this| with |other|.
73 void Swap(PolicyMap* other); 87 void Swap(PolicyMap* other);
74 88
75 // |this| becomes a copy of |other|. Any existing policies are dropped. 89 // |this| becomes a copy of |other|. Any existing policies are dropped.
76 void CopyFrom(const PolicyMap& other); 90 void CopyFrom(const PolicyMap& other);
77 91
78 // Returns a copy of |this|. 92 // Returns a copy of |this|.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 const PolicyMapType::value_type& b); 132 const PolicyMapType::value_type& b);
119 133
120 PolicyMapType map_; 134 PolicyMapType map_;
121 135
122 DISALLOW_COPY_AND_ASSIGN(PolicyMap); 136 DISALLOW_COPY_AND_ASSIGN(PolicyMap);
123 }; 137 };
124 138
125 } // namespace policy 139 } // namespace policy
126 140
127 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_ 141 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698