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 : initialized_(false),
17 schema_registry_(NULL
) {}
19 ConfigurationPolicyProvider::~ConfigurationPolicyProvider() {
20 DCHECK(!initialized_
);
23 void ConfigurationPolicyProvider::Init(SchemaRegistry
* registry
) {
24 schema_registry_
= registry
;
25 schema_registry_
->AddObserver(this);
29 void ConfigurationPolicyProvider::Shutdown() {
31 if (schema_registry_
) {
32 // Unit tests don't initialize the BrowserPolicyConnector but call
33 // shutdown; handle that.
34 schema_registry_
->RemoveObserver(this);
35 schema_registry_
= NULL
;
39 bool ConfigurationPolicyProvider::IsInitializationComplete(
40 PolicyDomain domain
) const {
44 void ConfigurationPolicyProvider::UpdatePolicy(
45 scoped_ptr
<PolicyBundle
> bundle
) {
47 policy_bundle_
.Swap(bundle
.get());
49 policy_bundle_
.Clear();
50 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer
,
52 OnUpdatePolicy(this));
55 SchemaRegistry
* ConfigurationPolicyProvider::schema_registry() const {
56 return schema_registry_
;
59 const scoped_refptr
<SchemaMap
>&
60 ConfigurationPolicyProvider::schema_map() const {
61 return schema_registry_
->schema_map();
64 void ConfigurationPolicyProvider::AddObserver(Observer
* observer
) {
65 observer_list_
.AddObserver(observer
);
68 void ConfigurationPolicyProvider::RemoveObserver(Observer
* observer
) {
69 observer_list_
.RemoveObserver(observer
);
72 void ConfigurationPolicyProvider::OnSchemaRegistryUpdated(
73 bool has_new_schemas
) {}
75 void ConfigurationPolicyProvider::OnSchemaRegistryReady() {}