Chromium Code Reviews| Index: chrome/browser/policy/policy_error_map.cc |
| diff --git a/chrome/browser/policy/policy_error_map.cc b/chrome/browser/policy/policy_error_map.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9500831ef0096b08e2d02994c87c4e06966c0dd9 |
| --- /dev/null |
| +++ b/chrome/browser/policy/policy_error_map.cc |
| @@ -0,0 +1,62 @@ |
| +// 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. |
| + |
| +#include "chrome/browser/policy/policy_error_map.h" |
| + |
| +#include <algorithm> |
| + |
| +#include "base/stl_util.h" |
| + |
| +namespace policy { |
| + |
| +PolicyErrorMap::PolicyErrorMap() { |
| +} |
| + |
| +PolicyErrorMap::~PolicyErrorMap() { |
| + Clear(); |
| +} |
| + |
| +void PolicyErrorMap::AddError(ConfigurationPolicyType policy, |
| + StringValue* error_message) { |
| + map_.insert( |
| + std::pair<ConfigurationPolicyType, StringValue*>(policy, error_message)); |
| +} |
| + |
| +ListValue* PolicyErrorMap::GetErrors( |
| + ConfigurationPolicyType policy) const { |
| + std::pair<const_iterator, const_iterator> range = map_.equal_range(policy); |
| + |
| + if (range.first == range.second) |
| + return NULL; |
| + |
| + const_iterator it = range.first; |
|
Mattias Nissler (ping if slow)
2011/09/20 13:12:25
move int loop initializer below?
simo
2011/09/22 11:43:26
Done.
|
| + ListValue* list = new ListValue(); |
| + for ( ; it != range.second; ++it) { |
|
Mattias Nissler (ping if slow)
2011/09/20 13:12:25
no need for curlies
simo
2011/09/22 11:43:26
Done.
|
| + list->Append(it->second->DeepCopy()); |
| + } |
| + |
| + return list; |
| +} |
| + |
| +bool PolicyErrorMap::empty() const { |
| + return map_.empty(); |
| +} |
| + |
| +size_t PolicyErrorMap::size() const { |
| + return map_.size(); |
| +} |
| + |
| +PolicyErrorMap::const_iterator PolicyErrorMap::begin() const { |
| + return map_.begin(); |
| +} |
| + |
| +PolicyErrorMap::const_iterator PolicyErrorMap::end() const { |
| + return map_.end(); |
| +} |
| + |
| +void PolicyErrorMap::Clear() { |
| + STLDeleteValues(&map_); |
| +} |
| + |
| +} // namespace policy |