OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/policy/asynchronous_policy_provider.h" |
| 6 |
| 7 #include "base/task.h" |
| 8 #include "chrome/browser/browser_thread.h" |
| 9 #include "chrome/browser/policy/asynchronous_policy_loader.h" |
| 10 |
| 11 namespace policy { |
| 12 |
| 13 AsynchronousPolicyProvider::AsynchronousPolicyProvider( |
| 14 const PolicyDefinitionList* policy_list, |
| 15 scoped_refptr<AsynchronousPolicyLoader> loader) |
| 16 : ConfigurationPolicyProvider(policy_list), |
| 17 loader_(loader) { |
| 18 // TODO(danno): The weak pointer provider shouldn't be necessary. Instead, the |
| 19 // PrefStore should explicitly observe preference changes that are reported |
| 20 // during the policy change. |
| 21 loader_->SetProvider(AsWeakPtr()); |
| 22 loader_->Init(); |
| 23 } |
| 24 |
| 25 AsynchronousPolicyProvider::~AsynchronousPolicyProvider() { |
| 26 loader_->Stop(); |
| 27 } |
| 28 |
| 29 bool AsynchronousPolicyProvider::Provide( |
| 30 ConfigurationPolicyStoreInterface* store) { |
| 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 32 DCHECK(loader_->policy()); |
| 33 DecodePolicyValueTree(loader_->policy(), store); |
| 34 return true; |
| 35 } |
| 36 |
| 37 scoped_refptr<AsynchronousPolicyLoader> AsynchronousPolicyProvider::loader() { |
| 38 return loader_; |
| 39 } |
| 40 |
| 41 } // namespace policy |
OLD | NEW |