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

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..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

Powered by Google App Engine
This is Rietveld 408576698