OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/config_dir_policy_loader.h" | 5 #include "components/policy/core/common/config_dir_policy_loader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return; | 135 return; |
136 } | 136 } |
137 | 137 |
138 // Start with an empty dictionary and merge the files' contents. | 138 // Start with an empty dictionary and merge the files' contents. |
139 // The files are processed in reverse order because |MergeFrom| gives priority | 139 // The files are processed in reverse order because |MergeFrom| gives priority |
140 // to existing keys, but the ConfigDirPolicyProvider gives priority to the | 140 // to existing keys, but the ConfigDirPolicyProvider gives priority to the |
141 // last file in lexicographic order. | 141 // last file in lexicographic order. |
142 for (std::set<base::FilePath>::reverse_iterator config_file_iter = | 142 for (std::set<base::FilePath>::reverse_iterator config_file_iter = |
143 files.rbegin(); config_file_iter != files.rend(); | 143 files.rbegin(); config_file_iter != files.rend(); |
144 ++config_file_iter) { | 144 ++config_file_iter) { |
145 JSONFileValueDeserializer deserializer(*config_file_iter); | 145 JSONFileValueDeserializer deserializer(*config_file_iter, |
146 deserializer.set_allow_trailing_comma(true); | 146 base::JSON_ALLOW_TRAILING_COMMAS); |
147 int error_code = 0; | 147 int error_code = 0; |
148 std::string error_msg; | 148 std::string error_msg; |
149 std::unique_ptr<base::Value> value = | 149 std::unique_ptr<base::Value> value = |
150 deserializer.Deserialize(&error_code, &error_msg); | 150 deserializer.Deserialize(&error_code, &error_msg); |
151 if (!value.get()) { | 151 if (!value.get()) { |
152 LOG(WARNING) << "Failed to read configuration file " | 152 LOG(WARNING) << "Failed to read configuration file " |
153 << config_file_iter->value() << ": " << error_msg; | 153 << config_file_iter->value() << ": " << error_msg; |
154 status.Add(JsonErrorToPolicyLoadStatus(error_code)); | 154 status.Add(JsonErrorToPolicyLoadStatus(error_code)); |
155 continue; | 155 continue; |
156 } | 156 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 void ConfigDirPolicyLoader::OnFileUpdated(const base::FilePath& path, | 230 void ConfigDirPolicyLoader::OnFileUpdated(const base::FilePath& path, |
231 bool error) { | 231 bool error) { |
232 if (!error) | 232 if (!error) |
233 Reload(false); | 233 Reload(false); |
234 } | 234 } |
235 | 235 |
236 } // namespace policy | 236 } // namespace policy |
OLD | NEW |