Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/policy/policy_error_map.cc

Issue 8139029: Make policy errors available to display in about:policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bad commit Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/policy/policy_error_map.h"
6
7 #include <utility>
8
9 #include "base/utf_string_conversions.h"
10 #include "ui/base/l10n/l10n_util.h"
11
12 namespace policy {
13
14 PolicyErrorMap::PolicyErrorMap() {
15 }
16
17 PolicyErrorMap::~PolicyErrorMap() {
18 }
19
20 void PolicyErrorMap::AddError(ConfigurationPolicyType policy, int message_id) {
21 string16 error = l10n_util::GetStringUTF16(message_id);
22 map_.insert(std::make_pair(policy, error));
23 }
24
25 void PolicyErrorMap::AddError(ConfigurationPolicyType policy,
26 int message_id,
27 const std::string& replacement) {
28 string16 error = l10n_util::GetStringFUTF16(message_id,
29 ASCIIToUTF16(replacement));
30 map_.insert(std::make_pair(policy, error));
31 }
32
33 ListValue* PolicyErrorMap::GetErrors(ConfigurationPolicyType policy) const {
34 std::pair<const_iterator, const_iterator> range = map_.equal_range(policy);
35
36 if (range.first == range.second)
37 return NULL;
38
39 ListValue* list = new ListValue();
40 for (const_iterator it = range.first; it != range.second; ++it)
41 list->Append(Value::CreateStringValue(it->second));
42
43 return list;
44 }
45
46 bool PolicyErrorMap::empty() const {
47 return map_.empty();
48 }
49
50 size_t PolicyErrorMap::size() const {
51 return map_.size();
52 }
53
54 PolicyErrorMap::const_iterator PolicyErrorMap::begin() const {
55 return map_.begin();
56 }
57
58 PolicyErrorMap::const_iterator PolicyErrorMap::end() const {
59 return map_.end();
60 }
61
62 void PolicyErrorMap::Clear() {
63 map_.clear();
64 }
65
66 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698