| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_POLICY_CORE_BROWSER_POLICY_ERROR_MAP_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_POLICY_ERROR_MAP_H_ |
| 6 #define COMPONENTS_POLICY_CORE_BROWSER_POLICY_ERROR_MAP_H_ | 6 #define COMPONENTS_POLICY_CORE_BROWSER_POLICY_ERROR_MAP_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "components/policy/policy_export.h" | 14 #include "components/policy/policy_export.h" |
| 15 | 15 |
| 16 namespace policy { | 16 namespace policy { |
| 17 | 17 |
| 18 // Collects error messages and their associated policies. | 18 // Collects error messages and their associated policies. |
| 19 class POLICY_EXPORT PolicyErrorMap { | 19 class POLICY_EXPORT PolicyErrorMap { |
| 20 public: | 20 public: |
| 21 typedef std::multimap<std::string, string16> PolicyMapType; | 21 typedef std::multimap<std::string, base::string16> PolicyMapType; |
| 22 typedef PolicyMapType::const_iterator const_iterator; | 22 typedef PolicyMapType::const_iterator const_iterator; |
| 23 | 23 |
| 24 PolicyErrorMap(); | 24 PolicyErrorMap(); |
| 25 virtual ~PolicyErrorMap(); | 25 virtual ~PolicyErrorMap(); |
| 26 | 26 |
| 27 // 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 |
| 28 // 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 |
| 29 // 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. |
| 30 bool IsReady() const; | 30 bool IsReady() const; |
| 31 | 31 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Adds an entry with key |policy|, list index |index| and the error message | 63 // Adds an entry with key |policy|, list index |index| and the error message |
| 64 // corresponding to |message_id| in grit/generated_resources.h to the map. | 64 // corresponding to |message_id| in grit/generated_resources.h to the map. |
| 65 // Replaces the placeholder in the error message with |replacement_string|. | 65 // Replaces the placeholder in the error message with |replacement_string|. |
| 66 void AddError(const std::string& policy, | 66 void AddError(const std::string& policy, |
| 67 int index, | 67 int index, |
| 68 int message_id, | 68 int message_id, |
| 69 const std::string& replacement_string); | 69 const std::string& replacement_string); |
| 70 | 70 |
| 71 // Returns all the error messages stored for |policy|, separated by a white | 71 // Returns all the error messages stored for |policy|, separated by a white |
| 72 // space. Returns an empty string if there are no errors for |policy|. | 72 // space. Returns an empty string if there are no errors for |policy|. |
| 73 string16 GetErrors(const std::string& policy); | 73 base::string16 GetErrors(const std::string& policy); |
| 74 | 74 |
| 75 bool empty(); | 75 bool empty(); |
| 76 size_t size(); | 76 size_t size(); |
| 77 | 77 |
| 78 const_iterator begin(); | 78 const_iterator begin(); |
| 79 const_iterator end(); | 79 const_iterator end(); |
| 80 | 80 |
| 81 void Clear(); | 81 void Clear(); |
| 82 | 82 |
| 83 private: | 83 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 94 | 94 |
| 95 std::vector<PendingError> pending_; | 95 std::vector<PendingError> pending_; |
| 96 PolicyMapType map_; | 96 PolicyMapType map_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); | 98 DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace policy | 101 } // namespace policy |
| 102 | 102 |
| 103 #endif // COMPONENTS_POLICY_CORE_BROWSER_POLICY_ERROR_MAP_H_ | 103 #endif // COMPONENTS_POLICY_CORE_BROWSER_POLICY_ERROR_MAP_H_ |
| OLD | NEW |