Index: chrome/browser/policy/policy_status_map.h |
diff --git a/chrome/browser/policy/policy_status_map.h b/chrome/browser/policy/policy_status_map.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8c6e2c5851bc26d2303d399f9346e4d0cebd8497 |
--- /dev/null |
+++ b/chrome/browser/policy/policy_status_map.h |
@@ -0,0 +1,127 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_POLICY_POLICY_STATUS_MAP_H_ |
+#define CHROME_BROWSER_POLICY_POLICY_STATUS_MAP_H_ |
+ |
+#include <map> |
+ |
+#include "base/scoped_ptr.h" |
+#include "base/values.h" |
+#include "policy/configuration_policy_type.h" |
+ |
+namespace policy { |
+ |
+// Describes a policy's status on the client. |
+struct PolicyStatusInfo { |
+ |
+ // Defines the possible sources a policy can have (user, device or none if the |
+ // 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.
|
+ enum PolicySourceType { |
+ USER, |
+ DEVICE, |
+ SOURCE_TYPE_UNDEFINED, |
+ }; |
+ |
+ // Defines the possible levels a policy can be operating on (mandatory, |
+ // recommended or none). |
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
same here.
simo
2011/08/10 14:28:19
Done.
|
+ enum PolicyLevel { |
+ MANDATORY, |
+ RECOMMENDED, |
+ LEVEL_UNDEFINED, |
+ }; |
+ |
+ // Defines the possible statuses a policy can have (successfully enforced, not |
+ // enforced or undefined). |
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
same here
simo
2011/08/10 14:28:19
Done.
|
+ enum PolicyStatus { |
+ ENFORCED, |
+ FAILED, |
+ STATUS_UNDEFINED, |
+ }; |
+ |
+ PolicyStatusInfo(); |
+ 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.
|
+ PolicySourceType source_type, |
+ PolicyLevel level, |
+ Value* value, |
+ PolicyStatus status, |
+ string16 error_message); |
+ ~PolicyStatusInfo(); |
+ |
+ // Returns a DictionaryValue pointer containing the information in the object |
+ // for UI purposes. The caller acquires ownership of the returned value. |
+ DictionaryValue* GetDictionaryValue() const; |
+ |
+ // Returns true if this PolicyStatusInfo object and |other_info| have equal |
+ // contents and false otherwise. |
+ bool Equals(const PolicyStatusInfo* other_info) const; |
+ |
+ // This creates a deep copy of the PolicyStatusInfo object (only needed to |
+ // get a deep copy of the Value object the PolicyStatusInfo contains). |
+ PolicyStatusInfo* DeepCopy() const; |
+ |
+ // |
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
missing comment?
simo
2011/08/10 14:28:19
Done.
|
+ static string16 getSourceTypeString(PolicySourceType source_type); |
+ |
+ static string16 getPolicyLevelString(PolicyLevel level); |
+ |
+ // The name of the policy. |
+ string16 name; |
+ |
+ // The source type of the policy (user, device or undefined). |
+ PolicySourceType source_type; |
+ |
+ // The level of the policy (mandatory, recommended or undefined). |
+ PolicyLevel level; |
+ |
+ // The policy value. |
+ scoped_ptr<Value> value; |
+ |
+ // The policy status (details whether the policy was successfully enforced). |
+ PolicyStatus status; |
+ |
+ // An error message in cases where the policy could not be enforced. |
+ string16 error_message; |
+ |
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.
|
+}; |
+ |
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
only one newline
simo
2011/08/10 14:28:19
Done.
|
+ |
+// 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
|
+class PolicyStatusMap { |
+ |
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
no newline
|
+ public: |
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
indentation
|
+ typedef std::map<ConfigurationPolicyType, PolicyStatusInfo*> |
+ PolicyStatusMapType; |
+ typedef PolicyStatusMapType::const_iterator const_iterator; |
+ |
+ PolicyStatusMap(); |
+ ~PolicyStatusMap(); |
+ |
+ // Returns the value stored for key |policy|. Retains ownership of the |
+ // returned |PolicyStatusInfo| pointer. Call PolicyStatusInfo::DeepCopy() |
+ // for your own copy. Returns NULL if the map does not contain a value for |
+ // the given key. |
+ const PolicyStatusInfo* Get(ConfigurationPolicyType policy) const; |
+ |
+ // Overwrites any exisiting value stored in the map for the key |policy| and |
+ // takes ownership of |info|. |
+ void Set(ConfigurationPolicyType policy, PolicyStatusInfo* info); |
+ |
+ bool empty() const; |
+ size_t size() const; |
+ |
+ const_iterator begin() const; |
+ const_iterator end() const; |
+ |
+ void Clear(); |
+ |
+ private: |
+ PolicyStatusMapType map_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PolicyStatusMap); |
+}; |
+ |
+} // policy |
Mattias Nissler (ping if slow)
2011/08/09 13:20:40
namespace policy
simo
2011/08/10 14:28:19
Done.
|
+ |
+#endif // CHROME_BROWSER_POLICY_POLICY_STATUS_MAP_H_ |