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_ERROR_MAP_H_ | |
6 #define CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 #include <string> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/string16.h" | |
14 #include "base/values.h" | |
15 #include "policy/configuration_policy_type.h" | |
16 | |
17 namespace policy { | |
18 | |
19 // Wrapper class around a std::multimap<ConfigurationPolicyType, string16> | |
20 // used to associate policies with error messages generated when a policy fails | |
21 // to be applied. | |
22 class PolicyErrorMap { | |
23 public: | |
24 typedef std::multimap<ConfigurationPolicyType, string16> PolicyMapType; | |
25 typedef PolicyMapType::const_iterator const_iterator; | |
26 | |
27 PolicyErrorMap(); | |
28 virtual ~PolicyErrorMap(); | |
29 | |
30 // Adds an entry with key |policy| and the error message corresponding to | |
31 // |message_id| in grit/generated_resources.h to the map. | |
32 void AddError(ConfigurationPolicyType policy, int message_id); | |
33 | |
34 // Adds an entry with key |policy| and the error message corresponding to | |
35 // |message_id| in grit/generated_resources.h to the map and replaces the | |
36 // placeholder within the error message with |replacement_string|. | |
37 void AddError(ConfigurationPolicyType policy, | |
38 int message_id, | |
39 std::string replacement_string); | |
Mattias Nissler (ping if slow)
2011/09/26 13:30:48
const ref
simo
2011/09/29 09:33:08
Done.
| |
40 | |
41 // Returns a list of all the error messages stored for |policy|. Returns NULL | |
42 // if there are no error messages for |policy. The caller acquires ownership | |
43 // of the returned ListValue pointer. | |
44 ListValue* GetErrors(ConfigurationPolicyType policy) const; | |
45 | |
46 bool empty() const; | |
47 size_t size() const; | |
48 | |
49 const_iterator begin() const; | |
50 const_iterator end() const; | |
51 | |
52 void Clear(); | |
53 | |
54 private: | |
55 // Adds an entry with key |policy| and value |errror| to the map. | |
56 void Insert(ConfigurationPolicyType policy, string16 error); | |
57 | |
58 PolicyMapType map_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); | |
61 }; | |
62 | |
63 } // namespace policy | |
64 | |
65 #endif // CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ | |
OLD | NEW |