| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_based_policy_provider.h" | 5 #include "chrome/browser/policy/file_based_policy_provider.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 kSettleIntervalSeconds, | 43 kSettleIntervalSeconds, |
| 44 kReloadIntervalMinutes); | 44 kReloadIntervalMinutes); |
| 45 watcher_ = new FileBasedPolicyWatcher; | 45 watcher_ = new FileBasedPolicyWatcher; |
| 46 watcher_->Init(loader_.get()); | 46 watcher_->Init(loader_.get()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 FileBasedPolicyProvider::~FileBasedPolicyProvider() { | 49 FileBasedPolicyProvider::~FileBasedPolicyProvider() { |
| 50 loader_->Stop(); | 50 loader_->Stop(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool FileBasedPolicyProvider::Provide(ConfigurationPolicyStore* store) { | 53 bool FileBasedPolicyProvider::Provide( |
| 54 ConfigurationPolicyStoreInterface* store) { |
| 54 scoped_ptr<DictionaryValue> policy(loader_->GetPolicy()); | 55 scoped_ptr<DictionaryValue> policy(loader_->GetPolicy()); |
| 55 DCHECK(policy.get()); | 56 DCHECK(policy.get()); |
| 56 DecodePolicyValueTree(policy.get(), store); | 57 DecodePolicyValueTree(policy.get(), store); |
| 57 return true; | 58 return true; |
| 58 } | 59 } |
| 59 | 60 |
| 60 void FileBasedPolicyProvider::DecodePolicyValueTree( | 61 void FileBasedPolicyProvider::DecodePolicyValueTree( |
| 61 DictionaryValue* policies, | 62 DictionaryValue* policies, |
| 62 ConfigurationPolicyStore* store) { | 63 ConfigurationPolicyStoreInterface* store) { |
| 63 const PolicyDefinitionList* policy_list(policy_definition_list()); | 64 const PolicyDefinitionList* policy_list(policy_definition_list()); |
| 64 for (const PolicyDefinitionList::Entry* i = policy_list->begin; | 65 for (const PolicyDefinitionList::Entry* i = policy_list->begin; |
| 65 i != policy_list->end; ++i) { | 66 i != policy_list->end; ++i) { |
| 66 Value* value; | 67 Value* value; |
| 67 if (policies->Get(i->name, &value) && value->IsType(i->value_type)) | 68 if (policies->Get(i->name, &value) && value->IsType(i->value_type)) |
| 68 store->Apply(i->policy_type, value->DeepCopy()); | 69 store->Apply(i->policy_type, value->DeepCopy()); |
| 69 } | 70 } |
| 70 | 71 |
| 71 // TODO(mnissler): Handle preference overrides once |ConfigurationPolicyStore| | 72 // TODO(mnissler): Handle preference overrides once |ConfigurationPolicyStore| |
| 72 // supports it. | 73 // supports it. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 !watcher_.Watch(loader->config_file_path(), loader.get())) | 250 !watcher_.Watch(loader->config_file_path(), loader.get())) |
| 250 loader->OnError(); | 251 loader->OnError(); |
| 251 | 252 |
| 252 // There might have been changes to the directory in the time between | 253 // There might have been changes to the directory in the time between |
| 253 // construction of the loader and initialization of the watcher. Call reload | 254 // construction of the loader and initialization of the watcher. Call reload |
| 254 // to detect if that is the case. | 255 // to detect if that is the case. |
| 255 loader->Reload(); | 256 loader->Reload(); |
| 256 } | 257 } |
| 257 | 258 |
| 258 } // namespace policy | 259 } // namespace policy |
| OLD | NEW |