| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/configuration_policy_provider.h" | 5 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "chrome/browser/policy/external_data_fetcher.h" | 8 #include "chrome/browser/policy/external_data_fetcher.h" |
| 9 #include "chrome/browser/policy/policy_domain_descriptor.h" | |
| 10 #include "chrome/browser/policy/policy_map.h" | 9 #include "chrome/browser/policy/policy_map.h" |
| 11 #include "policy/policy_constants.h" | 10 #include "policy/policy_constants.h" |
| 12 | 11 |
| 13 namespace policy { | 12 namespace policy { |
| 14 | 13 |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 const char* kProxyPolicies[] = { | 16 const char* kProxyPolicies[] = { |
| 18 key::kProxyMode, | 17 key::kProxyMode, |
| 19 key::kProxyServerMode, | 18 key::kProxyServerMode, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 proxy_settings.release(), | 60 proxy_settings.release(), |
| 62 NULL); | 61 NULL); |
| 63 } | 62 } |
| 64 } | 63 } |
| 65 | 64 |
| 66 } // namespace | 65 } // namespace |
| 67 | 66 |
| 68 ConfigurationPolicyProvider::Observer::~Observer() {} | 67 ConfigurationPolicyProvider::Observer::~Observer() {} |
| 69 | 68 |
| 70 ConfigurationPolicyProvider::ConfigurationPolicyProvider() | 69 ConfigurationPolicyProvider::ConfigurationPolicyProvider() |
| 71 : did_shutdown_(false) {} | 70 : did_shutdown_(false), |
| 71 schema_registry_(NULL) {} |
| 72 | 72 |
| 73 ConfigurationPolicyProvider::~ConfigurationPolicyProvider() { | 73 ConfigurationPolicyProvider::~ConfigurationPolicyProvider() { |
| 74 DCHECK(did_shutdown_); | 74 DCHECK(did_shutdown_); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ConfigurationPolicyProvider::Init() {} | 77 void ConfigurationPolicyProvider::Init(SchemaRegistry* registry) { |
| 78 schema_registry_ = registry; |
| 79 schema_registry_->AddObserver(this); |
| 80 } |
| 78 | 81 |
| 79 void ConfigurationPolicyProvider::Shutdown() { | 82 void ConfigurationPolicyProvider::Shutdown() { |
| 80 did_shutdown_ = true; | 83 did_shutdown_ = true; |
| 84 if (schema_registry_) { |
| 85 // Unit tests don't initialize the BrowserPolicyConnector but call |
| 86 // shutdown; handle that. |
| 87 schema_registry_->RemoveObserver(this); |
| 88 schema_registry_ = NULL; |
| 89 } |
| 81 } | 90 } |
| 82 | 91 |
| 83 bool ConfigurationPolicyProvider::IsInitializationComplete( | 92 bool ConfigurationPolicyProvider::IsInitializationComplete( |
| 84 PolicyDomain domain) const { | 93 PolicyDomain domain) const { |
| 85 return true; | 94 return true; |
| 86 } | 95 } |
| 87 | 96 |
| 97 void ConfigurationPolicyProvider::OnSchemaRegistryUpdated( |
| 98 bool has_new_schemas) { |
| 99 if (has_new_schemas) |
| 100 RefreshPolicies(); |
| 101 } |
| 102 |
| 88 void ConfigurationPolicyProvider::UpdatePolicy( | 103 void ConfigurationPolicyProvider::UpdatePolicy( |
| 89 scoped_ptr<PolicyBundle> bundle) { | 104 scoped_ptr<PolicyBundle> bundle) { |
| 90 if (bundle.get()) | 105 if (bundle.get()) |
| 91 policy_bundle_.Swap(bundle.get()); | 106 policy_bundle_.Swap(bundle.get()); |
| 92 else | 107 else |
| 93 policy_bundle_.Clear(); | 108 policy_bundle_.Clear(); |
| 94 FixDeprecatedPolicies(&policy_bundle_.Get( | 109 FixDeprecatedPolicies(&policy_bundle_.Get( |
| 95 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))); | 110 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))); |
| 96 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, | 111 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, |
| 97 observer_list_, | 112 observer_list_, |
| 98 OnUpdatePolicy(this)); | 113 OnUpdatePolicy(this)); |
| 99 } | 114 } |
| 100 | 115 |
| 116 const scoped_refptr<SchemaMap>& |
| 117 ConfigurationPolicyProvider::schema_map() const { |
| 118 return schema_registry_->schema_map(); |
| 119 } |
| 120 |
| 101 void ConfigurationPolicyProvider::AddObserver(Observer* observer) { | 121 void ConfigurationPolicyProvider::AddObserver(Observer* observer) { |
| 102 observer_list_.AddObserver(observer); | 122 observer_list_.AddObserver(observer); |
| 103 } | 123 } |
| 104 | 124 |
| 105 void ConfigurationPolicyProvider::RemoveObserver(Observer* observer) { | 125 void ConfigurationPolicyProvider::RemoveObserver(Observer* observer) { |
| 106 observer_list_.RemoveObserver(observer); | 126 observer_list_.RemoveObserver(observer); |
| 107 } | 127 } |
| 108 | 128 |
| 109 void ConfigurationPolicyProvider::RegisterPolicyDomain( | |
| 110 scoped_refptr<const PolicyDomainDescriptor> descriptor) {} | |
| 111 | |
| 112 } // namespace policy | 129 } // namespace policy |
| OLD | NEW |