OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ | 5 #ifndef CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ |
6 #define CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ | 6 #define CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | |
11 | 12 |
12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
13 #include "base/string16.h" | 14 #include "base/string16.h" |
14 #include "base/values.h" | |
15 #include "policy/configuration_policy_type.h" | 15 #include "policy/configuration_policy_type.h" |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 | 18 |
19 // Collects error messages and their associated policies. | 19 // Collects error messages and their associated policies. |
20 class PolicyErrorMap { | 20 class PolicyErrorMap { |
21 public: | 21 public: |
22 typedef std::multimap<ConfigurationPolicyType, string16> PolicyMapType; | 22 typedef std::multimap<ConfigurationPolicyType, string16> PolicyMapType; |
23 typedef PolicyMapType::const_iterator const_iterator; | 23 typedef PolicyMapType::const_iterator const_iterator; |
24 | 24 |
25 PolicyErrorMap(); | 25 PolicyErrorMap(); |
26 virtual ~PolicyErrorMap(); | 26 virtual ~PolicyErrorMap(); |
27 | 27 |
28 // Returns true when the errors logged are ready to be retrieved. It is always | 28 // Returns true when the errors logged are ready to be retrieved. It is always |
29 // safe to call AddError, but the other methods are only allowed once | 29 // safe to call AddError, but the other methods are only allowed once |
30 // IsReady is true. IsReady will be true once the UI message loop has started. | 30 // IsReady is true. IsReady will be true once the UI message loop has started. |
31 bool IsReady() const; | 31 bool IsReady() const; |
32 | 32 |
33 // Adds an entry with key |policy| and the error message corresponding to | 33 // Adds an entry with key |policy| and the error message corresponding to |
34 // |message_id| in grit/generated_resources.h to the map. | 34 // |message_id| in grit/generated_resources.h to the map. |
35 void AddError(ConfigurationPolicyType policy, int message_id); | 35 void AddError(ConfigurationPolicyType policy, int message_id); |
36 | 36 |
37 // Adds an entry with key |policy| and the error message corresponding to | 37 // Adds an entry with key |policy| and the error message corresponding to |
38 // |message_id| in grit/generated_resources.h to the map and replaces the | 38 // |message_id| in grit/generated_resources.h to the map and replaces the |
39 // placeholder within the error message with |replacement_string|. | 39 // placeholder within the error message with |replacement_string|. |
40 void AddError(ConfigurationPolicyType policy, | 40 void AddError(ConfigurationPolicyType policy, |
41 int message_id, | 41 int message_id, |
42 const std::string& replacement_string); | 42 const std::string& replacement_string); |
43 | 43 |
44 // Returns a list of all the error messages stored for |policy|. Returns NULL | 44 // Returns all the errors messages stored for |policy|, separated by a white |
Mattias Nissler (ping if slow)
2011/10/28 16:07:45
errors messages? either s/errors/error/ or drop s/
Joao da Silva
2011/10/28 16:14:10
Done.
| |
45 // if there are no error messages for |policy. The caller acquires ownership | 45 // space. Returns an empty string if there are no errors for |policy|. |
46 // of the returned ListValue pointer. | 46 string16 GetErrors(ConfigurationPolicyType policy); |
47 ListValue* GetErrors(ConfigurationPolicyType policy); | |
48 | 47 |
49 bool empty(); | 48 bool empty(); |
50 size_t size(); | 49 size_t size(); |
51 | 50 |
52 const_iterator begin(); | 51 const_iterator begin(); |
53 const_iterator end(); | 52 const_iterator end(); |
54 | 53 |
55 void Clear(); | 54 void Clear(); |
56 | 55 |
57 private: | 56 private: |
(...skipping 10 matching lines...) Expand all Loading... | |
68 | 67 |
69 std::vector<PendingError> pending_; | 68 std::vector<PendingError> pending_; |
70 PolicyMapType map_; | 69 PolicyMapType map_; |
71 | 70 |
72 DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); | 71 DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); |
73 }; | 72 }; |
74 | 73 |
75 } // namespace policy | 74 } // namespace policy |
76 | 75 |
77 #endif // CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ | 76 #endif // CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ |
OLD | NEW |