| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/policy/core/browser/policy_error_map.h" | 5 #include "components/policy/core/browser/policy_error_map.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_piece.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "components/strings/grit/components_strings.h" | 15 #include "components/strings/grit/components_strings.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 17 | 18 |
| 18 namespace policy { | 19 namespace policy { |
| 19 | 20 |
| 20 class PolicyErrorMap::PendingError { | 21 class PolicyErrorMap::PendingError { |
| 21 public: | 22 public: |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 void PolicyErrorMap::AddError(const std::string& policy, | 185 void PolicyErrorMap::AddError(const std::string& policy, |
| 185 const std::string& error_path, | 186 const std::string& error_path, |
| 186 const std::string& message) { | 187 const std::string& message) { |
| 187 AddError(base::MakeUnique<SchemaValidatingPendingError>(policy, error_path, | 188 AddError(base::MakeUnique<SchemaValidatingPendingError>(policy, error_path, |
| 188 message)); | 189 message)); |
| 189 } | 190 } |
| 190 | 191 |
| 191 base::string16 PolicyErrorMap::GetErrors(const std::string& policy) { | 192 base::string16 PolicyErrorMap::GetErrors(const std::string& policy) { |
| 192 CheckReadyAndConvert(); | 193 CheckReadyAndConvert(); |
| 193 std::pair<const_iterator, const_iterator> range = map_.equal_range(policy); | 194 std::pair<const_iterator, const_iterator> range = map_.equal_range(policy); |
| 194 std::vector<base::string16> list; | 195 std::vector<base::StringPiece16> list; |
| 195 for (const_iterator it = range.first; it != range.second; ++it) | 196 for (const_iterator it = range.first; it != range.second; ++it) |
| 196 list.push_back(it->second); | 197 list.push_back(it->second); |
| 197 return base::JoinString(list, base::ASCIIToUTF16("\n")); | 198 return base::JoinString(list, base::ASCIIToUTF16("\n")); |
| 198 } | 199 } |
| 199 | 200 |
| 200 bool PolicyErrorMap::empty() { | 201 bool PolicyErrorMap::empty() { |
| 201 CheckReadyAndConvert(); | 202 CheckReadyAndConvert(); |
| 202 return map_.empty(); | 203 return map_.empty(); |
| 203 } | 204 } |
| 204 | 205 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 238 |
| 238 void PolicyErrorMap::CheckReadyAndConvert() { | 239 void PolicyErrorMap::CheckReadyAndConvert() { |
| 239 DCHECK(IsReady()); | 240 DCHECK(IsReady()); |
| 240 for (size_t i = 0; i < pending_.size(); ++i) { | 241 for (size_t i = 0; i < pending_.size(); ++i) { |
| 241 Convert(pending_[i].get()); | 242 Convert(pending_[i].get()); |
| 242 } | 243 } |
| 243 pending_.clear(); | 244 pending_.clear(); |
| 244 } | 245 } |
| 245 | 246 |
| 246 } // namespace policy | 247 } // namespace policy |
| OLD | NEW |