1 // Copyright 2013 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.
5 #include "components/policy/core/common/configuration_policy_provider.h"
7 #include "base/callback.h"
8 #include "components/policy/core/common/external_data_fetcher.h"
9 #include "components/policy/core/common/policy_map.h"
13 ConfigurationPolicyProvider::Observer::~Observer() {}
15 ConfigurationPolicyProvider::ConfigurationPolicyProvider()
16 : did_shutdown_(false),
17 schema_registry_(NULL
) {}
19 ConfigurationPolicyProvider::~ConfigurationPolicyProvider() {
20 DCHECK(did_shutdown_
);
23 void ConfigurationPolicyProvider::Init(SchemaRegistry
* registry
) {
24 schema_registry_
= registry
;
25 schema_registry_
->AddObserver(this);
28 void ConfigurationPolicyProvider::Shutdown() {
30 if (schema_registry_
) {
31 // Unit tests don't initialize the BrowserPolicyConnector but call
32 // shutdown; handle that.
33 schema_registry_
->RemoveObserver(this);
34 schema_registry_
= NULL
;
38 bool ConfigurationPolicyProvider::IsInitializationComplete(
39 PolicyDomain domain
) const {
43 void ConfigurationPolicyProvider::UpdatePolicy(
44 scoped_ptr
<PolicyBundle
> bundle
) {
46 policy_bundle_
.Swap(bundle
.get());
48 policy_bundle_
.Clear();
49 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer
,
51 OnUpdatePolicy(this));
54 SchemaRegistry
* ConfigurationPolicyProvider::schema_registry() const {
55 return schema_registry_
;
58 const scoped_refptr
<SchemaMap
>&
59 ConfigurationPolicyProvider::schema_map() const {
60 return schema_registry_
->schema_map();
63 void ConfigurationPolicyProvider::AddObserver(Observer
* observer
) {
64 observer_list_
.AddObserver(observer
);
67 void ConfigurationPolicyProvider::RemoveObserver(Observer
* observer
) {
68 observer_list_
.RemoveObserver(observer
);
71 void ConfigurationPolicyProvider::OnSchemaRegistryUpdated(
72 bool has_new_schemas
) {}
74 void ConfigurationPolicyProvider::OnSchemaRegistryReady() {}