Chromium Code Reviews| Index: chrome/browser/policy/policy_error_map.h |
| diff --git a/chrome/browser/policy/policy_error_map.h b/chrome/browser/policy/policy_error_map.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1f0d5994a32ac4022ade9d0bb74d911b1d72e4f0 |
| --- /dev/null |
| +++ b/chrome/browser/policy/policy_error_map.h |
| @@ -0,0 +1,65 @@ |
| +// 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_ERROR_MAP_H_ |
| +#define CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ |
| +#pragma once |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/string16.h" |
| +#include "base/values.h" |
| +#include "policy/configuration_policy_type.h" |
| + |
| +namespace policy { |
| + |
| +// Wrapper class around a std::multimap<ConfigurationPolicyType, string16> |
| +// used to associate policies with error messages generated when a policy fails |
| +// to be applied. |
| +class PolicyErrorMap { |
| + public: |
| + typedef std::multimap<ConfigurationPolicyType, string16> PolicyMapType; |
| + typedef PolicyMapType::const_iterator const_iterator; |
| + |
| + PolicyErrorMap(); |
| + virtual ~PolicyErrorMap(); |
| + |
| + // Adds an entry with key |policy| and the error message corresponding to |
| + // |message_id| in grit/generated_resources.h to the map. |
| + void AddError(ConfigurationPolicyType policy, int message_id); |
| + |
| + // Adds an entry with key |policy| and the error message corresponding to |
| + // |message_id| in grit/generated_resources.h to the map and replaces the |
| + // placeholder within the error message with |replacement_string|. |
| + void AddError(ConfigurationPolicyType policy, |
| + int message_id, |
| + 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.
|
| + |
| + // Returns a list of all the error messages stored for |policy|. Returns NULL |
| + // if there are no error messages for |policy. The caller acquires ownership |
| + // of the returned ListValue pointer. |
| + ListValue* GetErrors(ConfigurationPolicyType policy) const; |
| + |
| + bool empty() const; |
| + size_t size() const; |
| + |
| + const_iterator begin() const; |
| + const_iterator end() const; |
| + |
| + void Clear(); |
| + |
| + private: |
| + // Adds an entry with key |policy| and value |errror| to the map. |
| + void Insert(ConfigurationPolicyType policy, string16 error); |
| + |
| + PolicyMapType map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PolicyErrorMap); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_POLICY_ERROR_MAP_H_ |