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_pref_store.h" | 5 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( | 41 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( |
42 PolicyService* service, | 42 PolicyService* service, |
43 PolicyLevel level) | 43 PolicyLevel level) |
44 : policy_service_(service), | 44 : policy_service_(service), |
45 level_(level) { | 45 level_(level) { |
46 // Read initial policy. | 46 // Read initial policy. |
47 prefs_.reset(CreatePreferencesFromPolicies()); | 47 prefs_.reset(CreatePreferencesFromPolicies()); |
48 policy_service_->AddObserver(POLICY_DOMAIN_CHROME, "", this); | 48 policy_service_->AddObserver(POLICY_DOMAIN_CHROME, this); |
49 } | 49 } |
50 | 50 |
51 void ConfigurationPolicyPrefStore::AddObserver(PrefStore::Observer* observer) { | 51 void ConfigurationPolicyPrefStore::AddObserver(PrefStore::Observer* observer) { |
52 observers_.AddObserver(observer); | 52 observers_.AddObserver(observer); |
53 } | 53 } |
54 | 54 |
55 void ConfigurationPolicyPrefStore::RemoveObserver( | 55 void ConfigurationPolicyPrefStore::RemoveObserver( |
56 PrefStore::Observer* observer) { | 56 PrefStore::Observer* observer) { |
57 observers_.RemoveObserver(observer); | 57 observers_.RemoveObserver(observer); |
58 } | 58 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 // static | 103 // static |
104 ConfigurationPolicyPrefStore* | 104 ConfigurationPolicyPrefStore* |
105 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore( | 105 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore( |
106 PolicyService* policy_service) { | 106 PolicyService* policy_service) { |
107 return new ConfigurationPolicyPrefStore(policy_service, | 107 return new ConfigurationPolicyPrefStore(policy_service, |
108 POLICY_LEVEL_RECOMMENDED); | 108 POLICY_LEVEL_RECOMMENDED); |
109 } | 109 } |
110 | 110 |
111 ConfigurationPolicyPrefStore::~ConfigurationPolicyPrefStore() { | 111 ConfigurationPolicyPrefStore::~ConfigurationPolicyPrefStore() { |
112 policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, "", this); | 112 policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, this); |
113 } | 113 } |
114 | 114 |
115 void ConfigurationPolicyPrefStore::Refresh() { | 115 void ConfigurationPolicyPrefStore::Refresh() { |
116 scoped_ptr<PrefValueMap> new_prefs(CreatePreferencesFromPolicies()); | 116 scoped_ptr<PrefValueMap> new_prefs(CreatePreferencesFromPolicies()); |
117 std::vector<std::string> changed_prefs; | 117 std::vector<std::string> changed_prefs; |
118 new_prefs->GetDifferingKeys(prefs_.get(), &changed_prefs); | 118 new_prefs->GetDifferingKeys(prefs_.get(), &changed_prefs); |
119 prefs_.swap(new_prefs); | 119 prefs_.swap(new_prefs); |
120 | 120 |
121 // Send out change notifications. | 121 // Send out change notifications. |
122 for (std::vector<std::string>::const_iterator pref(changed_prefs.begin()); | 122 for (std::vector<std::string>::const_iterator pref(changed_prefs.begin()); |
(...skipping 23 matching lines...) Expand all Loading... |
146 // issue during startup. | 146 // issue during startup. |
147 BrowserThread::PostTask(BrowserThread::UI, | 147 BrowserThread::PostTask(BrowserThread::UI, |
148 FROM_HERE, | 148 FROM_HERE, |
149 base::Bind(&LogErrors, | 149 base::Bind(&LogErrors, |
150 base::Owned(errors.release()))); | 150 base::Owned(errors.release()))); |
151 | 151 |
152 return prefs.release(); | 152 return prefs.release(); |
153 } | 153 } |
154 | 154 |
155 } // namespace policy | 155 } // namespace policy |
OLD | NEW |