Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/policy/configuration_policy_provider.cc

Issue 56623005: Policy providers all get a SchemaRegistry to work with. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-9-purge-with-callback
Patch Set: Fixed mac tests Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 browser_policy_connector but call
bartfab (slow) 2013/11/05 15:53:04 Written with underscores like this, browser_policy
Joao da Silva 2013/11/07 13:15:00 Done.
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 const scoped_refptr<SchemaMap>& current_map,
bartfab (slow) 2013/11/05 15:53:04 General question: Does anyone ever use the current
Joao da Silva 2013/11/07 13:15:00 That's right, removed.
99 bool has_new_schemas) {
100 if (has_new_schemas)
101 RefreshPolicies();
102 }
103
88 void ConfigurationPolicyProvider::UpdatePolicy( 104 void ConfigurationPolicyProvider::UpdatePolicy(
89 scoped_ptr<PolicyBundle> bundle) { 105 scoped_ptr<PolicyBundle> bundle) {
90 if (bundle.get()) 106 if (bundle.get())
91 policy_bundle_.Swap(bundle.get()); 107 policy_bundle_.Swap(bundle.get());
92 else 108 else
93 policy_bundle_.Clear(); 109 policy_bundle_.Clear();
94 FixDeprecatedPolicies(&policy_bundle_.Get( 110 FixDeprecatedPolicies(&policy_bundle_.Get(
95 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))); 111 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())));
96 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, 112 FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer,
97 observer_list_, 113 observer_list_,
98 OnUpdatePolicy(this)); 114 OnUpdatePolicy(this));
99 } 115 }
100 116
117 const scoped_refptr<SchemaMap>&
118 ConfigurationPolicyProvider::schema_map() const {
119 return schema_registry_->schema_map();
120 }
121
101 void ConfigurationPolicyProvider::AddObserver(Observer* observer) { 122 void ConfigurationPolicyProvider::AddObserver(Observer* observer) {
102 observer_list_.AddObserver(observer); 123 observer_list_.AddObserver(observer);
103 } 124 }
104 125
105 void ConfigurationPolicyProvider::RemoveObserver(Observer* observer) { 126 void ConfigurationPolicyProvider::RemoveObserver(Observer* observer) {
106 observer_list_.RemoveObserver(observer); 127 observer_list_.RemoveObserver(observer);
107 } 128 }
108 129
109 void ConfigurationPolicyProvider::RegisterPolicyDomain(
110 scoped_refptr<const PolicyDomainDescriptor> descriptor) {}
111
112 } // namespace policy 130 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698