Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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_STATUS_MAP_H_ | |
| 6 #define CHROME_BROWSER_POLICY_POLICY_STATUS_MAP_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/scoped_ptr.h" | |
| 11 #include "base/values.h" | |
| 12 #include "policy/configuration_policy_type.h" | |
| 13 | |
| 14 namespace policy { | |
| 15 | |
| 16 // Describes a policy's status on the client. | |
| 17 struct PolicyStatusInfo { | |
| 18 | |
| 19 // Defines the possible sources a policy can have (user, device or none if the | |
| 20 // policy wasn't actually set). | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
The description in parentheses is actually redunda
simo
2011/08/10 14:28:19
Done.
| |
| 21 enum PolicySourceType { | |
| 22 USER, | |
| 23 DEVICE, | |
| 24 SOURCE_TYPE_UNDEFINED, | |
| 25 }; | |
| 26 | |
| 27 // Defines the possible levels a policy can be operating on (mandatory, | |
| 28 // recommended or none). | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
same here.
simo
2011/08/10 14:28:19
Done.
| |
| 29 enum PolicyLevel { | |
| 30 MANDATORY, | |
| 31 RECOMMENDED, | |
| 32 LEVEL_UNDEFINED, | |
| 33 }; | |
| 34 | |
| 35 // Defines the possible statuses a policy can have (successfully enforced, not | |
| 36 // enforced or undefined). | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
same here
simo
2011/08/10 14:28:19
Done.
| |
| 37 enum PolicyStatus { | |
| 38 ENFORCED, | |
| 39 FAILED, | |
| 40 STATUS_UNDEFINED, | |
| 41 }; | |
| 42 | |
| 43 PolicyStatusInfo(); | |
| 44 PolicyStatusInfo(string16 name, | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
you should include the string16 header, since you'
simo
2011/08/10 14:28:19
Done.
| |
| 45 PolicySourceType source_type, | |
| 46 PolicyLevel level, | |
| 47 Value* value, | |
| 48 PolicyStatus status, | |
| 49 string16 error_message); | |
| 50 ~PolicyStatusInfo(); | |
| 51 | |
| 52 // Returns a DictionaryValue pointer containing the information in the object | |
| 53 // for UI purposes. The caller acquires ownership of the returned value. | |
| 54 DictionaryValue* GetDictionaryValue() const; | |
| 55 | |
| 56 // Returns true if this PolicyStatusInfo object and |other_info| have equal | |
| 57 // contents and false otherwise. | |
| 58 bool Equals(const PolicyStatusInfo* other_info) const; | |
| 59 | |
| 60 // This creates a deep copy of the PolicyStatusInfo object (only needed to | |
| 61 // get a deep copy of the Value object the PolicyStatusInfo contains). | |
| 62 PolicyStatusInfo* DeepCopy() const; | |
| 63 | |
| 64 // | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
missing comment?
simo
2011/08/10 14:28:19
Done.
| |
| 65 static string16 getSourceTypeString(PolicySourceType source_type); | |
| 66 | |
| 67 static string16 getPolicyLevelString(PolicyLevel level); | |
| 68 | |
| 69 // The name of the policy. | |
| 70 string16 name; | |
| 71 | |
| 72 // The source type of the policy (user, device or undefined). | |
| 73 PolicySourceType source_type; | |
| 74 | |
| 75 // The level of the policy (mandatory, recommended or undefined). | |
| 76 PolicyLevel level; | |
| 77 | |
| 78 // The policy value. | |
| 79 scoped_ptr<Value> value; | |
| 80 | |
| 81 // The policy status (details whether the policy was successfully enforced). | |
| 82 PolicyStatus status; | |
| 83 | |
| 84 // An error message in cases where the policy could not be enforced. | |
| 85 string16 error_message; | |
| 86 | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
no newline here
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
If you intentionally left out the DISALLOW_COPY_AN
simo
2011/08/10 14:28:19
I didn't intentionally leave it out but on rethink
simo
2011/08/10 14:28:19
Done.
| |
| 87 }; | |
| 88 | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
only one newline
simo
2011/08/10 14:28:19
Done.
| |
| 89 | |
| 90 // Wrapper class around an std::map<ConfigurationPolicyType, PolicyStatusInfo*> | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
What benefit do we get from using a wrapper?
simo
2011/08/09 21:03:02
I did this because I think it makes the Configurat
| |
| 91 class PolicyStatusMap { | |
| 92 | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
no newline
| |
| 93 public: | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
indentation
| |
| 94 typedef std::map<ConfigurationPolicyType, PolicyStatusInfo*> | |
| 95 PolicyStatusMapType; | |
| 96 typedef PolicyStatusMapType::const_iterator const_iterator; | |
| 97 | |
| 98 PolicyStatusMap(); | |
| 99 ~PolicyStatusMap(); | |
| 100 | |
| 101 // Returns the value stored for key |policy|. Retains ownership of the | |
| 102 // returned |PolicyStatusInfo| pointer. Call PolicyStatusInfo::DeepCopy() | |
| 103 // for your own copy. Returns NULL if the map does not contain a value for | |
| 104 // the given key. | |
| 105 const PolicyStatusInfo* Get(ConfigurationPolicyType policy) const; | |
| 106 | |
| 107 // Overwrites any exisiting value stored in the map for the key |policy| and | |
| 108 // takes ownership of |info|. | |
| 109 void Set(ConfigurationPolicyType policy, PolicyStatusInfo* info); | |
| 110 | |
| 111 bool empty() const; | |
| 112 size_t size() const; | |
| 113 | |
| 114 const_iterator begin() const; | |
| 115 const_iterator end() const; | |
| 116 | |
| 117 void Clear(); | |
| 118 | |
| 119 private: | |
| 120 PolicyStatusMapType map_; | |
| 121 | |
| 122 DISALLOW_COPY_AND_ASSIGN(PolicyStatusMap); | |
| 123 }; | |
| 124 | |
| 125 } // policy | |
|
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
namespace policy
simo
2011/08/10 14:28:19
Done.
| |
| 126 | |
| 127 #endif // CHROME_BROWSER_POLICY_POLICY_STATUS_MAP_H_ | |
| OLD | NEW |