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. 4 5 #include "components/policy/core/common/configuration_policy_provider.h" 6 7 #include "base/callback.h" 8 #include "components/policy/core/common/external_data_fetcher.h" 9 #include "components/policy/core/common/policy_map.h" 10 11 namespace policy { 12 ~Observer()13ConfigurationPolicyProvider::Observer::~Observer() {} 14 ConfigurationPolicyProvider()15ConfigurationPolicyProvider::ConfigurationPolicyProvider() 16 : initialized_(false), schema_registry_(nullptr) {} 17 ~ConfigurationPolicyProvider()18ConfigurationPolicyProvider::~ConfigurationPolicyProvider() { 19 DCHECK(!initialized_); 20 } 21 Init(SchemaRegistry * registry)22void ConfigurationPolicyProvider::Init(SchemaRegistry* registry) { 23 schema_registry_ = registry; 24 schema_registry_->AddObserver(this); 25 initialized_ = true; 26 } 27 Shutdown()28void ConfigurationPolicyProvider::Shutdown() { 29 initialized_ = false; 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_ = nullptr; 35 } 36 } 37 IsInitializationComplete(PolicyDomain domain) const38bool ConfigurationPolicyProvider::IsInitializationComplete( 39 PolicyDomain domain) const { 40 return true; 41 } 42 UpdatePolicy(std::unique_ptr<PolicyBundle> bundle)43void ConfigurationPolicyProvider::UpdatePolicy( 44 std::unique_ptr<PolicyBundle> bundle) { 45 if (bundle) 46 policy_bundle_.Swap(bundle.get()); 47 else 48 policy_bundle_.Clear(); 49 for (auto& observer : observer_list_) 50 observer.OnUpdatePolicy(this); 51 } 52 schema_registry() const53SchemaRegistry* ConfigurationPolicyProvider::schema_registry() const { 54 return schema_registry_; 55 } 56 57 const scoped_refptr<SchemaMap>& schema_map() const58ConfigurationPolicyProvider::schema_map() const { 59 return schema_registry_->schema_map(); 60 } 61 AddObserver(Observer * observer)62void ConfigurationPolicyProvider::AddObserver(Observer* observer) { 63 observer_list_.AddObserver(observer); 64 } 65 RemoveObserver(Observer * observer)66void ConfigurationPolicyProvider::RemoveObserver(Observer* observer) { 67 observer_list_.RemoveObserver(observer); 68 } 69 OnSchemaRegistryUpdated(bool has_new_schemas)70void ConfigurationPolicyProvider::OnSchemaRegistryUpdated( 71 bool has_new_schemas) {} 72 OnSchemaRegistryReady()73void ConfigurationPolicyProvider::OnSchemaRegistryReady() {} 74 75 } // namespace policy 76