| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "policy/configuration_policy_type.h" | |
| 16 | 15 |
| 17 namespace policy { | 16 namespace policy { |
| 18 | 17 |
| 19 // Collects error messages and their associated policies. | 18 // Collects error messages and their associated policies. |
| 20 class PolicyErrorMap { | 19 class PolicyErrorMap { |
| 21 public: | 20 public: |
| 22 typedef std::multimap<ConfigurationPolicyType, string16> PolicyMapType; | 21 typedef std::multimap<std::string, string16> PolicyMapType; |
| 23 typedef PolicyMapType::const_iterator const_iterator; | 22 typedef PolicyMapType::const_iterator const_iterator; |
| 24 | 23 |
| 25 PolicyErrorMap(); | 24 PolicyErrorMap(); |
| 26 virtual ~PolicyErrorMap(); | 25 virtual ~PolicyErrorMap(); |
| 27 | 26 |
| 28 // Returns true when the errors logged are ready to be retrieved. It is always | 27 // 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 | 28 // 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. | 29 // IsReady is true. IsReady will be true once the UI message loop has started. |
| 31 bool IsReady() const; | 30 bool IsReady() const; |
| 32 | 31 |
| 33 // Adds an entry with key |policy| and the error message corresponding to | 32 // Adds an entry with key |policy| and the error message corresponding to |
| 34 // |message_id| in grit/generated_resources.h to the map. | 33 // |message_id| in grit/generated_resources.h to the map. |
| 35 void AddError(ConfigurationPolicyType policy, int message_id); | 34 void AddError(const std::string& policy, int message_id); |
| 36 | 35 |
| 37 // Adds an entry with key |policy|, subkey |subkey|, and the error message | 36 // Adds an entry with key |policy|, subkey |subkey|, and the error message |
| 38 // corresponding to |message_id| in grit/generated_resources.h to the map. | 37 // corresponding to |message_id| in grit/generated_resources.h to the map. |
| 39 void AddError(ConfigurationPolicyType policy, | 38 void AddError(const std::string& policy, |
| 40 const std::string& subkey, | 39 const std::string& subkey, |
| 41 int message_id); | 40 int message_id); |
| 42 | 41 |
| 43 // Adds an entry with key |policy| and the error message corresponding to | 42 // Adds an entry with key |policy| and the error message corresponding to |
| 44 // |message_id| in grit/generated_resources.h to the map and replaces the | 43 // |message_id| in grit/generated_resources.h to the map and replaces the |
| 45 // placeholder within the error message with |replacement_string|. | 44 // placeholder within the error message with |replacement_string|. |
| 46 void AddError(ConfigurationPolicyType policy, | 45 void AddError(const std::string& policy, |
| 47 int message_id, | 46 int message_id, |
| 48 const std::string& replacement_string); | 47 const std::string& replacement_string); |
| 49 | 48 |
| 50 // Adds an entry with key |policy|, subkey |subkey| and the error message | 49 // Adds an entry with key |policy|, subkey |subkey| and the error message |
| 51 // corresponding to |message_id| in grit/generated_resources.h to the map. | 50 // corresponding to |message_id| in grit/generated_resources.h to the map. |
| 52 // Replaces the placeholder in the error message with |replacement_string|. | 51 // Replaces the placeholder in the error message with |replacement_string|. |
| 53 void AddError(ConfigurationPolicyType policy, | 52 void AddError(const std::string& policy, |
| 54 const std::string& subkey, | 53 const std::string& subkey, |
| 55 int message_id, | 54 int message_id, |
| 56 const std::string& replacement_string); | 55 const std::string& replacement_string); |
| 57 | 56 |
| 58 // Returns all the error messages stored for |policy|, separated by a white | 57 // Returns all the error messages stored for |policy|, separated by a white |
| 59 // space. Returns an empty string if there are no errors for |policy|. | 58 // space. Returns an empty string if there are no errors for |policy|. |
| 60 string16 GetErrors(ConfigurationPolicyType policy); | 59 string16 GetErrors(const std::string& policy); |
| 61 | 60 |
| 62 bool empty(); | 61 bool empty(); |
| 63 size_t size(); | 62 size_t size(); |
| 64 | 63 |
| 65 const_iterator begin(); | 64 const_iterator begin(); |
| 66 const_iterator end(); | 65 const_iterator end(); |
| 67 | 66 |
| 68 void Clear(); | 67 void Clear(); |
| 69 | 68 |
| 70 private: | 69 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 81 | 80 |
| 82 std::vector<PendingError> pending_; | 81 std::vector<PendingError> pending_; |
| 83 PolicyMapType map_; | 82 PolicyMapType map_; |
| 84 | 83 |
| 85 DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); | 84 DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); |
| 86 }; | 85 }; |
| 87 | 86 |
| 88 } // namespace policy | 87 } // namespace policy |
| 89 | 88 |
| 90 #endif // CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ | 89 #endif // CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ |
| OLD | NEW |