| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // The files are processed in reverse order because |MergeFrom| gives priority | 136 // The files are processed in reverse order because |MergeFrom| gives priority |
| 137 // to existing keys, but the ConfigDirPolicyProvider gives priority to the | 137 // to existing keys, but the ConfigDirPolicyProvider gives priority to the |
| 138 // last file in lexicographic order. | 138 // last file in lexicographic order. |
| 139 for (std::set<base::FilePath>::reverse_iterator config_file_iter = | 139 for (std::set<base::FilePath>::reverse_iterator config_file_iter = |
| 140 files.rbegin(); config_file_iter != files.rend(); | 140 files.rbegin(); config_file_iter != files.rend(); |
| 141 ++config_file_iter) { | 141 ++config_file_iter) { |
| 142 JSONFileValueDeserializer deserializer(*config_file_iter); | 142 JSONFileValueDeserializer deserializer(*config_file_iter); |
| 143 deserializer.set_allow_trailing_comma(true); | 143 deserializer.set_allow_trailing_comma(true); |
| 144 int error_code = 0; | 144 int error_code = 0; |
| 145 std::string error_msg; | 145 std::string error_msg; |
| 146 scoped_ptr<base::Value> value( | 146 scoped_ptr<base::Value> value = |
| 147 deserializer.Deserialize(&error_code, &error_msg)); | 147 deserializer.Deserialize(&error_code, &error_msg); |
| 148 if (!value.get()) { | 148 if (!value.get()) { |
| 149 LOG(WARNING) << "Failed to read configuration file " | 149 LOG(WARNING) << "Failed to read configuration file " |
| 150 << config_file_iter->value() << ": " << error_msg; | 150 << config_file_iter->value() << ": " << error_msg; |
| 151 status.Add(JsonErrorToPolicyLoadStatus(error_code)); | 151 status.Add(JsonErrorToPolicyLoadStatus(error_code)); |
| 152 continue; | 152 continue; |
| 153 } | 153 } |
| 154 base::DictionaryValue* dictionary_value = NULL; | 154 base::DictionaryValue* dictionary_value = NULL; |
| 155 if (!value->GetAsDictionary(&dictionary_value)) { | 155 if (!value->GetAsDictionary(&dictionary_value)) { |
| 156 LOG(WARNING) << "Expected JSON dictionary in configuration file " | 156 LOG(WARNING) << "Expected JSON dictionary in configuration file " |
| 157 << config_file_iter->value(); | 157 << config_file_iter->value(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 void ConfigDirPolicyLoader::OnFileUpdated(const base::FilePath& path, | 227 void ConfigDirPolicyLoader::OnFileUpdated(const base::FilePath& path, |
| 228 bool error) { | 228 bool error) { |
| 229 if (!error) | 229 if (!error) |
| 230 Reload(false); | 230 Reload(false); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace policy | 233 } // namespace policy |
| OLD | NEW |