| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/policy/config_dir_policy_provider.h" | 5 #include "chrome/browser/policy/config_dir_policy_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 file_util::FileEnumerator::FILES); | 27 file_util::FileEnumerator::FILES); |
| 28 for (FilePath config_file_path = file_enumerator.Next(); | 28 for (FilePath config_file_path = file_enumerator.Next(); |
| 29 !config_file_path.empty(); config_file_path = file_enumerator.Next()) | 29 !config_file_path.empty(); config_file_path = file_enumerator.Next()) |
| 30 files.insert(config_file_path); | 30 files.insert(config_file_path); |
| 31 | 31 |
| 32 // Start with an empty dictionary and merge the files' contents. | 32 // Start with an empty dictionary and merge the files' contents. |
| 33 DictionaryValue* policy = new DictionaryValue; | 33 DictionaryValue* policy = new DictionaryValue; |
| 34 for (std::set<FilePath>::iterator config_file_iter = files.begin(); | 34 for (std::set<FilePath>::iterator config_file_iter = files.begin(); |
| 35 config_file_iter != files.end(); ++config_file_iter) { | 35 config_file_iter != files.end(); ++config_file_iter) { |
| 36 JSONFileValueSerializer deserializer(*config_file_iter); | 36 JSONFileValueSerializer deserializer(*config_file_iter); |
| 37 deserializer.set_allow_trailing_comma(true); |
| 37 int error_code = 0; | 38 int error_code = 0; |
| 38 std::string error_msg; | 39 std::string error_msg; |
| 39 scoped_ptr<Value> value(deserializer.Deserialize(&error_code, &error_msg)); | 40 scoped_ptr<Value> value(deserializer.Deserialize(&error_code, &error_msg)); |
| 40 if (!value.get()) { | 41 if (!value.get()) { |
| 41 LOG(WARNING) << "Failed to read configuration file " | 42 LOG(WARNING) << "Failed to read configuration file " |
| 42 << config_file_iter->value() << ": " << error_msg; | 43 << config_file_iter->value() << ": " << error_msg; |
| 43 continue; | 44 continue; |
| 44 } | 45 } |
| 45 if (!value->IsType(Value::TYPE_DICTIONARY)) { | 46 if (!value->IsType(Value::TYPE_DICTIONARY)) { |
| 46 LOG(WARNING) << "Expected JSON dictionary in configuration file " | 47 LOG(WARNING) << "Expected JSON dictionary in configuration file " |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 82 |
| 82 ConfigDirPolicyProvider::ConfigDirPolicyProvider( | 83 ConfigDirPolicyProvider::ConfigDirPolicyProvider( |
| 83 const PolicyDefinitionList* policy_list, | 84 const PolicyDefinitionList* policy_list, |
| 84 const FilePath& config_dir) | 85 const FilePath& config_dir) |
| 85 : FileBasedPolicyProvider( | 86 : FileBasedPolicyProvider( |
| 86 policy_list, | 87 policy_list, |
| 87 new ConfigDirPolicyProviderDelegate(config_dir)) { | 88 new ConfigDirPolicyProviderDelegate(config_dir)) { |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace policy | 91 } // namespace policy |
| OLD | NEW |