| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_reader.h" | 5 #include "chrome/browser/policy/configuration_policy_reader.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ConfigurationPolicyReader::OnUpdatePolicy() { | 98 void ConfigurationPolicyReader::OnUpdatePolicy() { |
| 99 Refresh(); | 99 Refresh(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void ConfigurationPolicyReader::OnProviderGoingAway() { | 102 void ConfigurationPolicyReader::OnProviderGoingAway() { |
| 103 provider_ = NULL; | 103 provider_ = NULL; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ConfigurationPolicyReader::AddObserver(Observer* observer) { |
| 107 observers_.AddObserver(observer); |
| 108 } |
| 109 |
| 110 void ConfigurationPolicyReader::RemoveObserver(Observer* observer) { |
| 111 observers_.RemoveObserver(observer); |
| 112 } |
| 113 |
| 106 // static | 114 // static |
| 107 ConfigurationPolicyReader* | 115 ConfigurationPolicyReader* |
| 108 ConfigurationPolicyReader::CreateManagedPlatformPolicyReader() { | 116 ConfigurationPolicyReader::CreateManagedPlatformPolicyReader() { |
| 109 BrowserPolicyConnector* connector = | 117 BrowserPolicyConnector* connector = |
| 110 g_browser_process->browser_policy_connector(); | 118 g_browser_process->browser_policy_connector(); |
| 111 return new ConfigurationPolicyReader( | 119 return new ConfigurationPolicyReader( |
| 112 connector->GetManagedPlatformProvider(), PolicyStatusInfo::MANDATORY); | 120 connector->GetManagedPlatformProvider(), PolicyStatusInfo::MANDATORY); |
| 113 } | 121 } |
| 114 | 122 |
| 115 // static | 123 // static |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 173 } |
| 166 | 174 |
| 167 void ConfigurationPolicyReader::Refresh() { | 175 void ConfigurationPolicyReader::Refresh() { |
| 168 if (!provider_) | 176 if (!provider_) |
| 169 return; | 177 return; |
| 170 | 178 |
| 171 // Read policy state into a new keeper and swap out old keeper. | 179 // Read policy state into a new keeper and swap out old keeper. |
| 172 scoped_ptr<ConfigurationPolicyStatusKeeper> new_keeper( | 180 scoped_ptr<ConfigurationPolicyStatusKeeper> new_keeper( |
| 173 new ConfigurationPolicyStatusKeeper(provider_, policy_level_)); | 181 new ConfigurationPolicyStatusKeeper(provider_, policy_level_)); |
| 174 policy_keeper_.reset(new_keeper.release()); | 182 policy_keeper_.reset(new_keeper.release()); |
| 183 |
| 184 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyValuesChanged()); |
| 175 } | 185 } |
| 176 | 186 |
| 177 // PolicyStatus | 187 // PolicyStatus |
| 178 PolicyStatus::PolicyStatus(ConfigurationPolicyReader* managed_platform, | 188 PolicyStatus::PolicyStatus(ConfigurationPolicyReader* managed_platform, |
| 179 ConfigurationPolicyReader* managed_cloud, | 189 ConfigurationPolicyReader* managed_cloud, |
| 180 ConfigurationPolicyReader* recommended_platform, | 190 ConfigurationPolicyReader* recommended_platform, |
| 181 ConfigurationPolicyReader* recommended_cloud) | 191 ConfigurationPolicyReader* recommended_cloud) |
| 182 : managed_platform_(managed_platform), | 192 : managed_platform_(managed_platform), |
| 183 managed_cloud_(managed_cloud), | 193 managed_cloud_(managed_cloud), |
| 184 recommended_platform_(recommended_platform), | 194 recommended_platform_(recommended_platform), |
| 185 recommended_cloud_(recommended_cloud) { | 195 recommended_cloud_(recommended_cloud) { |
| 186 } | 196 } |
| 187 | 197 |
| 188 PolicyStatus::~PolicyStatus() { | 198 PolicyStatus::~PolicyStatus() { |
| 189 } | 199 } |
| 190 | 200 |
| 201 void PolicyStatus::AddObserver(Observer* observer) const { |
| 202 managed_platform_->AddObserver(observer); |
| 203 managed_cloud_->AddObserver(observer); |
| 204 recommended_platform_->AddObserver(observer); |
| 205 recommended_cloud_->AddObserver(observer); |
| 206 } |
| 207 |
| 208 void PolicyStatus::RemoveObserver(Observer* observer) const { |
| 209 managed_platform_->RemoveObserver(observer); |
| 210 managed_cloud_->RemoveObserver(observer); |
| 211 recommended_platform_->RemoveObserver(observer); |
| 212 recommended_cloud_->RemoveObserver(observer); |
| 213 } |
| 214 |
| 191 ListValue* PolicyStatus::GetPolicyStatusList(bool* any_policies_sent) const { | 215 ListValue* PolicyStatus::GetPolicyStatusList(bool* any_policies_sent) const { |
| 192 ListValue* result = new ListValue(); | 216 ListValue* result = new ListValue(); |
| 193 std::vector<DictionaryValue*> unsent_policies; | 217 std::vector<DictionaryValue*> unsent_policies; |
| 194 | 218 |
| 195 *any_policies_sent = false; | 219 *any_policies_sent = false; |
| 196 const PolicyDefinitionList* supported_policies = | 220 const PolicyDefinitionList* supported_policies = |
| 197 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); | 221 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(); |
| 198 const PolicyDefinitionList::Entry* policy = supported_policies->begin; | 222 const PolicyDefinitionList::Entry* policy = supported_policies->begin; |
| 199 for ( ; policy != supported_policies->end; ++policy) { | 223 for ( ; policy != supported_policies->end; ++policy) { |
| 200 if (!AddPolicyFromReaders(policy->policy_type, result)) { | 224 if (!AddPolicyFromReaders(policy->policy_type, result)) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 list->Append(mc_policy); | 287 list->Append(mc_policy); |
| 264 if (rp_policy) | 288 if (rp_policy) |
| 265 list->Append(rp_policy); | 289 list->Append(rp_policy); |
| 266 if (rc_policy) | 290 if (rc_policy) |
| 267 list->Append(rc_policy); | 291 list->Append(rc_policy); |
| 268 | 292 |
| 269 return added_policy; | 293 return added_policy; |
| 270 } | 294 } |
| 271 | 295 |
| 272 } // namespace policy | 296 } // namespace policy |
| OLD | NEW |