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

Unified Diff: chrome/browser/policy/policy_error_map.cc

Issue 7972013: ConfigurationPolicyPrefStore refactoring to surface error messages. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
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..d277c6b446597cf4fb33d8451163a341ed35bbe8
--- /dev/null
+++ b/chrome/browser/policy/policy_error_map.cc
@@ -0,0 +1,71 @@
+// 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 <utility>
+
+#include "base/logging.h"
+#include "base/stl_util.h"
+#include "base/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace policy {
+
+PolicyErrorMap::PolicyErrorMap() {
+}
+
+PolicyErrorMap::~PolicyErrorMap() {
+ Clear();
+}
+
+void PolicyErrorMap::AddError(ConfigurationPolicyType policy, int message_id) {
+ string16 error = l10n_util::GetStringUTF16(message_id);
+ map_.insert(std::make_pair(policy, error));
+}
+
+void PolicyErrorMap::AddError(ConfigurationPolicyType policy,
+ int message_id,
+ const std::string& replacement) {
+ string16 error = l10n_util::GetStringFUTF16(message_id,
+ ASCIIToUTF16(replacement));
+ map_.insert(std::make_pair(policy, error));
+}
+
+ListValue* PolicyErrorMap::GetErrors(
+ ConfigurationPolicyType policy) const {
+ std::pair<const_iterator, const_iterator> range = map_.equal_range(policy);
+
+ if (range.first == range.second)
+ return NULL;
+
+ ListValue* list = new ListValue();
+ for (const_iterator it = range.first; it != range.second; ++it)
+ list->Append(Value::CreateStringValue(it->second));
+
+ 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() {
+ map_.clear();
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698