| 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 class SimplePendingError : public PolicyErrorMap::PendingError { | 36 class SimplePendingError : public PolicyErrorMap::PendingError { |
| 37 public: | 37 public: |
| 38 SimplePendingError(const std::string& policy_name, | 38 SimplePendingError(const std::string& policy_name, |
| 39 int message_id, | 39 int message_id, |
| 40 const std::string& replacement) | 40 const std::string& replacement) |
| 41 : PendingError(policy_name), | 41 : PendingError(policy_name), |
| 42 message_id_(message_id), | 42 message_id_(message_id), |
| 43 replacement_(replacement) {} | 43 replacement_(replacement) {} |
| 44 virtual ~SimplePendingError() {} | 44 ~SimplePendingError() override {} |
| 45 | 45 |
| 46 virtual base::string16 GetMessage() const override { | 46 base::string16 GetMessage() const override { |
| 47 if (message_id_ >= 0) { | 47 if (message_id_ >= 0) { |
| 48 if (replacement_.empty()) | 48 if (replacement_.empty()) |
| 49 return l10n_util::GetStringUTF16(message_id_); | 49 return l10n_util::GetStringUTF16(message_id_); |
| 50 return l10n_util::GetStringFUTF16(message_id_, | 50 return l10n_util::GetStringFUTF16(message_id_, |
| 51 base::ASCIIToUTF16(replacement_)); | 51 base::ASCIIToUTF16(replacement_)); |
| 52 } | 52 } |
| 53 return base::ASCIIToUTF16(replacement_); | 53 return base::ASCIIToUTF16(replacement_); |
| 54 } | 54 } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 int message_id_; | 57 int message_id_; |
| 58 std::string replacement_; | 58 std::string replacement_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(SimplePendingError); | 60 DISALLOW_COPY_AND_ASSIGN(SimplePendingError); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 class DictSubkeyPendingError : public SimplePendingError { | 63 class DictSubkeyPendingError : public SimplePendingError { |
| 64 public: | 64 public: |
| 65 DictSubkeyPendingError(const std::string& policy_name, | 65 DictSubkeyPendingError(const std::string& policy_name, |
| 66 const std::string& subkey, | 66 const std::string& subkey, |
| 67 int message_id, | 67 int message_id, |
| 68 const std::string& replacement) | 68 const std::string& replacement) |
| 69 : SimplePendingError(policy_name, message_id, replacement), | 69 : SimplePendingError(policy_name, message_id, replacement), |
| 70 subkey_(subkey) {} | 70 subkey_(subkey) {} |
| 71 virtual ~DictSubkeyPendingError() {} | 71 ~DictSubkeyPendingError() override {} |
| 72 | 72 |
| 73 virtual base::string16 GetMessage() const override { | 73 base::string16 GetMessage() const override { |
| 74 return l10n_util::GetStringFUTF16(IDS_POLICY_SUBKEY_ERROR, | 74 return l10n_util::GetStringFUTF16(IDS_POLICY_SUBKEY_ERROR, |
| 75 base::ASCIIToUTF16(subkey_), | 75 base::ASCIIToUTF16(subkey_), |
| 76 SimplePendingError::GetMessage()); | 76 SimplePendingError::GetMessage()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 std::string subkey_; | 80 std::string subkey_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(DictSubkeyPendingError); | 82 DISALLOW_COPY_AND_ASSIGN(DictSubkeyPendingError); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 class ListItemPendingError : public SimplePendingError { | 85 class ListItemPendingError : public SimplePendingError { |
| 86 public: | 86 public: |
| 87 ListItemPendingError(const std::string& policy_name, | 87 ListItemPendingError(const std::string& policy_name, |
| 88 int index, | 88 int index, |
| 89 int message_id, | 89 int message_id, |
| 90 const std::string& replacement) | 90 const std::string& replacement) |
| 91 : SimplePendingError(policy_name, message_id, replacement), | 91 : SimplePendingError(policy_name, message_id, replacement), |
| 92 index_(index) {} | 92 index_(index) {} |
| 93 virtual ~ListItemPendingError() {} | 93 ~ListItemPendingError() override {} |
| 94 | 94 |
| 95 virtual base::string16 GetMessage() const override { | 95 base::string16 GetMessage() const override { |
| 96 return l10n_util::GetStringFUTF16(IDS_POLICY_LIST_ENTRY_ERROR, | 96 return l10n_util::GetStringFUTF16(IDS_POLICY_LIST_ENTRY_ERROR, |
| 97 base::IntToString16(index_), | 97 base::IntToString16(index_), |
| 98 SimplePendingError::GetMessage()); | 98 SimplePendingError::GetMessage()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 int index_; | 102 int index_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(ListItemPendingError); | 104 DISALLOW_COPY_AND_ASSIGN(ListItemPendingError); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class SchemaValidatingPendingError : public SimplePendingError { | 107 class SchemaValidatingPendingError : public SimplePendingError { |
| 108 public: | 108 public: |
| 109 SchemaValidatingPendingError(const std::string& policy_name, | 109 SchemaValidatingPendingError(const std::string& policy_name, |
| 110 const std::string& error_path, | 110 const std::string& error_path, |
| 111 const std::string& replacement) | 111 const std::string& replacement) |
| 112 : SimplePendingError(policy_name, -1, replacement), | 112 : SimplePendingError(policy_name, -1, replacement), |
| 113 error_path_(error_path) {}; | 113 error_path_(error_path) {}; |
| 114 virtual ~SchemaValidatingPendingError() {} | 114 ~SchemaValidatingPendingError() override {} |
| 115 | 115 |
| 116 virtual base::string16 GetMessage() const override { | 116 base::string16 GetMessage() const override { |
| 117 return l10n_util::GetStringFUTF16(IDS_POLICY_SCHEMA_VALIDATION_ERROR, | 117 return l10n_util::GetStringFUTF16(IDS_POLICY_SCHEMA_VALIDATION_ERROR, |
| 118 base::ASCIIToUTF16(error_path_), | 118 base::ASCIIToUTF16(error_path_), |
| 119 SimplePendingError::GetMessage()); | 119 SimplePendingError::GetMessage()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 std::string error_path_; | 123 std::string error_path_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(SchemaValidatingPendingError); | 125 DISALLOW_COPY_AND_ASSIGN(SchemaValidatingPendingError); |
| 126 }; | 126 }; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 void PolicyErrorMap::CheckReadyAndConvert() { | 230 void PolicyErrorMap::CheckReadyAndConvert() { |
| 231 DCHECK(IsReady()); | 231 DCHECK(IsReady()); |
| 232 for (size_t i = 0; i < pending_.size(); ++i) { | 232 for (size_t i = 0; i < pending_.size(); ++i) { |
| 233 Convert(pending_[i]); | 233 Convert(pending_[i]); |
| 234 } | 234 } |
| 235 pending_.clear(); | 235 pending_.clear(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace policy | 238 } // namespace policy |
| OLD | NEW |